How to Add zRAM on Ubuntu 26.04
zRAM is a compressed block device in RAM, used for swap or cache, which can improve performance on systems with limited RAM.
Enable zRAM on Ubuntu 26.04
Ubuntu includes support for zRAM via the systemd-zram-generator.
Install the zram-generator package
apt update
apt install systemd-zram-generator -y
Output:
root@vps:~# apt update
apt install systemd-zram-generator
Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
...
Installing: systemd-zram-generator
Create configuration file
Create a config file at /etc/systemd/zram-generator.conf
nano /etc/systemd/zram-generator.conf
Paste this:
[zram0]
zram-size = ram * 0.5
compression-algorithm = zstd
This sets zRAM to 50% of your total RAM.
You can also use:
compression-algorithm = lz4
for faster compression.
Reload and start zRAM
systemctl daemon-reexec
systemctl start systemd-zram-setup@zram0.service
Check if it's active:
swapon --show
You should see /dev/zram0 as an active swap device.
Output:
root@vps:~# swapon --show
NAME TYPE SIZE USED PRIO
/dev/vda2 partition 512M 0B -2
/dev/zram0 partition 1.7G 0B 100 CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS