What is swappiness and how do we change its value?

It is a feature in Linux which controls the degree to which the kernel prefers to swap in the procedure of freeing memory. It can be set to values on a scale from 0 to 100. A low value means the kernel will try to avoid swapping as much as possible unless there is almost no free memory let on the RAM for any new process. On the other side a higher value would force kernel aggressivey to swap out pages from the physical memory.

The default value for Linux machines is 60. Using a higher value wiil affect the system negatively as accessing a hard disk(swap space) for each and every request by a application program is a very slow process as compared to doing the same from physical memory. So it should be avoided to transfer active pages to swap space aggressively.

To check the current swappiness value

$ cat /proc/sys/vm/swappiness
60

To change the value

# echo 40 > /proc/sys/vm/swappiness

To make the changes affect

# sysctl -p

Verify the new parameter

# sysctl -a | grep swappiness
vm.swappiness = 40

 

Related Articles
What is kernel-PAE in Linux?
What is a Kernel in Linux?
What is virtual memory, paging and swap space?
What is the difference between POP3 and IMAP?

Leave a Comment