I know sysctl [variable]
such as sysctl vm.swappiness
will print out the value of vm.swappiness
. But when I tried sysctl vm.swappiness=10
and then typed sysctl vm.swappiness
, it showed that vm.swappiness = 10
(it was 60 before). I thought to change a sysctl
setting, you had to do sysctl -w [variable]
such as sysctl -w vm.swappiness=10
.
Is there a difference between sysctl vm.swappiness=10
and sysctl -w vm.swappiness=10
?
I thought that sysctl -w vm.swappiness=10
might edit /etc/sysctl.conf
directly, but that does not seem to be the case because when I entered sysctl -w vm.swappiness=10
and then looked at /etc/sysctl.conf
, vm.swappiness
was still set to 60. Then, when I did sysctl -p
, vm.swappiness
became 60 again.
So additionally, does sysctl -w
configure /etc/sysctl.conf
in any way?
re: Is there a difference between
sysctl vm.swappiness=10
andsysctl -w vm.swappiness=10
?No.
re: So additionally, does
sysctl -w
configure /etc/sysctl.conf in any way?No.
To edit /etc/sysctl.conf with a GUI text editor:
sudo -H gedit /etc/sysctl.conf
Otherwise use pico, nano, vim, or other favorite editor.
See
man sysctl
for more info.Be careful when setting vm.swappiness. A low value favors RAM, where a high value favors swap.
Examples:
With 4G RAM, setting vm.swappiness=10 is nuts. With a large enough swap, setting vm.swappiness greater than 60 (the default) might make some sense.
With 32G RAM, and a HDD for swap, setting vm.swappiness=10 might make some sense.