Linux systems use both RAM and swap space to manage memory. RAM is the physical memory, while swap is a space on the hard drive used when RAM is full. By default, Linux can start using swap even if RAM is not full. You can change this by adjusting the swappiness value.
How to Set Swappiness to Use Swap Only When RAM is Full
If you want your system to use swap only when RAM is almost full, you should set the swappiness value to 1.
Steps to Change the Swappiness Value
Open a terminal.
To temporarily set swappiness to 1, type this command:
sudo sysctl vm.swappiness=1
To make this change permanent, follow these steps:
Open the file /etc/sysctl.conf with a text editor:
sudo nano /etc/sysctl.conf
Add or modify this line in the file:
vm.swappiness=1
Save the file and exit the editor.
To apply the change, run this command:
sudo sysctl -p
Lower the Swap Priority over RAM
Conclusion
By setting the swappiness value to 1, your Linux system will prioritize using RAM and only use swap space when the RAM is nearly full. This can help improve performance in most cases.
The post How to Configure Swappiness to Use Swap Space Only When RAM is Full appeared first on TecAdmin.
Source: Read More