Improve responsiveness of Linux desktop: decrease “swappiness”

In Performance on July 25, 2009 at 4:54 pm

The swappiness parameter controls how aggressively the kernel swaps processes out of physical memory and onto the swap disk.

When swappiness=0, the server kernel avoids swapping programs out of physical memory for as long as possible. When swappiness=100, the server aggressively swaps processes out of physical memory.

The Ubuntu default is 60 at time of writing. You can check this through the following command:

cat /proc/sys/vm/swappiness

We want to change this value, and lower it to (typically) 20, as swap space is much slower than physical memory and involves expensive I/O writes. Also, the constant swapping heats up the hard drive and lowers its life expectancy.

You can change this value temporarily ( till the next reboot ) through the following command:

sudo sysctl vm.swappiness=20

To make this change permanent, we’ll need to edit /etc/sysctl.conf

gksudo  gedit /etc/sysctl.conf

and add or modify this parameter.


If this parameter does not exist in the file, add it at the end. You’ll need to reboot to have this change take effect. Authoritative source for this tip is the Ubuntu Community Documentation Swap FAQ.

Open a terminal, and run the free command to check how much swap space is being used after implementing this tweak.

Sample output on my system after the tweak:

$free             total       used       free     shared    buffers     cached
Mem:       1017416    1001440      15976          0      14304     233252
-/+ buffers/cache:     753884     263532
Swap:      1004020     133460     870560


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: