Objectives
To properly rebuild a software RAID array after performing a hot swap.
Prerequisites
N/A
Steps
Step 1: Copy the Partition Table of Running Drive
Ensure the partition table of the new GPT disk (replacement disk) matches with the running disk. To do so, copy the partition table entries with the sgdisk command
sgdisk -R <New_Disk> <Existing_Disk>
For example:
sgdisk -R /dev/sdc /dev/sdb
For non-GPT disks, you can copy partition tables with the sfdisk command.
sfdisk -d <Existing_Disk> | sfdisk <New_Disk>
For example:
sfdisk -d /dev/sdb | sfdisk /dev/sdc
Step 2: Add Partition to Existing RAID Array
Now the partition table has been copied over to the new disk, the newly-created partition can be added to the running RAID Array via mdadm –add command.
For our case, we will be adding one of the new partitions of /dev/sdc to the running RAID Array /dev/md0
mdadm --add /dev/md0 /dev/sdc1
Step 3: Verify Status of RAID Array
Once the new partition had been added into the array, the rebuild process will be initiated automatically.
To verify the status of the RAID array, simply refer to the /proc/mdstat file.
cat /proc/mdstat