Running "swapon -a" on a system where some of the /etc/fstab swap
entries are already enabled causes us to erase the contents of active
swap devices, with predictable effects.
Try to avoid this problem by calling swapon() before erasing the swap
device, and not erasing the device if an error occurs. This is not an
elegant solution, but I can't see how to reliably determine whether a
device is already a swap device. vm.swap_info gives the device number
for all in-use swap devices, but this is not sufficient to identify
vnode-backed swap devices.
Suggestions for other approaches are welcome, I will try to implement
them.
PR: 260793