How to Configure ZRAM on Linux

February 10, 2026

How to Configure ZRAM on Linux

Using ZRAM (Compressed RAM Block Device) allows you to use a portion of your physical RAM as compressed Swap memory, effectively increasing available memory even in limited memory environments.

ZRAM vs. tmpfs: Key Differences

Both are based on RAM, but there are significant differences in their purpose and operation.
ClassificationZRAM (Compressed RAM Block Device)tmpfs (Temporary Filesystem)
Core ConceptCompressed block device created within RAMVirtual filesystem based on RAM
Data FormatCompresses and stores data (approx. 1/3 size)Stores original data as-is
Primary Use CaseExpanding swap space, reducing disk I/OStoring fast temporary files like /tmp, /run
AdvantagesCan hold more data than physical RAM capacityFastest file read/write speed (lowest latency)

Key Advantages of ZRAM

  • Memory expansion effect: Compression allows for storing 2-3 times more data than the physical RAM capacity.
  • Storage life extension: Protects hardware life by avoiding swap writes to SSD or eMMC.
  • Performance improvement: Provides much faster response times than slow disk swapping.

How to Install

You can install zram-tools, a tool for managing ZRAM.
Install zram-tools
sh

Check supported Compression Algorithms

ZRAM supports multiple compression algorithms.
To check the list of available algorithms on your system, check the comp_algorithm in sysfs.
Check supported Compression Algorithms
sh

Modify Configuration

You can adjust the size and priority of ZRAM by editing the configuration file /etc/default/zramswap.
Modify Configuration
sh
Key configuration items
/etc/default/zramswap
config

Apply Configuration

After completing the settings, restart the service to apply them immediately.
Restart service
sh

Check Zram Status

Using zramctl, you can see at a glance how much ZRAM is currently compressed (COMPR) and how much physical RAM it is occupying (DATA).
zramctl
sh
As you can see, it has been successfully applied to the Swap memory.
Check Swap Memory
sh
Jooojub
System S/W engineer
Explore Tags
Series
    Recent Post
    © 2026. jooojub. All right reserved.