How to speed up Ubuntu 11.04 – Swappiness

Or pretty much any Ubuntu version really. This is aimed at desktop installations, not servers.

Ubuntu has a fancy little property called swappiness. Swappiness basically tells Ubuntu how often to move processes out of memory and onto the hard drive. Things that are in memory are faster. Just like remembering something is faster than wondering off to google and looking it up. So in general, on your average Ubuntu desktop, you want to tell the operating system to keep processes in memory for longer. Enter swappinesss.

To find out your swappiness open up a terminal and try this:

cat /proc/sys/vm/swappiness

It will probably report back “60”. Now, for desktops, the recomended value of swappiness is 10. So let’s change the swappiness factor – open up /etc/sysctl.conf in your favourite text editor (you get extra imaginary points if you use vim instead of gedit). Again, at the terminal type:

sudo gedit /etc/sysctl.conf

Search for (or add if it isn’t there) “vm.swappiness” and change it to:

vm.swappiness=10

Save, reboot and hey presto off you go. For the curious, read more about swap than you could ever want to know.

I have no idea why Ubuntu doesn’t set this by default on desktop installs really, it’s one of the things that is standing in the way of it really taking off for the average computer user. Not swappiness per se, but just the fact that you have to get your hands a little dirty when you run Ubuntu, when the average person just wants to install and then play Internet, Facebook, Twitter, type a few documents and check their bank balance. Still, now you can do all that. Only faster.