Recovering software RAID boot drive

My main file server uses software RAID, primarily RAID1 (mirroring), for both data and boot disk. I started having problems with one of the boot mirror's lately, and smartctl -t clearly shows failures. I was a little worried about pulling it out, since it also was the first disk (sea/hd0) that was failing. I followed the following steps to assure that it kept booting from the surviving mirror:

$ sudo grub

# root (hd0,0)
# setup (hd0)
# root (hd1,0)
# setup (hd1)

 

This of course assumes that your first two disks are the boot disks, in my case, /dev/sda and /dev/sdb. Also, the boot disk is the first partition, of course (/dev/sda1 and /dev/sdb2). Note that I did not edit anything in grub.config, once the bad disk is removed, the surviving mirror will be hd0, and it should boot just like this. Once you've replaced the bad disk, and installed a replacement, update the partition table, and then re-add the partitions normally. E.g.

$ sudo mdadm --manage /dev/md0 --add /dev/sdb1
$ sudo mdadm --manage /dev/md1 --add /dev/sdb2
$ sudo mdadm --manage /dev/md2 --add /dev/sdb3


 

I take no responsibilities for failures here, for some additional details also see http://www.texsoft.it/index.php?c=hardware&m=hw.storage.grubraid1&l=it.