Create Swap Space using ZRAM or RAM Compression

ZRAM enable us to create extra swap space but without the cons of slower speeds due to Hard Drive or SD Card limitations. It is not as fast as actual RAM, but it is close enough for the speed degradation to not be noticable.


  • 96Boards Consumer Edition board (tested with DragonBoard410c)


  • Linaro Debian Operating system snapshot Builds (
  • If you are not using the DragonBoard410c, you will need to rebuild the kernel using CONFIG_ZRAM=m and CONFIG_ZSMALLOC=m Kconfig option.


Create swap script

Feel free to use the text editor of your choice, I’ll be using ‘nano’ fot the rest of this guide.

sudo nano /usr/bin/

Now enter the following text, this will create a swap space 3 times that of actual usable memory

modprobe zram num_devices=4

totalmem=`free | grep -e "^Mem:" | awk '{print $2}'`
mem=$(( ($totalmem)* 1024 * 3))

echo $mem > /sys/block/zram0/disksize

mkswap /dev/zram0

swapon -p 5 /dev/zram0

Press ‘ctrl+x’ to exit and ‘y’ to save the file. You can change the amout of zram swap by modifying mem=$(( ($totalmem)* 1024 * 3))

Next, to make sure the script runs on every boot:

First, Make it executable

sudo chmod +x /usr/bin/

Next add it to the rc.local script

sudo nano /etc/rc.local

Add the following line just above exit 0

/usr/bin/ &


sudo reboot

That’s It!

Enjoy a faster swap, go ahead and try opening multiple chrome tabs and compiling something with make -j$(nproc) !!!

Video Demonstration