Setting Swappines value for linux machine

In this post we will look into how to change the swappiness value in Linux.

Swappiness is the kernel parameter that defines how much your Linux kernel will copy RAM contents to swap.

Approach 1:

Steps

1. Login as root.

2. To get the current swappiness value:

cat /proc/sys/vm/swappiness

3. To edit, open /etc/sysctl.conf file and set the desired value for vm.swappiness

4. You can also set it like:

sudo sysctl vm.swappiness =5 (can be between 0 to 100)

5. After this it requires a restart to set the values.

There is one more option without restarting your machine:

Approach 2:

swapoff -a
sudo sysctl vm.swappiness =5
swapon -a

This will set the swappiness on Linux machine.

Comments