When an array member fails, it's important to replace it as soon as possible because the failure of additional drives increases the chance of data loss. This recipe teaches you how to properly replace a bad drive and rebuild the array.
This recipe requires a CentOS system with administrative privileges provided by logging in with the root
account or using sudo
. It assumes that a RAID-1 configuration has been set up as described in the previous recipe and the drive that will be replaced is /dev/sdb
.
Follow these steps to replace a failed disk in a RAID:
Mark the failed partition as faulty with
mdadm
using the-f
option:mdadm /dev/md/md0 -f /dev/sdb1
Remove the partition from the RAID's configuration with
-r
:mdadm /dev/md/md0 -r /dev/sdb1
Physically replace the faulty disk.
Partition the new drive with
cfdisk
:cfdisk -z /dev/sdb
Use the
-a
option to add the partition to the RAID:mdadm /dev/md/md0 -a /dev/sdb1