System Ubuntu 14.04

I want to change my swappiness from the default 60 to 10. According to this answer https://askubuntu.com/a/103916/71679 I need to log in as root and edit /proc/sys/vm/swappiness and add or edit to vm.swappiness = 10

When opening that file as root I only see the number 60 when I add vm.swappiness = 10and try to save I get Error writing /proc/sys/vm/swappiness: Invalid argument

If I simply change 60 to 10 the file saves without issue I check the changes take place with cat /proc/sys/vm/swappiness it shows the changes took place

By editing this file as root I was under the assumption the changes would remain permanent but once I shut down and restart the default is back to 60. Why aren't the changes remaining permanent? What writes the file back to 60 after reboot?


1 Answer 1


If you want to set the swapiness without rebooting you could execute the following command:

echo 10 > /proc/sys/vm/swappiness

This will set the swapiness to 10 in this case. You can only echo a number because all this will do is call a kernel function to set the swapiness to 10 and this function only accepts numbers (this explains why you get a invalid argument error: you're trying to write other characters than numbers).

However, this is only temporary. The value will be reset at the next reboot to the default value.

To make the change permanent:

  1. Edit /etc/sysctl.conf as root

    sudo nano /etc/sysctl.conf
  2. Add the following line to the file:

    vm.swappiness = 10
  3. Save the file using CTRL + X

The changes made to sysctl.conf will apply on reboot or you can reload them using sudo sysctl -p (so sudo sysctl -p will have the same effect as echo 10 > /proc/sys/vm/swappiness in this case).

  • Fastest response time ever :) i will try it out and report back.......thanks!
    – damien
    May 9, 2014 at 9:29
  • 2
    and to check it cat /proc/sys/vm/swappiness
    – azerafati
    May 17, 2016 at 13:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .