If you want to give the zswap kernel extension a try you can enable it just for the current boot with the following
echo 1 > /sys/module/zswap/parameters/enabled
If you want to make the change permanent, it’s simple to do it adding a kernel boot parameter on the grub bootloader
Open the file ‘/etc/default/grub’ and look for a line similar to:
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
And add ‘zswap.enabled=1’ to the end of it, so it looks something like this:
GRUB_CMDLINE_LINUX_DEFAULT="quiet zswap.enabled=1"
Save the file, update the bootloader with ‘upgrade-grub’ and reboot.
After rebooting you can test if the installation was successful running the following as root:
grep -R . /sys/module/zswap/parameters
Example output:
/sys/module/zswap/parameters/same_filled_pages_enabled:Y
/sys/module/zswap/parameters/enabled:Y
/sys/module/zswap/parameters/max_pool_percent:20
/sys/module/zswap/parameters/compressor:lzo
/sys/module/zswap/parameters/zpool:zbud
You’re golden if you see the line:
/sys/module/zswap/parameters/enabled:Y
if it’s enabled successfully.
To look at the stats, and see if it’s making a difference on your RAM usage or not, you should run as root:
grep . /sys/kernel/debug/zswap/*
Example output:
/sys/kernel/debug/zswap/duplicate_entry:0
/sys/kernel/debug/zswap/pool_limit_hit:0
/sys/kernel/debug/zswap/pool_total_size:0
/sys/kernel/debug/zswap/reject_alloc_fail:0
/sys/kernel/debug/zswap/reject_compress_poor:0
/sys/kernel/debug/zswap/reject_kmemcache_fail:0
/sys/kernel/debug/zswap/reject_reclaim_fail:0
/sys/kernel/debug/zswap/same_filled_pages:0
/sys/kernel/debug/zswap/stored_pages:0
/sys/kernel/debug/zswap/written_back_pages:0
Sources:
https://www.kernel.org/doc/Documentation/vm/zswap.txt
https://wiki.archlinux.org/index.php/Zswap
https://lkml.org/lkml/2013/7/17/147