Skip to main content

mdadm - Replace failed disk

1. Identify the failed disk

Useful tools: lsblk, smartctl, hdparam

Write down the serial number of the failed disk. Example: lsblk -o NAME,SERIAL

2. Mark the disk as failed

mdadm --manage /dev/mdXXX --fail /dev/sdXY

3. Remove the disk by mdadm

mdadm --manage /dev/mdXXX --remove /dev/sdXY

4. Replace the disk

Shut down the server if necessary and replace the disk. Make sure to pick the right one and verify the serial number. Then power on the server again.

5. Recreate the partition table on the new disk

Recreate or copy from an existing disk with sfdisk -d /dev/sdSOURCEDISK | sfdisk /dev/sdDESTDISK.

6. Add disk to array

mdadm --manage /dev/mdXXX --add /dev/sdXY

The mirroring process will start automatically.

7. Verify

cat /proc/mdstat shows the progress of the mirroring process.