Add RAM to Ubuntu 12.04+ for free: zRAM

More RAM for free? By installing a software?! Enter zRAM.

In the mainline generic kernel of Ubuntu, there's a module called zram. This is a pretty good trick to add additional "free" RAM to your machine without any change: it creates in-memory compressed block for swap, meaning it eats a bit of your CPU but gives you literally more RAM.

If you're on a VPS for example, having 512 MB RAM, this would actually give you access to 750 MB RAM and would eat just a little CPU from you - I don't even notice it on the Munin graphs.

To install:

apt-get install zram-config

Make sure it's started and running:

cat /proc/swaps

If you see something like this

# cat /proc/swaps
Filename     Type       Size    Used    Priority
/dev/zram0   partition  62712   6804    5
/dev/zram1   partition  62712   6768    5
/dev/zram2   partition  62712   6744    5
/dev/zram3   partition  62712   6768    5

then it's already running.

Reboot your machine, and voilá.

More to read:

  • Increased performance in linux with zRAM1
  • Ubuntu Linux Considers Greater Usage Of zRAM2