Using ZRAM on Your Raspberry Pi to Improve Performance (2026 Edition)

New Article
RaspberryPiPerformance
Using ZRAM on Your Raspberry Pi to Improve Performance (2026 Edition)

The Modern Way to Enable ZRAM on Raspberry Pi

ZRAM creates a compressed block device directly inside RAM and uses it as high-speed swap. Compared to writing swap pages to a slow microSD card, ZRAM is orders of magnitude faster and dramatically reduces flash wear.

In 2018, enabling ZRAM meant downloading custom shell scripts and writing manual systemd units. In 2026, Debian and Raspberry Pi OS include systemd-zram-generator right in the official repositories — no third-party scripts required.

1. Install systemd-zram-generator

2. Configure ZRAM with zstd Compression

Create or edit /etc/systemd/zram-generator.conf:

Add the following configuration (using 50% of RAM up to 4 GB with fast zstd compression):

[zram0]
zram-size = min(ram / 2, 4096)
compression-algorithm = zstd
swap-priority = 100

3. Optional: Disable SD-Card Swap

If you want to avoid swap writes to your microSD card completely, disable dphys-swapfile (if installed):

4. Activate and Verify

Reload systemd and start the generated ZRAM swap unit (or simply reboot):

You should now see /dev/zram0 listed with zstd compression and priority 100. That's all it takes in 2026 — clean, maintainable, and fully managed by systemd.

Related articles

David Krawiec
About the Author
David Krawiec

I am very interested in many topics related to technology. My current focus lies on how to realize projects with a small budget regarding most importantly the cost of invested time. Being mostly a soloist means getting out most without the abstinence of freedom, performance or quality.