My Ubuntu 21.04 Network Attached Storage Server (NAS) had a failed mdadm RAID 5 Array because 1 disk failed with bad blocks.
I recovered the RAID Array by purchasing a new Seagate IronWolf 4tb Drive and adding it back to the Raid 5 Array. The rebuild took about 8 hours.
Check your RAID Array status with
cat /proc/mdstat
This should result in your RAID array configuration and some status information:
md5 : active raid5 sdk1[4] sdi1[7] sdh1[6] sdg1[5] sdj1[8]
15627536384 blocks super 1.2 level 5, 512k chunk, algorithm 2 [5/5] [UUUUU]
The “U”‘s at the end indicate which disks are UP in the Array if there are any “_” then that may indicate an issue with a disk not being available for the array.
Check the RAID Details with the following command:
sudo mdadm --detail /dev/<md#>
Check the RAID Devices with the following command:
sudo mdadm --examine /dev/sdXX
This should return the partitions Superblock info for the disk in the RAID array.
Check the Disk with smart mon tools
sudo smartctl -a /dev/sdX
Get the Serial Number of the Disk so you can ensure you are replacing the correct drive physically in the system
sudo lsblk -o NAME,MODEL,SERIAL,WWN,HCTL
To add your replacement disk back into the RAID Array
Copy a RAID disks partition config from an existing disk within the RAID using fdisk:
sudo fdisk /dev/sdX
"m" to dump disk layout
Enter filename
Then copy it over to the new disk
sudo fdisk /dev/<new Disk>
Print the partition table and copy the Disk Identifier
Load the disk layout from the previous step with
"I"
Enter the filename used when dumping the previous disk info.
Then change the Disk Identifier back to the original with
"x"
"i"
Enter the original Disk Identifier
Write the disk and exit the fdisk application
Add the disk back to the array:
sudo mdadm --add /dev/md# /dev/sdXX
Watch your RAID recover with:
watch -n 2 cat /proc/mdstat