The swappiness parameter of the Linux kernel controls how finicky it is about moving processes out of physical RAM to the swap space on your harddisk. Swappiness ranges from 0 to 100. A value of 0 means that the kernel tries to use the swap space as less as possible, that is it tries to keep processes in physical RAM as much as possible. On the other hand, a value of 100 makes the kernel move processes to swap space as early as possible.
If you find your Ubuntu to be moving processes unnecessarily to disk and back, then you might want to play around with the swappiness parameter. Ubuntu sets this parameter to 60 by default, which seems pretty high.
To check the current value of swappiness:
$ cat /proc/sys/vm/swappiness
To change the value of swappiness, to say 10, immediately for the current kernel session:
$ sudo sysctl vm.swappiness=10
To change the value permanently for all future kernel sessions, open the
/etc/sysctl.conf file and edit or add
Tried with: Ubuntu 12.04 LTS