Swappiness in Ubuntu

From a few years, Ubuntu has developed an annoying behavior about the way it uses swap.

Even though you have enough memory to hold all your applications, the SO tends to use swap slowing the whole machine down.

Recently I've discovered a parameter to control the behavior of the operating system in swap.

The parameter is called 'swappiness' and you can check your current value this way:

cat /proc/sys/vm/swappiness

It's a number on a scale of 0-100. The default Ubuntu value is 60 which is unnecessarily high. It's even worst for SSD drives because it tends to write on the drive much frequently reducing its lifespan.

To reduce the swappiness to a more sensible value, you have to edit "/etc/sysctl.conf" as root and add the following line:

vm.swappiness=1

You'll have to reboot for the changes to take effect.

This way you'll reduce to the minimum the use of swap and your system will be faster and more responsive.

Depending on your particular machine, maybe you'll have to try different values to achieve the optimum configuration.

And as always, your mileage may vary.

Add new comment

(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.