Swap-iness on linux

15 May 2020

‘Swapiness’ on linux can be reduced or increased with sysctl — a higher value will make the system swap out memory more aggressively; 0 will disable swap altogether. On a system with plenty of memory for its workload, many people seem to go with a low-ish value like 10.

sudo sysctl vm.swappiness=10

To check you can run:

cat /proc/sys/vm/swappiness

To make persistent:

sudo sh -c 'echo vm.swappiness = 10 >> /etc/sysctl.conf'

An amusingly-named place to find out a bit more about linux RAM use for those who are not well versed is at linuxatemyram.com

It’s worth a visit for the brilliant graphic alone: