Ubuntu – How to permanently change swappiness


I am trying to permanently change my swappiness level,i’ve seen an answer posted in a few places and everyone being greateful, saying it works. But it isn’t for me…

This is the question/answer i looked at:

Why dont changes to the swappiness remain permanent after reboot?

But after entering:
sudo nano /etc/sysctl.conf

i get a list come up saying various things all with a hashtags in front of each line….

Where exactly do i add vm.swappiness=10??
do i add a hashtag in front of it too like everything else in the file?
I added it to the very top of the file and saved, rebooted, hasnt changed anything.
I also added it to the bottom and saved, rebooted…..still hasn’t changed. my swappiness is still 60.

Could someone please be a bit more specific with this please? I'm far from an expert when it comes to linux


Best Answer

Add that at the bottom without the # before it then run:

sudo sysctl -p

Sample from my sysctl.conf file:

# Log Martian Packets
#net.ipv4.conf.all.log_martians = 1
fs.inotify.max_user_watches = 524288
fs.file-max = 2097152