How to: Change Swappiness or Adjust Swap File Use in Ubuntu 12.10
A few weeks ago, I made the switch to Ubuntu, and I’m enjoying it tremendously (Currently Ubuntu 12.10). Some drawbacks though have been performance related, it locks up a lot and I have to reboot using ubuntu ctrl + alt + printscreen, REISUB –which is apparently a safer way to reboot and a good way to stretch out your fingers.
One things I read up about regarding PC performance is that the swap file use in Ubuntu is setup for servers, not for home use out of the box. This tweakable setting provided by the Linux Kernal is call swappiness.
With swappiness at zero it will not use the hard disk at all for memory swaping unless emergency situations (e.g. you run out of memory), a swappiness of 100 means that programs will be swapped immediately.
The default setting on Ubuntu is a swappiness of 60, you can find your swappiness by typing in the terminal:
When I initally did this I got “60” returned to me. This means that the swap file will be used often if memory usage is about half of my Ram.
The first article I found this on said that the way to change this is to open a terminal and run:
sudo gedit /etc/sysctl.conf
Then modify the swappiness setting, except for one problem, my file didn’t have that particular setting for one reason or another… So I had to look for a different method, and luckily there is one, which is even easier.
sudo sysctl vm.swappiness=10
Then when I re-check my swappiness level, it shows 10, and I know I’m good to go!