2014年4月1日火曜日

How to use zram

By default, Raspbian uses swap file in sdcard for its easy setup.
Swap is generally helpful when system memory is getting less.
But, swap in sdcard partition is a problem since it shortens life of sdcard hardware by frequent data write for swap out. Also, it has slow performance problem.

Therefore, 'zram' is one solution to solve the issues.
It is a kernel feature to create compressible swap partition on ram.

Following instruction explains how to enable it for your raspberry pi.

Disable default swap setting

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


Enable swap on zram

Load zram module.

# modprobe zram

Set 128MB zram.

# echo $((128*1024*1024)) > /sys/block/zram0/disksize

Create swap on the zram.

# mkswap /dev/block/zram0

Enable swap.

# swapon -p 10 /dev/block/zram0

3 件のコメント: