Tuesday, February 12, 2013

mdadm and dmraid

When you try and create a RAID group using mdadm, you get some weird errors like so:


# mdadm --create --verbose /dev/md0 --level=stripe --raid-devices=3 /dev/sdl /dev/sdm /dev/sdn
mdadm: super1.x cannot open /dev/sdl: Device or resource busy
mdadm: /dev/sdl is not suitable for this array.
mdadm: super1.x cannot open /dev/sdm: Device or resource busy
mdadm: /dev/sdm is not suitable for this array.
mdadm: create aborted

This may be because the busy drives are being controlled by dmraid. You can confirm by running:
# dmraid -r

and the busy drives will show up as part of some long-dead RAID group.

You can remove dmraid if you prefer to use mdadm.
# rpm -e dmraid

Some distros are set up so the kernel has a dependency on dmraid, meaning that removing dmraid will remove the kernel as well. Obviously you don't want to do that, so you can:
# rpm -e --nodeps dmraid
# reboot

Try mdadm --create again and it should work. If it doesn't, then you can:
#  dd if=/dev/zero of=/dev/sdl bs=4k count=
#  dd if=/dev/zero of=/dev/sdm bs=4k count=

Where count is the number of 4k blocks in your drive. You actually only need to run it until the first few blocks where dmraid writes its headers are zapped. 

Now reboot again, and mdadm --create should work.

After creating the RAID array don't forget to create mdadm.conf so the array is created on startup.

Labels: