How to Change the Swappiness Value?
In the above section, we explored the steps to retrieve the Swappiness Value. In this section, we will navigate through the steps to change the Swappiness Value.
Step 1: Create the Entry of Suitable Value
Create or modify the entry for swappiness in the /etc/sysctl.conf file by using a text editor. Open the file with the command sudo gedit /etc/sysctl.conf and change the value of vm.swappiness to your desired setting. If the entry doesn’t exist, create it. This step ensures a persistent adjustment of the swappiness value on your Linux system.
Command:
sudo gedit /etc/sysctl.conf
Output:
Step 2: Display the Created Entry
Verify the successful creation of the entry in the /etc/sysctl.conf file by using the command cat /etc/sysctl.conf | grep swappiness. This command displays the content of the file and filters for lines containing “swappiness,” confirming the presence of the newly created or modified entry.
Command:
cat /etc/sysctl.conf | grep swappiness
Output:
Step 3: Change the Swappiness Value of System
Change the system’s swappiness value during runtime using the sysctl command. Execute the command sudo sysctl vm.swappiness=10 (adjusting “10” to your preferred value) to dynamically set the swappiness to the desired level. This allows testing and immediate application of the new swappiness value without requiring a system reboot.
Command :
sudo sysctl vm.swappiness=10
Output :
How to Change the Swappiness of your Linux system
In this article, we will explore the crucial aspect of Linux system optimization by exploring the “swappiness” setting. Swappiness determines the system’s tendency to swap data between RAM and disk, influencing overall performance. This article not only explains the underlying mechanics of swappiness but also provides practical insights and examples for adjusting this parameter, both temporarily and persistently, to enhance Linux performance enabled to specific hardware configurations and workloads.