2

Now that Ubuntu (since 17.04) uses a swap file instead of a swap partition, can the swap settings be adjusted with the same methods used for swap partitions?

For example, to set your swap to 40, will

sudo sysctl vm.swappiness=40

still work?

And will adding vm.swappiness = 40 to /etc/sysctl.conf retain the new settings after restart?

2

Yes to both. Swappiness will be set the same way for swap files and swap partitions. I would recommend using a separate configuration file in /etc/sysctl.d/ though.

To check whether the swappiness has been set after reboot, use the following command:

$ cat /proc/sys/vm/swappiness 
40

If you want to test that the swappiness does actually change, you can do a simple test as described in this article: https://rudd-o.com/linux-and-free-software/tales-from-responsivenessland-why-linux-feels-slow-and-how-to-fix-that.

Take also note of this question discussing the pros and cons of reducing swappiness: Why most people recommend to reduce swappiness to 10-20?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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