To try and fix an issue, I set swappiness to as low as possible, a 0, and swap is still being used. Why?

Running free -m gives:

total        used        free      shared  buff/cache   available
Mem:            484         241           8          58         235         134
Swap:          1023          97         926
  • 1
    Maybe because RAM is full? Or you had set it incorrectly? Add more detail like how exactly you configured it and the output of free -m – Byte Commander Oct 25 '17 at 12:54
  • You've got a pretty small amount of memory for Ubuntu in this machine - what version of Ubuntu are you running? – Charles Green Oct 25 '17 at 12:59
  • It's a VPS on Ubuntu 16.04(I can't afford a better server now) – NerdOfLinux Oct 25 '17 at 12:59
up vote 3 down vote accepted

Swappiness defines when swap is used.

For instance, swappiness of 40 defines to begin using swap when there is 40% of RAM left to use.

Swappiness of 0 defines swap is used when the RAM is full and 0% left to use.

To disable swap (totally not recommended as you could possibly end up with an unusable system), you run:

sudo swapoff -a

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.