
Follow ZDNET: Add us as a preferred source on Google.
ZDNET's key takeaways
- With the price of RAM skyrocketing, try this to speed up Linux.
- This configuration is simple to do.
- Some distributions include ZRAM by default.
The last time I checked the price of memory (RAM), I was shocked. According to Tom's Hardware, the price of RAM has increased 240% on Amazon. Wow.
There are two primary reasons why the price of RAM has jumped:
- Supply chain bottlenecks and geopolitical instability
- Explosive demand from AI and data centers
As AI continues to grow in popularity, the price of RAM will most likely continue to climb (or remain flat at the higher prices).
If those out-of-control price increases make adding RAM to your Linux system(s) prevent you from upgrading, what can you do?
Fortunately, there's a software solution you can use to eke out more speed from your Linux computers.
Also: I've used Linux for 30 years. Here are 5 reasons why I'll never switch to Windows or MacOS
That solution is called ZRAM. Let me show you how to install and use it.
What is ZRAM?
ZRAM is a compressed swap space that is used entirely in RAM. When your system is low on memory, it typically uses a traditional swap space, which is slower than a RAM-based space. Because ZRAM keeps swapped data in memory, it's much faster than a standard swap-system.
Installing ZRAM
What you'll need: The only things you'll need for this are a running instance of Linux and a user with sudo preferences. Keep in mind that ZRAM is typically enabled by default on Fedora and Fedora-based distributions. I've also found that some Debian-based distributions (such as Pop!_OS) ship with ZRAM preinstalled as well.
Also: The best Linux laptops you can buy: Expert tested
I'll demonstrate how this is done on a Debian-based distribution.
Next, we can install ZRAM with the following command:
sudo apt-get install zram-tools -y
ZRAM is now installed and ready to be configured.
Configuring ZRAM
With ZRAM installed, it's now time to configure it. Here's how.
1. Open the ZRAM config file
Open the ZRAM config file for editing with the command:
sudo nano /etc/default/zramswap
2. Customize ZRAM
In that file, you'll want to customize the following lines:
ALGO=
PERCENT=
PRIORITY=
You can also swap out SIZE= for PERCENTAGE=, but using the percentage option is often easier.
As far as the ALGO option is concerned, you have two options:
- lz4 – used for pure speed
- zstd – used for better compression
Also: This Linux distro I recommend to power users takes a unique approach to OS design
I want to go with lz4 and 20% of my total RAM, with a priority of 100 (the default). Here's how those config lines would look:
ALGO=lz4
PERCENT=20
PRIORITY=100
Save and close the file.
3. Restarting ZRAM
With the configuration taken care of, you'll then need to restart the ZRAM system with the command:
sudo systemctl zram
ZRAM is now honoring your new defaults.
One caveat
You might find that your system is configured with a “swappiness” that is too aggressive. Aggressive swappiness means it will swap out memory pages from the RAM swap space more frequently, which can lead to an increase in swap activity and slow down the system.
To check on this, issue the command:
sudo sysctl -a | grep -E ‘vm.vfs_cache_pressure|vm.swappiness|vm.dirty_background_ratio|vm.dirty_ratio'
The command will output something like this:
vm.dirty_background_ratio=0
vm.dirty_ratio=0
vm.swappiness=180
vm.vfs_cache_pressure=100
- vm.swappiness — Ensures that ZRAM is used more actively but without being over-prioritized.
- vm.vfs_cache_pressure — This configures how much the kernel can reclaim inode and dentry caches.
- vm.dirty_background_ratio — The ratio of unsaved data to disk, which can prevent sudden large I/O operations.
You can adjust these parameters within the /etc/sysctl.d/99-zram-tweaks.conf file (sudo nano /etc/sysctl.d/99-zram-tweaks.conf). You might want to set these values to something like this:
vm.dirty_background_ratio=5
vm.dirty_ratio=10
vm.swappiness=50
vm.vfs_cache_pressure=50
Save and close the file. Apply those changes with the command:
sudo sysctl –system
Note: If you don't find the 99-zram-tweaks file on your system, create it and add the above values. To create and edit the file, issue the command:
sudo nano /etc/sysctl.d/99-zram-tweaks.conf
ZRAM should now be in place and configured. You should start to notice a bit more speed, especially when you have several apps open on your desktop.
Turn off your default swap space
You'll also want to disable your default swap space (so there's no conflict between it and ZRAM). To do that, open your fstab file with:
sudo nano /etc/fstab
In that file, look for the line that starts with:
swapfile
Place a # character at the beginning of the line and save/close the file.
Disable the running swap space with:
sudo swapoff -a
Also: This free Linux distro is the easiest way to revive your old computer. How it works
Reboot the system, and you should find it to be a bit zippier.











