[SOLVED] SWAP behavior on Proxmox 6

wahmed

Famous Member
Oct 28, 2012
1,093
39
113
Calgary, Canada
www.symmcom.com
Hello,

Has SWAP behavior changed on Proxmox 6? I have noticed that after the upgrade the swap mention has been automatically removed from /etc/fstab. The GUI shows Swap usage N/A for the host.
Also LXCs are not swapping any more since the host itself has no swap space allocated.

I can fully understand the benefit of disabling swap on host. But the LXCs getting shut down when they need to swap and swap is not available. How can I have VMs swapping on the storage instead? Or should I enable SWAP on host again?
 
Hi, I also upgraded my Proxmox installation to 6.0 (Upgraded via APT) and the SWAP on my system is the same as before the ipgrade (Even though during the upgrade process I always selected to use the remote configuration files when asked to choose between the existing one or remote one).

Something might have gone wrong during the upgrade for you. I would enable SWAP again if that would be my case.
 
I can add them again, but it happened to all 9 nodes. So I was wandering if it was done intentionally by Proxmox because it is better to disable SWAP on host. I personally prefer to keep it off so Proxmox does not constantly write to the SSD OS drive. But I also want LXCs to have SWAP.
 
I can add them again, but it happened to all 9 nodes. So I was wandering if it was done intentionally by Proxmox because it is better to disable SWAP on host. I personally prefer to keep it off so Proxmox does not constantly write to the SSD OS drive. But I also want LXCs to have SWAP.

I understand you, I have a similar setup. I recommend you to read about the "swappiness" parameters. You can set it up in such a way that it will only swap when there is nearly no more space in your RAM (Still better to swap rather than having a crashing system due to oom, and if you do have enough RAM it will simply not swap untill it's necessary). Also from what I understand, the swap tries to first use static data when possible (data that doesn't changes but is still in memory), as concurrent reads and writes are extremely slow (at least on non SSDs).
 
we don't touch /etc/fstab after the initial installing. so unless you "upgraded" by re-installing all your nodes, the change in /etc/fstab must come from somewhere else.

the default behaviour in the installer did change (in 5.4 IIRC?) - if you install with ZFS as root file system, swap is no longer setup since issues with deadlocking systems became too common with swap on a zvol.
 
if you install with ZFS as root file system, swap is no longer setup since issues with deadlocking systems became too common with swap on a zvol.

That is it. Rechecking the nodes, all the ceph pmx node OSs are on single enterprise HDD. The pmx nodes in question OSs are on mirror ZFS SSD. All these nodes were cleanly installed with Proxmox 5.4 and now upgraded to 6. Any node with ZFS mirror SSD the swap is missing. It looks like I never noticed it before since there are lot of RAM on the nodes and never needed to swap.

What is the process of manually adding swap to these nodes?
 
create a swapfile/partition on some non-zfs storage (preferably one that is fast enough to be somewhat usable as swap ;)) and add it to /etc/fstab
 
FYI I use mdadm and UUIDs in fstab and create swap on SW RAID on the same disks.
My notes and you are welcome. :)
Code:
mdadm --create /dev/md/swap --level=1 --raid-devices=2 /dev/sdc3 /dev/sdd3
(apt install mdadm parted, cfdisk /dev/sdc, partprobe /dev/sdc..., mkswap /dev/md/swap, edit /etc/fstab, !!!!dodaj preko blkid UUID!!!!! in swapon -a)
 
ZRAM, while compressed, still uses RAM. So it is not a direct SWAP replacement.
ZSWAP is also an option to consider.
 
I use for all my ZFS Servers ZRAM.

I went ahead with Zram as well. The host itself got plenty of RAM. But some LXC running inside is limited to allocated memory which may not need to swap time to time. I used the following procedure:
1. Load zram module
Code:
$ modprobe zram
2. Make the module autoload during reboot by adding zram in /etc/modules
3. Create zram swap space with required size
Code:
$ zramctl --size 8G /dev/zram0
4. Format swap space
Code:
$ mkswap /dev/zram0
5. Turn on swap space
Code:
$ swapon /dev/zram0 -p 10

Thanks everyone for all your answer.
 
  • Like
Reactions: fireon
Perhaps this helps... I had serious performace problems since proxmox VE6 with my vm's ....
vm.swappiness was set to 60 by default in all my testing and productive machines.
I found this solution:
Proxmox - Best performance - Disable swappiness

In my case I needed to restart proxmox and now swap file is not in use anymore.
 

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!