Rebuilding mdadm RAID 5 Array

Written by Justin Goetz -

Recently, a drive failed in my software RAID 5 Array. These are the steps I found to take.

1st, remove the dying drive from the RAID.

mdadm --manage /dev/md0 --fail /dev/sde1
mdadm --manage /dev/md0 --remove /dev/sde1

Once the drives are removed from the RAID array, power down the server and replace the drive. Be certain that you are replacing the correct one. I used my drive's serial number to identify which one to remove.

Boot the server again, and login to a terminal. Now, the new drive should appear in the same /dev/sd* format as the previous drive. Now we copy the partition table from the other drives to the new drive.

/sbin/sfdisk -d /dev/sda | /sbin/sfdisk /dev/sdb

Once that has completed, verify that the drives have appeared in the /dev directory.

ls /dev/sdx*

Now just add the drive back to the RAID with the following mdadm command.

mdadm --manage /dev/md0 --add /dev/sdb1

Comments