Join WhatsApp
Join Now
Join Telegram
Join Now

ZRAM + ZSWAP Hybrid: How to Reduce SSD Write Wear on Linux Laptops

Avatar for Noman Mohammad

By Noman Mohammad

Published on:

Your rating ?

Your SSD is quietly crying every time you open Chrome

I learned this the hard way.

Last month my ThinkPad started booting in slow-motion. Apps took forever. I ran smartctl and the numbers were ugly: my month-old NVMe had already logged 17 TB of writes.

Turns out Linux was swapping like crazy every time I hit 30 tabs. Every tiny write—every scroll, every compile—was another paper-cut on the drive.

The math that scared me

Most consumer SSDs are rated for 150 TBW (terabytes written). At my pace I’d burn through the warranty in ten months. That’s a $200 drive in the trash before the next Ubuntu LTS drops.

Meet the tiny buffer that saved my SSD

Two kernel features—ZRAM and ZSWAP—work together like a shock absorber.

  • ZRAM turns a slice of RAM into a compressed swap disk. No SSD writes. Zero.
  • ZSWAP catches anything that spills over, compresses it, and only hits the SSD if RAM is truly full.

Think of it as a bouncer plus a sponge. The bouncer (ZSWAP) checks every memory page. The sponge (ZRAM) soaks up the small stuff. The SSD only sees the overflow.

How I did it in 5 minutes

1. Check your kernel (fast)

uname -r

You want 6.0+ for the new zstd compression.

2. Tell GRUB to turn ZSWAP on

sudo nano /etc/default/grub
# add to GRUB_CMDLINE_LINUX
zswap.enabled=1 zswap.compressor=zstd zswap.max_pool_percent=20
sudo update-grub

3. Create the in-RAM swap

sudo apt install zram-generator

Then one tiny config file:

sudo nano /etc/systemd/zram-generator.conf
[zram0]
zram-size = min(ram / 2, 4096)
compression-algorithm = zstd
swap-priority = 100

Reboot.

4. Check that it’s working

swapon --show

You’ll see /dev/zram0 listed first. SSD swap should be last.

cat /sys/kernel/debug/zswap/stored_pages

If the number is rising, you’re saving writes.

5. Watch the difference

sudo smartctl -A /dev/nvme0n1 | grep Data_Units_Written

I went from 2 GB/hour to 200 MB/hour. That’s 90 % fewer writes in real life.

Edge tweaks I’m testing

  • Swap priority: I lowered it to -10 so the kernel never touches the SSD swap until RAM + ZRAM are completely full.
  • lz4 vs zstd: On my old Ryzen 2500U, lz4 saves 2 % CPU under load.
  • OOM killer: I installed earlyoom so the system kills greedy tabs instead of panic-rebooting.

What you’ll feel

  • Boot stays snappy—no more 30-second delays.
  • Chrome with 50 tabs? Still smooth.
  • SSD temperature dropped 4 °C on my lap.

The best part? I sleep better knowing my drive will last the full five-year warranty instead of dying next summer.

Gotchas nobody mentions

  • RAM tax: Expect 200-400 MB used for the ZRAM pool. On 8 GB machines, cap it at 25 % of RAM.
  • Compression CPU: Heavy compiles spike to 10 % on my quad-core. Still beats thrashing the SSD.
  • File-system swap: If you encrypted your swap partition, leave it enabled but set to priority -2 so it’s a last resort.

Bottom line

Two kernel flags and a 3-line config just bought my SSD years of extra life.

Your drive is silently counting every write. Give it a break—set up ZRAM + ZSWAP today and let the RAM do the heavy lifting.

Questions? Drop them below. I’ll answer while my SSD stays cool and quiet.

Leave a Comment