swap on proxmox server ?

RolandK

Famous Member
Mar 5, 2019
1,092
272
128
52
since swap on zvol still is not in a usable state - what is the recommended proxmoy way to go to have swap on servers with requirement for redundant disk (i.e. raid storage) ?
 
Last edited:
  • Like
Reactions: leesteken
you have no redundancy with simple ext4, if your disk crashes and pages are swapped out, your server crashes. that's why i wrote "rundandant disk".

nowadays, typically zfs is being used and using mdraid is discouraged with proxmox

so i wonder what are the options, i.e. what's the right way....
 
Last edited:
You could simply create and "mount" (with nofail) two SWAP partitions/files to achieve redundancy?
 
Last edited:
that's at least better then nothing, but is no real redundancy but more a comfortability switch, as you won't need maintenance on the machine on bootup when one swap device fails.
 
zram is useful if you have ~16GB+ RAM, then you can give it a couple of gigs and it will compress.

For rpool servers I reserve a couple of gigs at the end of the disk(s) and make swap partitions manually postinstall with gdisk.

Don't forget if you have spare slots, you can have a dedicated disk for swap. Even USB3 external SSD will work since the whole point of a server is to have max RAM usage and minimal swapping.
 
But then you don't have checksums or redundancy, which was the main point of the first post.
Maybe swap on a BTRFS mirror? But the tutorials mention that the swap would be NODATACOW which also disables checksums (NODATASUM), but at least some redundancy. Then you cannot tell which copy is correct but you can probably survive a missing or fully broken drive (but not a silently corrupted or partially broken one?).
 
Last edited:
> what is the recommended proxmoy (sic) way to go to have swap on servers with requirement for redundant disk (i.e. raid storage) ?

You don't need "checksums or redundancy" for swap, that makes little sense. If the server has a requirement for RAID and comes with a RAID card, you can just set up ext4/lvm rootfs with hardware RAID6 or mirror, and use the installer to reserve some disk space for swap.

If using ZFS on HBA, then you (like I said) can reserve a bit of disk space at the end and make swap postinstall, or put swap on separate dedicated disk that aren't part of the ZFS pool.
 
>You don't need "checksums or redundancy" for swap, that makes little sense.

huh?

>If using ZFS on HBA, then you (like I said) can reserve a bit of disk space at the end and make swap postinstall,
>or put swap on separate dedicated disk that aren't part of the ZFS pool.

and if you loose the disk where the swap is on , if writes or reads will fail or read will return garbage - your system will crash
 
Last edited:
I don't really see your point, that has been the case since swap was invented (probably back in the 60's.) Any Linux system can have multiple swap partitions in addition to swap files. Or NO swap - although for Linux at least, a minimal swap amount is recommended for housekeeping.

Putting swap on hardware RAID may help to a certain extent, but I've never heard of a server failing because "the disk where the swap was housed failed" - it's usually the root filesystem getting corrupted.

Haven't tested it, but if you have more than 1 swap defined and take out a swap space entirely (fail the disk) you MAY still be able to recover the system if it hasn't kernel panic'ed by simply doing a swapoff on that extent. Part of it depends on how much swap was actually in use; modern sysadmins go for 0% to minimal usage. RAM was fairly cheap until last November, and 64GB+ systems aren't uncommon anymore.

EDIT: Do a search on " does linux kernel swap itself out " - kernel prioritizes swapping out USER space stuff and tries to keep running-the-system critical stuff in RAM.
 
Last edited: