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.

Similar Reads

What is Swappiness?

Swappiness, in the context of Linux, is an important kernel parameter that governs the system’s propensity to transfer less actively used memory pages from RAM to disk swap space. Represented as a value between 0 and 100, swappiness determines the percentage of swapping activity. Higher values encourage more swapping, potentially enhancing system responsiveness, while lower values mitigate swapping, prioritizing the retention of data in physical RAM. With a default setting of 60 in most Linux distributions, indicating a preference to swap out up to 60% of inactive cached pages, users can fine-tune swappiness to align with specific workloads and available RAM, effectively minimizing I/O overhead stemming from excessive swapping....

How to Display the Swappiness Value of the System?

In this section, we will explore the steps to retrieve and display the current swappiness value of your Linux system. Utilizing the sysctl command, we can easily inspect the active swappiness setting, providing insights into the system’s memory management configuration....

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....

Frequently Asked Questions on Changing Swappiness of Linux System – FAQs

What is swappiness on Linux?...

Conclusion

In conclusion, swappiness is a Linux setting that controls how often the system swaps memory pages from RAM to disk. The default swappiness value of 60 tells Linux to be quite aggressive about using swap space. However, high disk I/O from excessive swapping can lead to performance issues. Lowering the swappiness allows Linux to favor using free RAM over swap, which is faster. The swappiness parameter tunes Linux memory management. Lower values lessen swap usage which usually speeds things up. Try values like 10 or adjust higher if your system lacks RAM. Changing it can optimize Linux to best suit your hardware....

Contact Us