I'm using 12.04 LTS and can sudo sysctl to set swappiness to 10, but adding vm.swappiness=10 to sysctl.conf doesn't work for me – after I reboot, swappiness still reports 60 (default)
I'd like to be able to reduce swaps to my SSD, but can't find a way to do so except manually per session. Modifying sysctl.conf seems to work for most – can anyone advise what I need to check / change to make it work for me too, please?
Best Answer
What I usually do is create a custom rule in
/etc/sysctl.d/
instead of editing the mainsysctl
file. Change directory tosysctl.d
and create your file:Then run your favourite text editor:
Enter your value at the top of the file, for example,
vm.swappiness = 10
(there must be spaces between swappiness and the value as shown).As it recommends in the readme in
/etc/sysctl.d/
, runfor the system to read the new values and then reboot.
The reason why we use
60
at the start of themy-swappiness.conf
is so that your custom rule overrides any other rules in the directory.Check that you have the correct swappiness with
This works for me, but there is more guidance on swap and swappiness in the Ubuntu guide if you need any more detailed information.