How to re-add a drive when RAID is in degraded mode?
Adding Back a RAID 1 Member
To add a RAID member back into the array, use:
mdadm <RAID Device> -a <Device to add into the array>
For example:
$ mdadm /dev/md0 -a /dev/sdc1
mdadm: re-added /dev/sdc1
If you check again using mdadm --detail , you'll see that /dev/sdc1 is shown as "rebuilding":
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
2 8 33 1 spare rebuilding /dev/sdc1
This means that the newly added member is being synchronised with the data on the other member; if you now check proc/mdstat, you can see the synchronisation progress - as a percentage and a bar chart:
$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdc1[2] sdb1[0]
976759936 blocks [2/1] [U_]
[>....................] recovery = 1.2% (12409024/976759936) finish=195.2min speed=82312K/sec
unused devices: <none>
Verify that you can still see your files on the RAID drive following the addition of the new RAID member:
$ ls /mnt/raid1
Music lost+found Images Films Misc
I solved my own issue. I did not understand that mdX are partitions and sda and sdb are actual physical discs. So sdb was missing, so I needed to add it back. I executed the following commands:
sgdisk -R /dev/sdb /dev/sda
sgdisk -G /dev/sdb
mdadm /dev/md0 -a /dev/sdb1
mdadm /dev/md1 -a /dev/sdb2
mdadm /dev/md2 -a /dev/sdb3
mdadm /dev/md3 -a /dev/sdb4
After a day of resync (can be observed with)
cat /proc/mdstat
What I see today looks good again:
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md3 : active raid1 sdb4[2] sda4[0]
1839089920 blocks super 1.2 [2/2] [UU]
md1 : active raid1 sdb2[2] sda2[0]
523968 blocks super 1.2 [2/2] [UU]
md2 : active raid1 sdb3[2] sda3[0]
1073610560 blocks super 1.2 [2/2] [UU]
md0 : active raid1 sdb1[2] sda1[0]
16768896 blocks super 1.2 [2/2] [UU]