Mirror Swap

I wonder if it helps to mirror swap e.g. via ZFS or gMirror in order to get a HA System from HDD point of a view. Please don't consider the negative effect of not being able to store kernel dumps, since I'm not interested in it due to the fact, that I rather have a HA System.

I remember, that some longer time ago, I've read about the fact, that if one of the mirrored swap drive fails, the kernel will panic. If this scenario is the case, than of course it would be useless to mirror, since mirroring should exactly prevent such a scenario.

Unfortunately currently I don't have a system to test this in more detail. I was hoping you could share some useful information about this?

Thanks
 
Gmirror swap is very safe, from the kernel's point of view it's no different than using a single partitition. I don't understand why would anyone make a claim that the kernel would panic if one of the disks in the mirror fails because that event would be hidden by the mirroring and the system would continue working normally with just one drive of the mirror.
 
It may panic if the swap was on a RAID 0 and one of the disks dies. As kpa said, it should not happen with mirroring (RAID1).
 
Nobody runs swap on RAID 0. If the swap becomes the performance bottleneck you already have much bigger problems elsewhere.
 
So gmirror(8) should be safe. And what about a mirror setup via ZFS? I assume it should also be safe, right?
 
Last edited by a moderator:
Yes, it should. This is how Proxmox, which is a Debian derivative, is actually set up when installed with root on ZFS. Just make sure to exclude the swap zvol from ARC caching, or you'll have bad surprises. By default, Proxmox only caches metadata (primarycache=metadata) as a means to (try to) reduce the latency of swap operations.
 
Back
Top