Zram, https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html, is a Linux kernel module that creates a compressed block device in RAM. This device can be used as swap space or a general-purpose RAM disk. By compressing data in memory, zram allows your system to store more data in RAM, reducing the need to swap to slower disk storage and improving overall responsiveness.
In particular, zram
- Increases effective RAM capacity by compressing data.
- Reduces disk I/O and wear, especially useful on SSDs.
- Improves performance on systems with limited memory.
If you’re looking to boost your Linux system’s performance, especially on machines with limited RAM, zram is a powerful tool worth exploring.
In this post, I’ll show how to set it up on both Arch Linux and Ubuntu.
Installing zram
On Arch Linux
Install the zram generator package:
|
1 2 |
sudo pacman -S zram-generator |
On Ubuntu
Install the systemd zram generator:
|
1 2 |
sudo apt install systemd-zram-generator |
Configuring zram
Create a configuration file to set up your zram device. For example, to allocate half of your system’s RAM to zram and use the efficient zstd compression algorithm, run:
|
1 2 3 4 5 |
cat <<-EOF | sudo tee /etc/systemd/zram-generator.conf [zram0] zram-size = (ram / 2) compression-algorithm = zstd EOF |
After saving the configuration, reboot your system to activate zram.
By default, zram will have the precedence over an existing swap partition.
You can use the command zramctl to see the status of zram and swapon to show your swap partitions (zram’s one will be /dev/zram0).





