Close Menu
Linux All DayLinux All Day
    Facebook Bluesky Mastodon X (Twitter)
    Linux All DayLinux All Day
    • News
    • Operating Systems
      • Linux Distributions
      • Android-based OS
      • ChromeOS Alternatives
    • Software
      • Apps & Tools
      • Desktop Environments
      • Installation & Management
    • Tutorials
      • Linux Basic & Tips
      • System Optimization
      • Security & Privacy
    • Linux Gaming
      • Game News & Reviews
      • Emulators & Retro
      • Performance & Benchmarks
    • Comparisons
    Mastodon Bluesky Facebook
    Linux All DayLinux All Day
    Home - Tutorials - System Optimization - Stop Wasting RAM: How to Use ZRAM on Linux

    Stop Wasting RAM: How to Use ZRAM on Linux

    Is your PC slowing down? Learn how to double your memory efficiency and save your SSD life using the zstd compression algorithm.
    By Mitja System Optimization November 19, 20255 Mins Read
    Share Facebook Bluesky Twitter Threads Reddit LinkedIn Telegram Tumblr Email Copy Link Pinterest
    Follow Us
    Facebook Mastodon Bluesky X (Twitter)
    Terminal output showing zramctl status with zstd compression on Fedora Linux.
    Share
    Facebook Twitter Bluesky Reddit Threads Tumblr Email Copy Link

    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:

    Bash

    zramctl
    
    • If you see a list (NAME, ALGORITHM, SIZE…): Congratulations, ZRAM is active! Check the ALGORITHM column. Is it zstd? 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.

    1. Install the generator defaults (usually already there):

      Bash

      sudo dnf install zram-generator-defaults
      
    2. Now, let’s configure it. We need to create a configuration file.

      Bash

      sudo nano /etc/systemd/zram-generator.conf
      
    3. Paste the following configuration. This tells Fedora to use the superior zstd compression 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).

    4. Save (CTRL+O) and Exit (CTRL+X). Now, we need to tell systemd to reload its configuration and restart the ZRAM service:

      Bash

      sudo systemctl daemon-reload && sudo systemctl restart systemd-zram-setup@zram0
      
    5. Verify with zramctl. You should now see zstd under 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.

    1. First, disable any existing ZRAM config to avoid conflicts, then install the tools:

      Bash

      sudo apt update
      sudo apt install zram-tools
      
    2. Open the configuration file:

      Bash

      sudo nano /etc/default/zramswap
      
    3. Find and uncomment/edit these lines to look like this:

      Bash

      ALGO=zstd
      PERCENTAGE=50
      PRIORITY=100
      
      • ALGO=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.

    4. Save (CTRL+O) and Exit (CTRL+X). Now restart the service to apply changes:

      Bash

      sudo systemctl restart zramswap
      
    5. Check 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.

    Follow on Mastodon Follow on Bluesky
    Share. Facebook Twitter Bluesky Reddit Threads Telegram Email Copy Link

    Related post

    TLP vs Power-Profiles-Daemon: The Ultimate Linux Battery Guide (2026 Edition)

    November 29, 2025

    ZRAM Linux Guide: Why I Stopped Using Swap Partitions (2025)

    November 21, 2025

    A Beginner’s Guide to Nginx Proxy Manager on Linux

    November 13, 2025
    Leave A Reply Cancel Reply

    → Switch to Linux Today
    • Facebook
    • Twitter
    • Mastodon
    • Bluesky
    More From Linuxallday
    Beyond the Grid: Mastering the Zen Flow of Bryce Tiles
    Mozilla Confirms Full “AI Kill Switch” for Firefox, Arriving in Early 2026
    Rescuezilla Review 2025: The ‘Undo Button’ for Your Entire PC
    Tails OS Review 2025: The Ultimate Amnesic System for Total Privacy
    Facebook X (Twitter) Mastodon Bluesky Threads RSS
    • About Us
    • Cookie Policy
    • Terms & Conditions
    • Privacy Policy
    • Disclosure & Disclaimer
    • Contact
    • Our Authors
    • Cookie Policy (EU)
    © 2026 Designed by FeedCrux

    Type above and press Enter to search. Press Esc to cancel.

    Manage Consent
    To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
    Functional Always active
    The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
    Preferences
    The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
    Statistics
    The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
    Marketing
    The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
    • Manage options
    • Manage services
    • Manage {vendor_count} vendors
    • Read more about these purposes
    View preferences
    • {title}
    • {title}
    • {title}