How To Set And Use ZRAM swap

sudo systemctl stop dev-zram0.swap systemd-zram-setup@zram0.service
sudo systemctl disable dev-zram0.swap systemd-zram-setup@zram0.service
sudo systemctl mask dev-zram0.swap systemd-zram-setup@zram0.service

Note that this will disable both zram and normal swap

I use:

# /etc/sysctl.d/9999-swappiness.conf 
vm.swappiness=0

While that does not disable swap, it makes its usage possible only in very extreme low-memory situations, which I think is better than crashing the VM for OOM.

2 Likes

That will indeed work better than disabling swap completely, though I believe using this with zram-based swap could be less-than-ideal for performance.