Linux – Having trouble setting up RAID 1 on Fedora

fedoralinuxpartitioningraid

I have been working for a while to setup RAID 1 on my fedora server. I have one installed with Fedora, 1 blank but partitioned. The one with fedora is /dev/sda and the blank one is /dev/sdb.

I tried to install by doing mdadm --create /dev/md0 --raid-devices=2 --level=1 /dev/sda2 /dev/sdb1, which it responded with the "cannot open /dev/sda: device or resource busy error."

I tried doing implementing the solution from a previous thread, where I used sudo yum remove dmraid libdmraid1.0.0.rc15 and restarted, but there was still a device busy on /dev/sda.

I tried to force it by using mdadm --assemble --run --force /dev/md0 /dev/sda2 /dev/sdb1, but it said "/dev/sda2 has no superblock – assembly aborted".

When I tried to do the zero-superblock command, mdadm --zero-superblock /dev/sda1, it returned with "couldn't open /dev/sda for write – not zeroing".

So, then I installed smartmontoools to see if it was a problem with the drive. They both passed the test when I used smartctl -d ata -a dev/sd[a1,b1,a2,b2].

I'm pretty new to Linux and Fedora in general, so maybe the solution is really easy and its slipping over my head? I'm just really confused and frustrated at this point, and I would like to seek some outside help. I have no idea where to go from here.

Best Answer

What are you trying to do? Because I see two options:

Option 1:

You already have installed Fedora on the disk /dev/sda, on the first partition.
You have some free space in /dev/sda2
You have some free space in /dev/sdb1
And you want to combine these two partitions in a mirror.

Option 2:

You have installed Fedora on the first disk (in the first partition) and you want to mirror everything, including the OS which is currently active.


Option 1 should just work. You might want to check that the partition type of /dev/sda2 and /dev/sdb1 is fd. (Aka Linux RAID autodetect).

You also want to check that neither partition has a mounted (and thus active) filesystem. Worst case reboot the OS and select single user mode. Then create the array with nothing running but a bare root shell.


Option 2 is trickier. The easy solution is to reinstall with the RAID array create before you install.

The hard solution comes down to this:

  • Create a mirror with one disk.
    mdadm -create /dev/md0 --raid-devices=2 --level=1 missing /dev/sdb1 (note the `missing**). You should now have a degraded mirror.
  • Copy the OS to the new device. Tricky with a running OS. I recommend booting from a liveCD to do this.
  • Configure the new disk to boot (probably means playing with the bootloader).
  • Now boot from the degraded mirror leaving the old OS on sda inactive.
  • Wipe the disk, repartition to type fd. Probably reboot.
  • 'Fix' the mirror by adding the old disk to it.
Related Question