Handling a degraded software RAID (mdadm) Print

  • 0

Linux software RAID keeps running when a disk fails, but without redundancy. Replace the disk soon, before a second one fails.

Check the state

cat /proc/mdstat
mdadm --detail /dev/md0

[UU] is healthy; [U_] means one member is missing. mdadm --detail shows which.

Replace a failed disk

  1. Find the serial number of the failed disk (smartctl -i /dev/sdb or ls -l /dev/disk/by-id/), so the datacenter swaps the right one.
  2. Mark it failed and remove it from every array it's in:
    mdadm /dev/md0 --fail /dev/sdb1 --remove /dev/sdb1
  3. Have the disk replaced. See Requesting remote hands: what to include.
  4. Copy the partition table from the healthy disk to the new one (GPT):
    sgdisk -R /dev/sdb /dev/sda && sgdisk -G /dev/sdb
  5. Add the new partitions back:
    mdadm /dev/md0 --add /dev/sdb1
  6. Watch the rebuild in /proc/mdstat.
  7. If the system boots from this RAID, reinstall the bootloader on the new disk (grub2-install or grub-install, or recreate the EFI partition).

Double-check device names before every command. Removing the wrong disk from a degraded array loses data. If you're not sure, stop and call us.


Was this answer helpful?

« Back