Replacing a Mirrored Disk Using mdadm
Basic steps for replacing a mirrored disk in software raid using mdadm.
Remove all raid partitions
mdadm --fail /dev/md0 /dev/sdb1 mdadm --fail /dev/md1 /dev/sdb2 mdadm --remove /dev/md0 /dev/sdb1 mdadm --remove /dev/md1 /dev/sdb2
Then you can physically remove the bad disk
Once the disk is replaced you need to repartition it. You can use sfdisk to copy the partitions from the good disk.
sfdisk -d /dev/sda > ~/partitions.sda sfdisk /dev/sdb < ~/partitions.sda
Then you can add the partitions back into the raid to have it rebuilt
mdadm --add /dev/md0 /dev/sdb1 mdadm --add /dev/md1 /dev/sdb2
You can run the following to see the rebuild process
cat /proc/mdstat
