Linux – Forgot to create a second RAID for swap partitions in Software RAID 1. Will it work

linuxraid1software-raidUbuntu

I have a Ubuntu 11.10 headless machine setup with Software RAID 1. It has two drives, each drive has a main boot partition (sda1 & sdb1) and a small swap partition. I created a raid for the boot partitions (md0) but not for the swap partitions. OOpps!!?? The machine appears to be running fine, but how is the box handling swap? Is it striped, mirrored, or unused on one of the partitions. Should I create a second RAID for the swap partitions?

Best Answer

swapon -s will show your current active swap setup. If you see both swap-partitions with the same priority the kernel will stripe across these swap-devices.

If you do not need swap (i.e. you have got enough free+cached ram to take up what is currently in swap), you can deactivate swap online: swapoff -a. If swap is in use it will take a moment to load the swapped areas into ram.

Now you can safely build your raid1, mkswap on that device, edit fstab and swapon -a. If you use swap as resume-device you need to reconfigure that as well to the new device.