How to activate ZRAM on Linux to speed up older PC
Do you have an old PC that seems very slow even after installing a lightweight Linux distro? Don’t worry: there is a simple solution that can make a difference, ZRAM.
In this guide, I will explain what it is, why it is useful, and how to activate it on the main lightweight distributions such as Linux Lite, Lubuntu, Xubuntu, Peppermint, Q4OS, Ufficio Zero Minimal, antiX, and Puppy Linux.
What is ZRAM and why use it?
ZRAM is a Linux kernel feature that creates a portion of compressed RAM, used as a fast swap area.
Why is it useful?
- If you have 1 or 2 GB of RAM, ZRAM allows you to load more applications without saturating the memory.
- It avoids continuous writing to the disk (traditional swap), increasing speed.
- Ideal for older PCs with slow hard drives.
Check if ZRAM is already active
Some distros (such as Lubuntu and Linux Lite) may have ZRAM pre-activated. To check:
zramctl
If you see a list of devices (es. /dev/zram0), ZRAM is already active.
If there is nothing, activate it by following the instructions below.
How to activate ZRAM on Linux
The method varies slightly depending on the distro.
Universal method (all distros)
- Install the zram-tools package
sudo apt update && sudo apt install zram-tools
- Configure ZRAM
- Open the configuration file:
sudo nano /etc/default/zramswap
You will find a line like this:
PERCENT=50
You can increase the value (e.g. 75) to allocate more ZRAM space (percentage relative to actual RAM).
- Restart the service
sudo systemctl restart zramswap
- Verify
zramctl
You will see the allocated space and the compression level.
For distros without systemd (antiX, Devuan, Puppy)
You can use a simple script:
sudo modprobe zram
echo lz4 > /sys/block/zram0/comp_algorithm
echo $(( $(getconf _PHYS_PAGES) * 1024 / 2 )) > /sys/block/zram0/disksize
mkswap /dev/zram0
swapon /dev/zram0
This activates ZRAM manually (it must be repeated at restart, or create a script in /etc/init.d).
Quanto spazio dare a ZRAM?
- PC with 1 GB of RAM → 512 MB ZRAM
- PC with 2 GB of RAM → 1 GB ZRAM
- PC with 4 GB or more → 2 GB ZRAM
How to check if it works
After enabling ZRAM, use:
free -h
You will see the Swap entry populated with the ZRAM size, even if you do not have swap partitions.
Which distros does this guide apply to?
- Linux Lite / Lubuntu / Xubuntu / Peppermint / Q4OS → use the method with
zram-tools - Ufficio Zero Minimal → works in the same way (based on Devuan)
- antiX and Puppy Linux → use the manual script because they do not use systemd
🔗 Useful resource
Want to know which are the best lightweight distros for old PCs? Take a look at our guide: 8 lightweight Linux distros for older PCs (internal link).
