mdadm raid array lost after reboot

mdadm is a pain, since it doesn’t record the raid settings automatically, after you set everything up, you have to remember to save the mdadm.conf file. What a pain. Anyway, I forgot to do that, and on reboot, it hung my machine saying /dev/md0 was hosed.

So here is how I recovered it.

originally, my stripe was created with:

mdadm -C /dev/md0 –level=raid0 –raid-devices=2 /dev/hda3 /dev/hdc1

and so I was able to recreate the stripe using:

mdadm -A /dev/md0 /dev/hda3 /dev/hdc1

and then mount it with:

mount /dev/md0 /www -t ext3

so then I saved the /etc/mdadm.conf file with:

echo ‘DEVICES /dev/hda3 /dev/hdc1’ > /etc/mdadm.conf
mdadm –detail –scan >> /etc/mdadm.conf

So before adding it back into my /etc/fstab, I reboot, and check that I can mount it

mount /dev/md0 /www -t ext3

and if that works (it did), I add back into /etc/fstab

/dev/md0  /www   ext3   defaults   1 2

and reboot again.

Coutersy: http://blog.bloke.com/2010/03/mdadm-raid-array-lost-after-reboot/