Your use of the information on Hobbs Knowledge Base is at your own risk and I accept no responsibility for any damage caused. More info here.
How To Stop Linux Swapping So Much
From Hobbs Knowledge Base
Summary
The kernel has a value called "swappiness" which determines how willing it is to swap stuff out of RAM into the swap partition.
By default on my machine, this value is "60". A value of "100" tells the kernel to swap out as much as possible (as long as it's not in use, of course), and a value of "0" tells the kernel to keep as much as possible in RAM until it's completely full, at which point it will start swapping out.
You can check your machine's default value by typing the following command:
cat /proc/sys/vm/swappiness
I think that's pretty much the case, anyway.
On my machines at home and work, i have set this value to "10" - this way, i don't have to wait quite as long for that application to open up from the task bar, that's been minimized for hours/days because it's still in RAM, and it's not having to reload it all from the swap partition, so it makes the whole machine feel slightly more streamlined, and much smoother.
To set this value on-the-fly, in a currently-running Linux system, type the following command:
echo xx > /proc/sys/vm/swappiness
(where "xx" is the number you wish to set it to ("10" for example)).
This will set the value and start using it immediately, but if you reboot your machine the value will reset back to the default value. You can, however, change the default value ready for your next reboot (and all future reboots) by adding the following two lines to the bottom of "/etc/sysctl.conf":
# reduce swappiness from yy (default) to xx vm.swappiness=xx
(where "xx" is the number you wish to set it to ("10" for example) and "yy" is whatever the default value was on your machine).
| If the information on this page is either out-of-date, incorrect, or if you'd just like more information then please Contact Me. |

