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! 🚀
gggggggggggg
返信削除gggggggggggg
返信削除/dev/block/zram0 has moved to /dev/zram0
返信削除(2019-06-14)
Thanks for the information!
削除I fixed it.