I am trying to configure the zswap module so that compression of the swap area would be enabled from the very beginning of the system boot. To do this, in the /etc/default/grub file, set the kernel boot options:

 GRUB_CMDLINE_LINUX="zswap.enabled=1 zswap.zpool=zsmalloc zswap.compressor=lz4" 

And everything would be fine if the lz4 compression would turn on itself at boot time (or right after, the main thing is not to manually). However, the default is lzo.

The contents of the files in the /sys/modules/zswap/parameters follows:

 /sys/module/zswap/parameters/compressor:lzo /sys/module/zswap/parameters/enabled:Y /sys/module/zswap/parameters/max_pool_percent:20 /sys/module/zswap/parameters/zpool:zsmalloc 

And here is the output of dmesg related to zswap :

 [ 1.140971] zswap: compressor lz4 not available, using default lzo [ 1.141064] zswap: loaded using pool lzo/zsmalloc 

Moreover, if you manually set a compression method after entering, it is installed without problems - the file contents change, dmesg reports success, and this command completes without errors:

 echo lz4 | sudo tee /sys/module/zswap/parameters/compressor 

But it is annoying for me to enter such a command every time the computer is turned on. How to make this kernel module automatically use lz4 compression, without additional kicks manually?

System: Ubuntu 16.04

    1 answer 1

    Such an error in the first few seconds of the system operation is caused by the absence at this moment of the module responsible for compression by the lz4 method. In Ubuntu, the default kernel module of the same name is not included on the initial boot disk. So you have to add it yourself. Like this:

     echo lz4 | sudo tee -a /etc/initramfs-tools/modules 

    And then do not forget to regenerate this disk:

     sudo update-initramfs -u