Monday, January 19, 2009

Replacement of Faulty RAID Drive

For consistency, always move the good drive to to the primary position and place the new replacement drive in the secondary. Reboots the system and read the RAID status by:

# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sda2[0] sdb2[1]
3943872 blocks [2/2] [U_]

md0 : active raid1 sda1[0] sdb1[1]
152344256 blocks [2/2] [U_]

unused devices:


As you can see, sdb1 and sdb2 are missing.

Start by copying the partition structure from /dev/sda to /dev/sdb:
# sfdisk -d /dev/sda | sfdisk /dev/sdb

Now add the two sdb partitions to the corresponding md's:
# mdadm --add /dev/md0 /dev/sdb1
# mdadm --add /dev/md1 /dev/sdb2


The two drvies should start to synchronize. To watch them sync:
#watch -n 1 cat /proc/mdstat

At last, create a new boot record on the secondary drive:
Start the grub command shell:
# grub

At the 'grub>" shell prompt create new boot record for the second drive:
grub> root (hd1,0)
grub> setup (hd1)
grub> quit