How to improve Ubuntu performance thanks to ZSwap

Tux mascot

For several months now, a tool called Z-Swap. This tool helps us optimize the operation of the operating system by better managing memory and making the paging memory be stored in the ram memory and not in another device.

This kernel tool is useful, especially if we have a computer with few resources, with a slow processor or with a slow hard disk, which causes the operation of the operating system to slow down more than normal.

Before activating and using ZSwap, we must make sure that we do not have it activated. In old versions of Ubuntu, in derived distributions or in LTS versions we may not have this function activated. I currently use Ubuntu 17.10 and this version already has it activated by default. But the best is check for ourselves that it is activated, thus, we only have to write the following in the terminal:

cat /boot/config-`uname -r` | grep -i zswap

If this appears to us CONFIG_ZSWAP = y, it will mean that it is activated, if it appears the same but ends in «n», it will mean that we do not have it activated. If we do not have it activated we have to edit the grub file. To do this we open gedit with root permission:

gksu gedit /etc/default/grub

And we replace the line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

By

GRUB_CMDLINE_LINUX_DEFAULT = "splash silencioso zswap.enabled = 1 zswap.compressor = lz4"

We save, close the file and update the grub:

sudo update-grub

Now we have to activate another tool that uses ZSwap, the Lz4 compressor. To do this, from the same terminal, we write the following:

sudo su
echo lz4 >> / etc / initramfs-tools / modules
echo lz4_compress >> / etc / initramfs-tools / modules
update-initramfs -u

We restart the pc and now we can check again if we have ZSwap activated, using the first command that we use in the terminal and showing the message first. As well we will notice an increase in the performance of our team, being faster in certain tasks such as opening Gimp.