How to change swappiness on a linux server ?

Swappiness is a feature in linux which tells the system kernel how much data to be swapped, or to be moved into swap memory and back to main memory.

The larger the value, more data is moved to swap memory.

Hence in large memory systems, we recommend to have less or least swappiness to have increased performance.

In this post, we will see how to change swappiness on our linux server.

Lets see this step by step.

1. Check current swappiness on the server.

[root@ngelinux001 ~]# cat /proc/sys/vm/swappiness
60

 

2. Change the swappiness in the configuration file.

[root@ngelinux001 ~]# tail /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
## Reboot the system after 5 minutes, if kernel panics.
kernel.panic = 300
# Increasing these values to alleviate Indago inotify runtime issues
# # fs.inotify.max_user_watches from 8192 to 131072. fs.inotify.max_user_instances from 128 to 8192
fs.inotify.max_user_watches = 131072
fs.inotify.max_user_instances = 8192
vm.swappiness = 1

 

3. Save the changes by printing them

[root@ngelinux001 ~]# sysctl -p
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
kernel.panic = 300
fs.inotify.max_user_watches = 131072
fs.inotify.max_user_instances = 8192
vm.swappiness = 1
[root@ngelinux001 ~]#

 

4. Check the new swappiness value on our server.

[root@ngelinux001 ~]# cat /proc/sys/vm/swappiness
1

I hope you are now aware what is meant by swappiness and how to change it in linux.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments