How to change swappiness in Linux

Swap space is part of the hard disk is full of RAM used. Swap space can be a dedicated swap partition or swap file.

When the Linux system runs out of physical memory, RAM moved from the inactive page to swap space.

Swappiness is a Linux kernel property for setting the page switching from physical memory to swap space and delete pages from a balance between the page cache. It essentially defines the system frequency using the swap space.

This article describes how to change swappiness value on Linux systems.

Check the value Swappiness

Swappiness current value on the system you want to check, use the cat command:

cat /proc/sys/vm/swappiness

Swappiness default on most Linux distributions is 60:

60

Although swappiness 60 values ​​for most users, but in some cases you may need to set a lower value.

Another command you can use to determine the value of swappiness is sysctl:

sysctl vm.swappiness
vm.swappiness = 60

Changes in the value of Swappiness

Swappiness may have a value between 0 and 100. A value of 0 indicates the kernel actively avoid as long as possible exchange. The value of the process 100 will be actively swapped out of physical memory.

Lower values ​​will cause the kernel to avoid possible exchange, while a higher value means that the kernel will try to more actively use swap space.

Swap memory access is much slower than direct access to physical memory. Swappiness lower value parameter is likely to improve overall system performance. For regular desktop installation, we recommend a value of 10. For most database servers, it is recommended to use swappiness value of 0 or 1.

Best swappiness value depends on the size of your system work load and RAM memory. You should adjust this parameter in small increments to find the best value.

For example, swappiness value to be set to 10 at run-time, type the following command as root or sudo user:

sudo sysctl vm.swappiness=10

For swappiness parameters remain unchanged after the restart, use a text editor to open the file /etc/sysctl.conf:

sudo nano /etc/sysctl.conf

Find vm.swappiness parameter and change its value. If this parameter is not present, add the following lines appended to the file /etc/sysctl.conf.

vm.swappiness=10

in conclusion

We've shown you how to change swappiness parameter values.

Guess you like

Origin www.linuxidc.com/Linux/2019-09/160761.htm