2014年4月1日火曜日

How to use zram

Optimizing Swap with ZRAM on Raspbian

Optimizing Swap with ZRAM on Raspbian

By default, Raspbian uses a swap file on the SD card for easy setup. While swap helps when system memory is low, using the SD card for swap can shorten its lifespan due to frequent writes and cause slower performance.

ZRAM is a solution to these issues. It’s a kernel feature that creates a compressed swap partition in RAM, improving both performance and longevity of the SD card.

Disable Default Swap Setting

sudo apt-get install chkconfig
sudo chkconfig dphys-swapfile off

Enable Swap on ZRAM

Load the ZRAM module:

sudo modprobe zram

Set a 128MB ZRAM swap space:

echo $((128*1024*1024)) | sudo tee /sys/zram0/disksize

Create the swap space on ZRAM:

sudo mkswap /dev/zram0

Enable the swap:

sudo swapon -p 10 /dev/zram0

With ZRAM enabled, your Raspberry Pi will benefit from faster swap performance and reduced SD card wear.

Enjoy optimizing your Raspberry Pi! 🚀

4 件のコメント: