Follow ZDNET: Add us as a favorite source On Google.
ZDNET Highlights
- With the price of RAM skyrocketing, try this to speed up Linux.
- This configuration is easy.
- Some distributions include ZRAM by default.
Last time I checked the price of memory (RAM) I was shocked. according to Tom’s HardwareThe price of RAM on Amazon has increased by 240%. Very good.
There are two primary reasons for the surge in RAM prices:
- Supply chain disruptions and geopolitical instability
- Explosive demand from AI and data centers
As AI continues to grow in popularity, the price of RAM will likely continue to rise (or remain stable at higher prices).
If adding RAM to your Linux system prevents you from upgrading due to uncontrolled price increases, what can you do?
Luckily, there is a software solution you can use to get more speed out of your Linux computer.
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 it 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 usually uses traditional swap space, which is slower than RAM-based space. Because ZRAM keeps the swapped data in memory, it is much faster than standard swap-systems.
Installing ZRAM
what you’ll need: The only thing you need for this is a running instance of Linux and a user with sudo preferences. Keep in mind that ZRAM is usually enabled by default on Fedora and Fedora-based distributions. I’ve also found that some Debian-based distributions (like Pop!_OS) come preinstalled with ZRAM as well.
Also: The best Linux laptops you can buy: Expert-tested
I will demonstrate how to do this on a Debian-based distribution.
sudo apt-get install zram-tools -y
ZRAM is now installed and ready to be configured.
configuring zram
Once ZRAM is installed, it’s time to configure it. This way.
1. Open the ZRAM config file
Open the ZRAM config file for editing with the command:
sudo nano /etc/default/zramswap
2. Optimize ZRAM
In that file, you’ll want to customize the following lines:
Algo=
Percentage=
Priority=
You can also replace SIZE= with PERCENTAGE=, but it is often easier to use the percentage option.
As far as ALGO options are concerned, you have two options:
- lz4 – used for pure speed
- zstd – used for better compression
Also: This Linux distro that I recommend to power users takes a unique approach to OS design
I’d go with lz4 with a priority of 100 (default) and 20% of my total RAM. Here’s what those configuration lines will look like:
ALGO=lz4
percentage=20
priority=100
Save and close the file.
3. Restarting ZRAM
After the configuration is taken care of, you need to restart the ZRAM system with the command:
sudo systemctl zram
ZRAM is now respecting your new defaults.
a warning
You may find that your system is configured with “swampness” that is too aggressive. Aggressive swappiness means that it will swap memory pages from the RAM swap space more frequently, which can increase 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 – This ensures that ZRAM is used more actively but without over-prioritization.
- vm.vfs_cache_pressure – This configures how much the kernel can reclaim the inode and data caches.
- vm.dirty_background_ratio — The ratio of unsaved data to disk, which can suddenly stop 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 may want to set these values like this:
vm.dirty_background_ratio=5
vm.dirty_ratio=10
vm.swapness=50
vm.vfs_cache_pressure=50
Save and close the file. Apply those changes with the command:
sudo sysctl –system
Note: If you do not find the 99-zram-tweaks file on your system, create it and add the above values. To create and edit a file, issue the command:
sudo nano /etc/sysctl.d/99-zram-tweaks.conf
The ZRAM should now be in place and configured. You should start to notice slightly higher speeds, especially if you have multiple apps open on your desktop.
Turn off your default swap space
You may also want to disable your default swap space (so there is no conflict between it and ZRAM). To do this, open your fstab file with:
sudo nano /etc/fstab
In that file, look for the line that starts with:
swap file
Place the # character at the beginning of the line and save/close the file.
Disable running swap space with:
sudo swapoff -a
Plus: This free Linux distro is the easiest way to revive your old computer. how it works
Reboot the system, and you’ll find it a little zippier.
