Vm.swappiness=1 isn't working!


I have 8 GiB of RAM(7.23 usable), and it’s quite good. So, I don’t want the system to use the Swap until it really needs it!

  1. I set the swappiness in /etc/sysctl.d/20-swappiness.conf to 10, then to 5, then to 1, but it didn’t have any effect!
  2. I also tried $sudo sysctl vm.swappiness=1, and I even tried $sudo sysctl vm.swappiness=0 but nothing happened! it still uses Swap even if the ram usage is just 4-6/7.23!

I turned off the swap, then repeated 2), but no effect too!

I’m confused. Why isn’t it working?!

You followed these steps and it didn’t work?


Have you confirmed that it did in fact change with

cat /sys/fs/cgroup/memory/memory.swappiness


cat /proc/sys/vm/swappiness

I don’t believe setting it to 0 is a good idea, use 1-100

I have a laptop with 8Gb of RAM and I have the opposite issue, I can’t get the kernel to use the swap without upping the swappiness, funny how that works :stuck_out_tongue:



I was thinking it might do sth!

ironic :joy:

I read this article and set /proc/sys/vm/vfs_cache_pressure to 40, then swappiness to 4, (I made sure they’re set up using sysctl) and I really was not very sure it had a serious effect on the swap usage :joy:

I turned swap off, then it was 6G usage, turned it on again, then opened a lot of chrome tabs, and it started to be filled when the usage reached 6.45G :3

I’m not sure what’s going on. but I’m sure I didn’t miss anything!

sysctl vm.swappiness results in: vm.swappiness = 4
and sysctl vm.vfs_cache_pressure results in: vm.vfs_cache_pressure = 40

what else should I reduce? :joy:

You can always set swappiness to 1, which essentially only uses it when absolutely necessary, note that you’ll need to reboot or swapoff/swapon to make sure swap is cleared. Otherwise can take awhile to notice it take effect.


That’s what I have mine set to on my main pc which has more than enough RAM

1 Like

For the record: I also find that vm.swappiness has absolutely no effect on the swap usage in my Debian stable system, I am convinced it is a placebo knob :expressionless:

@OP: can you drop the caches?

sudo tee /proc/sys/vm/drop_caches <<<"3"

^ That should free up swap space, not really a solution though.

I use zswap, that might help a bit, add this kernel parameter:


It won’t change the swap usage per se but it will apply compression and make if faster and more efficient.


In order to have the swappiness to be in effect without to have to reboot after it s saved in your sysctl file , you have to do this command in your /etc/sysctl.conf file in terminal;

sysctl -p

& check if it s in there afterward.

1 Like

@Head_on_a_Stick , thx , will try that one out, good trick in there.


1 Like

I did that, but no effect, too

did that but no effect

Ah, I see

Well , weird. What s the output from this in terminal

cat /proc/sys/vm/swappiness

Also , what s the output if you do in terminal

sysctl -p

I made it so, because I wanted swap to start working when ~250MB only left in memory, but it starts working when ~800MBs are left

vm.swappiness = 4
vm.vfs_cache_pressure = 40
fs.inotify.max_user_watches = 524288

Thx for the comeback, it s in it, it should be working …

Edit: Here are my last 4 output : might help you out.

vm.swappiness = 10
vm.dirty_ratio = 40
vm.dirty_background_ratio = 10
vm.vfs_cache_pressure = 50

1 Like

thanks for sharing, will try these options

1 Like

@ahmedloay, No problem mate.