0

I have an Ubuntu 15.04 64bit with 4GB RAM. I do not have a separate swap partition, but a swapfile of 8GB. The system recognizes the swap.

I have tried to set swappiness to 15 by adding it to the last line of /etc/sysctl.conf. The last 3 lines of $cat /etc/sysctl.conf are

# ADDED ON 9JAN16 for swap trial
vm.swappiness=15
#

However, when my system starts up, the swappiness value is 1

$ cat /proc/sys/vm/swappiness
1

Manually setting vm.swappiness changes the value

$ sudo sysctl vm.swappiness=15
vm.swappiness = 15
$ cat /proc/sys/vm/swappiness
15

Swappiness becomes 1 again when I boot up the system next time.

NOTE - I had previously tried to setup hibernation using Debian's tutorial to hibernate without a swap partition and failed. I have removed uswusp that I had installed for that process. Perhaps there is something in there that is overriding sysctl.conf, but I am not smart enough to figure it out.

How do I set default value of swappiness to 15?

  • Is there more than one occurrence of vm.swappiness in your /etc/sysctl.conf file? – Jeffrey Lam Jan 11 '16 at 23:07
  • @JeffreyLam - there is just one occurence of vm.swappiness – 3l4ng Jan 12 '16 at 8:04
  • 1
    I found something in your Debian tutorial. Create a file called local.conf in /etc/sysctl.d and add the kernel variable there so it sticks: vm.swappiness=1. Is this /etc/sysctl.d/local.conf file still there? Does it still say vm.swappiness=1 inside it? – Jeffrey Lam Jan 18 '16 at 12:11
  • 1
    argh! I thought we had it. Can you post these into your question: your /etc/sysctl.conf file and the contents of your /etc/sysctl.d/ directory? (The commands cat /etc/sysctl.conf and ls -l /etc/sysctl.d/ will get these) There might be something in one of the files inside the sysctl.d directory that sets the swappiness. – Jeffrey Lam Jan 18 '16 at 18:29
  • 1
    Actually. it turns out that there was some .conf file in etc/sysctl.d/ that had a line to set swappiness. Deleted that and swappiness is now set via /etc/sysctl.conf. Thanks for all the help – 3l4ng Jan 20 '16 at 9:14
0

It turned out that there was a .conf in /etc/sysctl.d/ that had the line setting vm.swappiness = 1

Deleting that allows swappiness to be set from /etc/sysctl.conf file.

I guess the takeaway from this issue is that a .conf file in /etc/sysctl.d/ can override an entry in /etc/sysctl.conf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.