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.
| Classification | ZRAM (Compressed RAM Block Device) | tmpfs (Temporary Filesystem) |
|---|---|---|
| Core Concept | Compressed block device created within RAM | Virtual filesystem based on RAM |
| Data Format | Compresses and stores data (approx. 1/3 size) | Stores original data as-is |
| Primary Use Case | Expanding swap space, reducing disk I/O | Storing fast temporary files like /tmp, /run |
| Advantages | Can hold more data than physical RAM capacity | Fastest 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-toolssh
Check supported Compression Algorithms
ZRAM supports multiple compression algorithms.
To check the list of available algorithms on your system, check the
To check the list of available algorithms on your system, check the
comp_algorithm in sysfs.Check supported Compression Algorithmssh
Modify Configuration
You can adjust the size and priority of ZRAM by editing the configuration file /etc/default/zramswap.
Modify Configurationsh
Key configuration items
/etc/default/zramswapconfig
Apply Configuration
After completing the settings, restart the service to apply them immediately.
Restart servicesh
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).zramctlsh
As you can see, it has been successfully applied to the Swap memory.
Check Swap Memorysh