title | permalink | redirect_from |
---|---|---|
Create Swap Space using ZRAM or RAM Compression |
/documentation/consumer/guides/zram_swapspace.md.html |
/documentation/ConsumerEdition/guides/zram_swapspace.md.html |
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 (http://snapshots.linaro.org/96boards/)
- If you are not using the DragonBoard410c, you will need to rebuild the kernel using
CONFIG_ZRAM=m
andCONFIG_ZSMALLOC=m
Kconfig option.
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/zram.sh
Now enter the following text, this will create a swap space 3 times that of actual usable memory
#!/bin/bash
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))
First, Make it executable
sudo chmod +x /usr/bin/zram.sh
Next add it to the rc.local script
sudo nano /etc/rc.local
Add the following line just above exit 0
/usr/bin/zram.sh &
sudo reboot
Enjoy a faster swap, go ahead and try opening multiple chrome tabs and compiling something with make -j$(nproc)
!!!