====== NAS - Build a Linux NAS - Support recovering from a faulty disk ====== ===== Determine which disk has failed ===== mdadm --detail /dev/md0 returns: ---- ===== Get the serial number of the failed disk ===== hdparm -i /dev/sdd | grep SerialNo returns: Model=ST16000NM001G-2KK103, FwRev=SB30, SerialNo=WL2091XL **NOTE:** Double check which actual physical disk has failed and needs to be replaced. ---- ===== Replace the faulty disk ===== Steps are: * Wait until the disks has finished rebuilding on the spare disk if any. * Power the server down. * Replace the faulty disk. * Power the server up again. * Partition the disks. * Add the new disk to the array with: mdadm --add /dev/md0 /dev/sdd1 **NOTE:** To add a failed drive, for example /dev/sdd1 back to the RAID the following can also be used: sudo mdadm --manage /dev/md0 --add /dev/sdd1 ---- ===== Recover the Raid ===== If the original OS dies, but the RAID disks are okay, then rebuild a new OS. Then, use mdadm to examine the superblock on one of the disks and use this to recover the raid: mdadm --examine /dev/sda returns: Then use the listed UUID from the disk to assemble the raid onto the device md0: mdadm --assemble /dev/md0 --uuid= **NOTE:** See [[https://www.linuxquestions.org/questions/linux-general-1/recovering-mdadm-superblocks-713234/|Recovering mdadm superblocks]]