Changing the SWAP file Swapiness on Ubuntu 14.04

I have been asked several times about reducing the “swapiness” on a Linux machine to make the machine more responsive. So here is a post on how to do that. Remember just because you can does not make it a good thing to do.

If the machine has 8GB or more RAM turn down the swapiness. That is, if you do not want the system using swap until only 10-15% of RAM is left unused. Then this is the post for you.

To see the current swapiness value, which is probably 60 as that is the Ubuntu default.

cat /proc/sys/vm/swappiness

To set a new value that is remembered over a reboot edit sysctl.conf

sudo nano /etc/sysctl.conf

Add or amend the line the following line

vm.swappiness = 10

and to change the value once the machine is running with out rebooting. This does not survive a reboot.

sudo sysctl vm.swappiness=10
Personally I just leave this alone, if your machine is constantly swapping to 
disk give it some more RAM. if that is not possible run less apps concurrently.

Leave a Reply

Your email address will not be published. Required fields are marked *