The Linux and Unix Swap Memory and Swappiness Parameter

When your computer gets out of RAM memory, some data from the RAM memory is transfered to the swap memory, on the hard disk. The Swap memory is a simple file or partition on the hard disk.

When you send your computer to hibernation, all the data from the RAM is transfered to the Swap memory. In the books is said that the swap memory needs to have at least the double capacity of the RAM memory.

There is also a swappiness parameter. This parameter controls the tendency of the kernel to move processes on the swap disk, when there is no physical memory.

swappiness=0 tells the kernel not to send data on the swap disk

swappiness=100 tells the kernel to agressively move the data from the RAM to the swap.

By default, the swappiness value is 60.

Depending of you RAM memory, you can choose a  swappiness value lower or higher than 60:

This is how to set a new swappiness value:

$ sudo sysctl vm.swappiness=10

This values are saved in the /etc/sysctl.conf file. You can also modify the swappiness value by editing, by hand, /etc/sysctl.conf.

Tagged with: , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *




Subscribe to get the latest Linux news and how to guides directly on your e-mail!