Linux Swappiness

I finally got sick of linux (Ubuntu and Centos to be more precise) swapping all the time when I have 8GB and 16GB of memory in the two machines I use all the time.  So I decided that it was time I learnt about how to tune the swappiness.  Turns out that it is particularly simple.

Swappiness is a number between 0 and 100.  0 means swap only to prevent an out of memory condition, 100 means go nuts and swap aggressively.  On both of my machines it was set to 60.

To see what value your system currently has

  • cat /proc/sys/vm/swappiness

To temporarily set the swappiness to something sane, say 10,

  • sudo sysctl -w vm.swappiness=10

To make this value persist across reboots, edit /etc/sysctl.conf as root and insert

  •  vm.swappiness=10


Tagged with: ,
Posted in Uncategorized

Leave a Reply

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

You are commenting using your 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: