I can't switch to sysctl vm.swappiness=10

Your only swap device is zram, which has it’s swappiness set in /usr/lib/sysctl.d/99-sysctl-garuda.conf. If you want to change the swappiness of your zram device you can change it there.


Reducing the swappiness of your zram device will most likely reduce your system performance. I’m not sure what you are actually trying to do, but if you are attempting to spare some writes to the disk you should be aware that zram does not use the hard drive, it uses RAM. So you may be sacrificing performance for no benefit.

Testing suggests a higher swappiness value gives better performance on a system using zram.

zram - ArchWiki

Optimizing swap on zram

Since zram behaves differently than disk swap, we can configure the system’s swap to take full potential of the zram advantages:

/etc/sysctl.d/99-vm-zram-parameters.conf
vm.swappiness = 180 
vm.watermark_boost_factor = 0 
vm.watermark_scale_factor = 125 
vm.page-cluster = 0

Explanation of the configuration:

These values are what Pop!_OS uses. That Pop!_OS GitHub PR also links to some testing done by users on r/Fedora, which determined that vm.page-cluster = 0 is ideal. They also found a high swappiness value to be ideal, which matches what is suggested by the kernel docs:

“The default value is 60. For in-memory swap, like zram or zswap, as well as hybrid setups that have swap on faster devices than the filesystem, values beyond 100 can be considered. For example, if the random IO against the swap device is on average 2x faster than IO from the filesystem, swappiness should be 133 (x + 2x = 200, 2x = 133.33).”

On a system with a hard drive, random IO against the zswap device would be orders of magnitude faster than IO against the filesystem, so swappiness should be ~200. Even on a system with a fast SSD, a high swappiness value may be ideal.

3 Likes