Ubuntu – How to permanently enable compressed ram swap? What version to use

11.0412.04ramswapzram

EDIT: In precise there's now zram-config. It's an upstart job compressing up to half of your ram spread over $(number of CPU cores) swap devices. It didn't allways start at boot but issuing sudo service zram-config start works.

I enabled compcache="256 M" in /etc/initramfs-tools/initramfs.conf as described here (by me :P). This – I believe – creates /dev/ramzswap0 but it is never enabled as swap. It works only after mkswap && swapon.

Then there is the module zram that creates /dev/zram. Is it something else? It works the same way but /dev/ramzswap is created from the module ramzswap.

At the end of the day I wanna have a compressed swap in ram and use the better of the two and for that I need to know how to enable it permanently in a non hackish way. How is this done?

I wrote about ramzswap in Lucid here but things have changed in Natty.
You can still enable ramzswap in initramfs.conf but it doesn't get activated.

P.S.:I scanned all udev rules in /lib and/etc but found nothing of interest.

Best Answer

There's now a PPA that installs a proper Upstart script for enabling zram at boot-time. It chooses the correct size and number of compressed swap devices for your system.

https://launchpad.net/~shnatsel/+archive/zram

Related Question