How do I configure swappiness?
Moderator: Staff
cPanel Server Management
@ 30$ Onwards
@ 30$ Onwards
Re: How do I configure swappiness?
Swappiness can be set to values between 0 and 100 inclusive. A low value causes the kernel to avoid swapping, a higher value causes the kernel to try to use swap space. The default value is 60. You can simply set the swappiness value running as root user.
To find the current swappiness settings:
(e.g. 30) to /proc/sys/vm/swappiness using the following command.
# Set the swappiness value as root
# Alternatively, run this
# Verify the change
To make changes permanent, you can add the setting to the /etc/sysctl.conf file:
Add the below line.
# Search for the vm.swappiness setting. Uncomment and change it as necessary.
You can also clear your swap by running swapoff -a and then swapon -a as root instead of rebooting to achieve the same effect.
To find the current swappiness settings:
Code: Select all
cat /proc/sys/vm/swappiness
- Result: 60
(e.g. 30) to /proc/sys/vm/swappiness using the following command.
# Set the swappiness value as root
Code: Select all
echo 30 > /proc/sys/vm/swappiness
Code: Select all
sysctl -w vm.swappiness=30
Code: Select all
cat /proc/sys/vm/swappiness
- Result: 30
Code: Select all
sysctl vm.swappiness
- Result: vm.swappiness = 30
To make changes permanent, you can add the setting to the /etc/sysctl.conf file:
Code: Select all
sudo nano /etc/sysctl.conf
# Search for the vm.swappiness setting. Uncomment and change it as necessary.
Code: Select all
vm.swappiness=10
You can also clear your swap by running swapoff -a and then swapon -a as root instead of rebooting to achieve the same effect.
Aaron N
Linux Support Engineer.
Nixtree Solutions LLP
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree
Linux Support Engineer.
Nixtree Solutions LLP
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree