1

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
vm.swappiness=60


$ sudo gedit /etc/sysfs.conf
vm.swappiness=60

/etc/sysctl.d/60-my-swappiness.conf
vm.swappiness=60


$ sudo cat /proc/sys/vm/swappiness
0

$ rgrep swappiness /etc/sysctl.*
/etc/sysctl.conf:# swappiness
/etc/sysctl.conf:vm.swappiness=60
/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
60

After reboot, swappiness is again set to zero:

$ sudo cat /proc/sys/vm/swappiness
0

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?

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
Bartek
  • 183
  • The default value of swappiness in Ubuntu is 60. Can you add the output of lsb_release -a to the question. Can you also add an explanation of how you got to the point of swappiness becoming 0. – mikewhatever Mar 19 '13 at 12:53
  • @mikewhatever

    Yes I know it's 60, this is why I wanted to change it from 0 to default 60.

    ' $ lsb_release -a'

    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 12.04.2 LTS
    Release: 12.04
    Codename: precise'
    
    – Bartek Mar 19 '13 at 12:56

3 Answers3

0

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 !

  • Did you read my question? I did it before and setting in sysctl.conf are ignored after reboot. Something is wrong about it. – Bartek Mar 19 '13 at 13:06
  • check that file again on possible double entry's vm.swappiness. Remove all those entry's and configure that file again. Altering swappiness was never an issue, and as a support point I've done that more than 30 times. For altering this file I strongly advise to use Leafpad and not Gedit (what has a bug you can confirm that on Launchpad) – Joris Donders Mar 20 '13 at 09:04
0

I was having the same issue so I added

sysctl -p

to my /etc/rc.local file and now my swappiness value matches the value in /etc/sysctl.conf after reboot. This probably reflects on something not being configured quite properly in a default install, but this is the easy fix.

Joe
  • 376
0

syntax error

If I'm not mistaken, you have

vm.swappiness=60

when you should have the line

vm.swappiness = 60

in /etc/sysctl.conf in order to make the setting persistent

mchid
  • 43,546
  • 8
  • 97
  • 150