[SOLVED] How can I force swappiness=0

As far as I know swappiness=0 isn't supported anymore. If you don't want swapping at all, why don't you just remove your swap partition (open /etc/fstab and comment out the line that mounts your swap partition)? If you don't want to reboot you can also run swapoff -a to temporarily disable swapping.
 
To make it persistent you need to add the following line to /etc/sysctl.conf :
vm.swappiness=0
 
  • Like
Reactions: alext
From the kernel documentation:
This control is used to define the rough relative IO cost of swapping and filesystem paging, as a value between 0 and 200. At 100, the VM assumes equal IO cost and will thus apply memory pressure to the page cache and swap-backed pages equally; lower values signify more expensive swap IO, higher values indicates cheaper.
...
At 0, the kernel will not initiate swap until the amount of free and file-backed pages is less than the high watermark in a zone.
So "swappiness=0" won't disable swap, it will just swap out very late. If you want the OOM to kill processes instead of swapping out RAM you really need to disable swap by swapoff -a or unmounting the swap device/file.
 
  • Like
Reactions: Chris
I didn't get the motivation to disable swap...
A case could be creating a Kubernetes node.

If anyone else ends up here looking to disable swap to create a Kubernetes node template...

As far as I know swappiness=0 isn't supported anymore. If you don't want swapping at all, why don't you just remove your swap partition (open /etc/fstab and comment out the line that mounts your swap partition)? If you don't want to reboot you can also run swapoff -a to temporarily disable swapping.

As Dunuin comments ^, the commenting out of the swap partition line in /etc/fstab seems to also be necessary.
 
Last edited:
A case could be creating a Kubernetes node.

If anyone else ends up here looking to disable swap to create a Kubernetes node template...



As Dunuin comments ^, the commenting out of the swap partition line in /etc/fstab seems to also be necessary.
Doesn't kubernetes support swap now?
 
Quick follow up question to all this, after disabling swap, do I need to re-configure any of my lxcs swap settings? Or is it OK to just leave them thinking they have swap?
 
Quick follow up question to all this, after disabling swap, do I need to re-configure any of my lxcs swap settings? Or is it OK to just leave them thinking they have swap?
Have you checked if they see the 0 swap? If they see it, the settings swap cannot be used.

Why do you want to disable swap?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!