We have all been there. You have 20 Chrome tabs open, you launch a virtual machine or a heavy compilation task, and suddenly—your system freezes. The mouse cursor stutters, the music loops, and your hard drive LED goes crazy.
Your computer just ran out of RAM and started panicking.
In the old days, the solution was a “Swap Partition” on your hard drive. But even with modern NVMe SSDs, disk swap is thousands of times slower than RAM.
But what if I told you that you could “download more RAM”? Well, technically, you can compress the RAM you already have. This is called ZRAM, and it is one of the first optimizations I apply on every single computer I own.
Whether it’s my powerful Desktop PC with 64GB of RAM or my aging MacBook Air 2017 (8GB), ZRAM is the secret to keeping them fast and responsive.
What is ZRAM?
Imagine your RAM is a suitcase. When it gets full, a standard operating system starts throwing clothes (data) out onto the floor (your hard disk). That is slow.
ZRAM is like a vacuum bag for that suitcase. Instead of throwing data out, it takes the data, compresses it using smart algorithms, and keeps it in RAM.
Without ZRAM: 8GB RAM = 8GB capacity.
With ZRAM: 8GB RAM can behave like 12GB or even 16GB of effective capacity.
Why I Use It (The “Zstd” Secret)
On my ThinkPad P14s, I often run multiple virtual machines. Without ZRAM, 32GB fills up fast. With ZRAM, I can push the system much harder before it slows down.
The key is the compression algorithm. Most defaults use lzo, which is fast but okay-ish at compression. I personally prefer zstd (Zstandard). It was developed by Facebook/Meta and offers an incredible balance: it compresses data tightly (saving more RAM) while being extremely fast on modern CPUs like the Intel Ultra series.
Here is how to set it up properly.
Step 1: Check Your Current Status
First, let’s see if you are already using ZRAM. Open your terminal and type:
zramctl
If you see a list (NAME, ALGORITHM, SIZE…): Congratulations, ZRAM is active! Check the
ALGORITHMcolumn. Is itzstd? If not, read on.If you get no output: ZRAM is not active. Let’s fix that.
Case A: Optimizing Fedora (It’s Default, but let’s make it better)
Fedora has been amazing by enabling ZRAM by default for years. However, we can tweak it to be even more efficient using zstd.
Install the generator defaults (usually already there):
Bashsudo dnf install zram-generator-defaultsNow, let’s configure it. We need to create a configuration file.
Bashsudo nano /etc/systemd/zram-generator.confPaste the following configuration. This tells Fedora to use the superior
zstdcompression and allows ZRAM to use up to half your total RAM if needed.Ini, TOML[zram0] zram-size = min(ram / 2, 8192) compression-algorithm = zstd(Note: On my 64GB desktop, I sometimes increase the size limit, but for most users, 8GB of compressed swap is plenty).
Save (
CTRL+O) and Exit (CTRL+X). Now, we need to tell systemd to reload its configuration and restart the ZRAM service:Bashsudo systemctl daemon-reload && sudo systemctl restart systemd-zram-setup@zram0Verify with
zramctl. You should now seezstdunder the algorithm column!
Case B: Enabling on Ubuntu, Debian, or Linux Mint
Unlike Fedora, Debian-based systems often stick to old-school swap files by default. Let’s bring them into 2025.
First, disable any existing ZRAM config to avoid conflicts, then install the tools:
Bashsudo apt update sudo apt install zram-toolsOpen the configuration file:
Bashsudo nano /etc/default/zramswapFind and uncomment/edit these lines to look like this:
BashALGO=zstd PERCENTAGE=50 PRIORITY=100ALGO=zstd: Forces the modern compression.
PERCENTAGE=50: Allocates 50% of your RAM as swap space (don’t worry, it only uses what it needs).
PRIORITY=100: Ensures Linux uses fast ZRAM before touching your slow disk swap.
Save (
CTRL+O) and Exit (CTRL+X). Now restart the service to apply changes:Bashsudo systemctl restart zramswapCheck with
zramctl. Boom! You just upgraded your RAM for free.
Why Not Just Buy More RAM?
On a desktop, sure, buying more RAM is great. But on soldered laptops (like many modern ultrabooks or my MacBook Air), you simply can’t.
But even on my High-End Desktop, I use ZRAM. Why?
To save my SSD.
Every time your computer swaps to disk, it writes gigabytes of data to your expensive NVMe drive, wearing it out. ZRAM keeps that data in memory, reducing wear and tear on your drive. It’s a win-win.
ZRAM is one of those “set it and forget it” optimizations that significantly improves your quality of life. It makes an old laptop feel snappy and a new workstation feel invincible.
Go ahead, check your zramctl output right now. If it doesn’t say zstd, you know what to do!
Do you use ZRAM or do you still rely on a Swap Partition? Let me know in the comments!
Disclaimer: While these commands are safe, mistakes in system configuration files can affect system stability. Always double-check your typing. Use at your own risk.

