Ubuntu – Permission denied when changing swappiness

permissionsswap

I'm trying to set my swappiness to a more reasonable value than 60, but I get errors:

root@server1:~# sysctl vm.swappiness=10
sysctl: permission denied on key 'vm.swappiness'
root@server1:~# swapoff -a
swapoff: Not superuser.
root@server1:~# sudo swapoff -a
swapoff: Not superuser.
root@server1:~# echo 10 > /proc/sys/vm/swappiness
bash: /proc/sys/vm/swappiness: Permission denied
root@server1:~# 

What's going on here??

Ubuntu 14.04 Server
6GB RAM

Best Answer

What you want it not possible. Your Virtual private server (VPS) does not allow this (OpenVZ (probably the most popular?), Solaris Containers and LXC are 3 examples of such systems).

Basically there is one server that is divided up into containers of which you use one. Changing swappiness would change it for all containers so you are not allowed to change it. It is set by the provider.

On a side note: changing swappiness on a VPS is not going to solve any problem you believe to have. On a VPS like OpenVZ swap is the same as RAM (and I expect it to be the same on any VPS). So your problem is solved by adding RAM.

Related Question