DevOps DigitalGeek Linux Others Performance

Ubuntu RAM compression

Current Debian distributions does not have memory compression settings enabled by default.

This causes a lot of RAM usage and makes difficult to run many apps for web development.

A successor to compcache is zram which is fully integrated in the Linux kernel since 2.6.37.1 and uses lzo compression. The idea behind it is to create swap devices made of chunks of the ram and to compress those chunks on the fly to increase the available space used and ideally reduce the need of swapping to slow disks.

It uses a small extra amount of the CPU, however, the reduced i/o usage should more than make up for this. This is primarily interesting for a small scaled VPS, Netbooks or low memory devices. Also virtualisation hosts should benefit of compressed memory.

Unfortunatly the zram-config script is currently not part of the Debian and Centos distributions.

In Ubuntu, from 12.04 onwards, the install script is included and it takes only a minute to setup zram.

# sudo apt-get install zram-config

Then restart your computer.

To check if it works:

# cat /proc/swaps

Output:
Filename Type Size Used Priority
/dev/zram0 partition 482900 0 5
/dev/zram1 partition 482900 0 5
/dev/zram2 partition 482900 0 5
/dev/zram3 partition 482900 0 5

Then your linux system will compress memory on the fly.

Stan

Stan is an experienced full-stack developer and software engineer who is focused on web and game development. He is enthusiastic about new technologies. Stan is highly skilled in many programming languages and frameworks, and he always tries to deliver the best approach.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *