• Root/
  • Linux/
  • Repairing RAID (mdadm)
  • If a disk managed by mdadm become unavailable, it will be removed from list of RAID devices and manual intervention will be required to restore RAID integrity. This guide assumes physical connectivity to disk device was restored or new virtual disk device was attached.

    ❗ This guide assumes reader has expert knowledge regarding RAID setup on device and can determine which device can be safely erased. Mistake will result in data loss!

    # Command Description
    0.1 sudo mdadm -D /dev/md0 Displays information about RAID located at /dev/md0 (replace RAID device name as required). Stop here if you do not know RAID device name!
    0.2 lsblk (optional) Displays information about attached devices. Use it to find new disk device name to add to remaining RAID disk devices. Stop here if you don't understand which device you should pick, otherwise prepare for data loss!
    1 sudo mdadm --manage /dev/md0 -a /dev/sdb Adds disk device /dev/sdb to RAID /dev/md0. This operation will, by design, irreversibly erase all data on /dev/sdb - if you made mistake, no steps to reduce data loss are known to this guide author are known (partial data recovery might be possible by expert recovery professional with fewer data lost if system is immediately powered down!)
    2 cat /proc/mdstat (optional) Displays status of RAID /dev/md0. After adding new/recovered disk device, rebuild progress might be observed here (you can prepend watch to see updates every 2 seconds)

    Last update: 2024-05-20