Raspberry Pi

How to install ZRAM on Raspberry Pi

Are you worried about your Raspberry Pi memory issue and looking for a way to resolve it? If so, then you should consider installing ZRAM on your Raspberry Pi device. ZRAM is a Linux Kernel Module which is intended specially to fix the memory issue as it creates a block which can then be utilized as a swap memory. It enhances the memory space by compressing the memory pages and storing them in its memory block. If you are using a Raspberry Pi device having 1GB or 2GB RAM, then you should consider installing ZRAM on your device and if you are seeking for an easy installation of Raspberry Pi, then this article will help you in such a case.

How to install ZRAM on Raspberry Pi

Here, you will find the required instructions to install ZRAM on your Raspberry Pi device in order to increase your memory space. The below steps are required to be performed to ZRAM on your Raspberry Pi device.

Step 1: To begin the installation of ZRAM, your first task will be to ensure whether the Raspberry Pi packages are updated and in order to check that, you will need to follow the update command which is given below.

$ sudo apt update

Step 2: Next after the update, you will need to run the “full-upgrade” command to ensure having an upgraded version of system packages and to do this, follow the below mentioned command in the terminal.

$ sudo apt full-upgrade

Step 3: In the next step, you will need to use git to clone the script and in order to do the clone, you will need to download the “git” on your Raspberry Pi device using the below mentioned command in the terminal.

$ sudo apt install git

The above command will install “git” on your Raspberry Pi device, as in our case it is already installed so we will get confirmation from the command.

Step 4: Now, after finishing the above steps, you will need to reboot your Raspberry Pi device using the “reboot” command so that when it reboots, the changes will take place.

Step 5: After the download, you will now clone the script from the GitHub website using the below mentioned command in the terminal.

$ git clone https://github.com/foundObjects/zram-swap.git

After entering the above command, the setup process will require a few minutes to clone the script and you will need to be patient during the process.

Step 6: After completing the process, you will need to change the directory of the ZRAM script you just downloaded on your device and to do that use the below mentioned command in the terminal.

$ cd zram-swap

Step 7: After entering into the directory of “zram-swap”, you will need to run the ZRAM installation script there and to do that follow the below given command and execute it into the terminal.

$ sudo ./install.sh

Step 8: After successfully installing the ZRAM on your Raspberry Pi device, you will need to do an additional step to check the status of ZRAM storage through the below mentioned command.

$ sudo cat /proc/swaps

From the above information, you will see that ZRAM has highest priority as compared to other disk swap, it means that the OS will first use ZRAM to compress the files and then delivers them towards the low disk swap. That’s it, now you have increased your memory space by installing ZRAM on your Raspberry Pi device.

Conclusion

Now at this moment, you have gained enough knowledge to install ZRAM on your Raspberry Pi device and when you have successfully done it, you will be relieved from the worry of having a low memory space on your Raspberry Pi device. ZRAM is a great utility and having it on your Raspberry Pi device allows you to fit more data. Also, the installation process is fairly simple as you won’t face an issue during the entire process.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.