Optimizing Swap with ZRAM on Raspberry Pi OS¶
By default, Raspberry Pi OS uses a swap file on the SD card, which can reduce performance and shorten the card's lifespan. ZRAM is a solution that creates a compressed swap partition in RAM, improving both performance and longevity.
1. Disable Default Swap Setting¶
2. Enable Swap on ZRAM¶
Load the ZRAM module:
Set a 128MB ZRAM swap space:
Create and enable the swap:
With ZRAM enabled, your Raspberry Pi will benefit from faster swap performance and reduced SD card wear.
Enjoy optimizing your Raspberry Pi!