Swappiness is a Linux kernel parameter that controls the relative weight given to swapping out runtime memory, as opposed to dropping pages from the system page cache. Swappiness can be set to values between 0 and 100 inclusive. A low value causes the kernel to avoid swapping, a higher value causes the kernel to try to use swap space. The default value is
60, and for most desktop systems, setting it to 100 may affect the overall performance, whereas setting it lower (even 0) may decrease response latency.
||The kernel will swap only to avoid an out of memory condition. See the "VM Sysctl documentation".|
||Kernel version 3.5 and over: Minimum amount of swapping without disabling it entirely.|
||This value is sometimes recommended to improve performance when sufficient memory exists in a system.|
||The default value.|
||The kernel will swap aggressively.|
With kernel version 3.5 and over, it is likely better to use 1 for cases where 0 used to be optimal.
To temporarily set the swappiness in Linux, write the desired value (e.g.
/proc/sys/vm/swappiness using the following command, running as root user:
# Set the swappiness value as root echo 10 > /proc/sys/vm/swappiness # Alternatively, run this sysctl -w vm.swappiness=10 # Verify the change cat /proc/sys/vm/swappiness 10 # Alternatively, verify the change sysctl vm.swappiness vm.swappiness = 10
Permanent changes are made in
/etc/sysctl.conf via the following configuration line (inserted, if not present):
vm.swappiness = 10
sysctl -w vm.swappiness=10
- van Riel, Rik. "Documentation for /proc/sys/vm/* in Github". Linus Torvald's kernel tree. Github. Retrieved 3 March 2013.
- Documentation for /proc/sys/vm/* kernel version 2.6.29 authoritative documentation
- "2.6 swapping behavior". May 5, 2004. Retrieved June 8, 2010.
- "Linux: Tuning Swappiness". April 29, 2004. Retrieved June 8, 2010.
- "Linux Swap Space". February 28, 2011. Retrieved May 8, 2015.