Ubuntu – Swappiness setting are ignored in sysctl.conf


swappiness is set to 0 and I can't change it.

I have tried changing the swappiness setting in /etc/sysctl.conf and /etc/sysfs.conf – both are ignored after reboot (Ubuntu 12.04):

$ sudo gedit /etc/sysctl.conf

$ sudo gedit /etc/sysfs.conf


$ sudo cat /proc/sys/vm/swappiness

$ rgrep swappiness /etc/sysctl.*
/etc/sysctl.conf:# swappiness
/etc/sysctl.conf~:# swappiness
/etc/sysctl.conf~:vm.swappiness = 60
/etc/sysctl.d/60-my-swappiness.conf:vm.swappiness = 60

$ sudo sysctl -p
vm.swappiness = 60

$ sudo cat /proc/sys/vm/swappiness

After reboot, swappiness is again set to zero:

$ sudo cat /proc/sys/vm/swappiness

Why are my settings in /etc/sysctl.conf are not loading after reboot?

Is there something wrong with procps?

What should I check?

I looked for answer in askubuntu and on other sites, but I have not found the answer.

I saw this, but there is no answer:
Swappiness setting ignored in systcl.conf

How can I resolve this issue?

Best Answer

please verify first by using the following:

 cat /proc/sys/vm/swappiness

This output gives you the right swappiness at the moment. (it could be 0 it could be 60)

If you want to change this do the following:

 gksudo leafpad /etc/sysctl.conf

I use leafpad as an editor but you can change this with gedit (what has a bug in it) scroll at the bottom of this file and add # altering swappiness

vm.swappiness= (give here the digit you want e.g. 60 or 10 (bold is for pointing out)

save this altered file and reboot completely

verify your swappiness again by using the command I gave above (cat ....)

I use for 1Gb RAM or more the value 10; for less than 1Gb RAM the value 5 (personal experience) . Only for a server or something like that the value 60 is required.

Good luck !