CentLinux

Monday, 13 September 2021

How to Change Swappiness in Linux

change-swappiness-in-linux-distribution

In this article, you will learn how to change swappiness in Linux distributions.

The Linux kernel's swappiness setting defines how aggressively it will swap memory pages versus dropping pages from the page cache.

A higher value increases swap aggressiveness, while a lower value tells the Linux kernel to swap as little as possible to disk and favor RAM.

The swappiness range is from 0 to 100, and most Linux distributions have swappiness set to 60 by default.

Some database servers managed cache to use RAM, and is capable of managing what should be in RAM and what shouldn’t be. Allowing the Linux operating system to have too much control over what memory pages are in RAM is likely to lower your database performance. Therefore, it is recommended that swappiness should be set to 0.

Check current setting of swappiness.

# cat /proc/sys/vm/swappiness
60

Set the swappiness setting to 0 for the running system.

# sysctl -w vm.swappiness=0
vm.swappiness = 0

Verify the current setting of swappiness again.

# cat /proc/sys/vm/swappiness
0

To make swappiness setting persistent, you have to add it in Kernel parameter file.

# echo 'vm.swappiness=0' >> /etc/sysctl.d/99-swappiness.conf

You have successfully change the swappiness for your Linux distribution.

 

Video Link:

If you find this article useful? Consider supporting us by Buy Me A Coffee


No comments:

Post a Comment

© 2023 CentLinux. All Rights Reserved.