Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If you want to temporarily change the "swappiness" value, use the sysctl tool ("-w" means "write", this will change the value):

# sysctl -w vm.swappiness=10

Verify the value:

# sysctl vm.swappiness
vm.swappiness = 10

The value will be reset on reboot (usually to 60). If you want to change it permanently, put the desired value in a sysctl config file. It's recommended to use a separate file to not accidentally change or overwrite other sysctl settings (if you overwrite the global "sysctl.conf", you'll lose whatever was in there).

# echo 'vm.swappiness=1' >/etc/sysctl.d/swappiness.conf

Now, to apply the new value, tell sysctl to use it:

# sysctl -p /etc/sysctl.d/swappiness.conf

Verify it:

# sysctl vm.swappiness
vm.swappiness = 1

If you want to temporarily change the "swappiness" value, use the sysctl tool ("-w" means "write", this will change the value):

# sysctl -w vm.swappiness=10

Verify the value:

# sysctl vm.swappiness
vm.swappiness = 10

The value will be reset on reboot (usually to 60). If you want to change it permanently, put the desired value in a sysctl config file. It's recommended to use a separate file to not accidentally change or overwrite other sysctl settings (if you overwrite the global "sysctl.conf", you'll lose whatever was in there).

# echo 'vm.swappiness=1' >/etc/sysctl.d/swappiness.conf

Now, to apply the new value, tell sysctl to use it:

# sysctl -p /etc/sysctl.d/swappiness.conf

Verify it:

# sysctl vm.swappiness
vm.swappiness = 1

Naturally, these commands must be run as root. Use sudo or just su if sudo is not configured on your system.