Last modified: 2012-04-16
I have a RAID1 setup with two drives. Once I booted my system up, the other drive dropped (because of the motherboard, the drive is fine), and thus later the timestamps in the headers didn't match anymore, and my array assembly failed. I knew which drive dropped, so I just wanted to assemble the array with the clean drive, add the one that dropped, and resync. It's easy if you know the exact commands. However, the man pages of mdadm are impossible as always, and quick searching turned up lots of irrelevant stuff. This text tells how to accomplish this simple task.
I assume here that the system has only one raid array called /dev/md1, and that proper assembly information is written into /etc/mdadm.conf. If you have more than one raid array, just repeat these steps for each one.
First you need to stop the arrays as mdadm might have started them as inactive.
# mdadm --stop /dev/md1
After this you need to decide which drive is clean by examining the timestamps etc. Here I assume that /dev/md1 consists of /dev/sda1 and /dev/sdb1.
# mdadm --examine /dev/sda1
State : clean
Device UUID : ccc1bd2e:e9c06272:68c4c975:4d5472d8
Update Time : Sun Apr 15 23:16:52 2012
# mdadm --examine /dev/sdb1
State : active
Device UUID : 9ee945c1:d6a5aba0:6adcd926:b5ff9ac5
Update Time : Mon Apr 16 17:16:26 2012
As one immediately observes, the latter drive was the one that dropped during boot because it's marked as active, as the other one is clean. Thus we need to assemble the array using only the clean one /dev/sda1. If you have more drives in your array, obviously repeat this examination for every drive.
Notice: We are about to resync /dev/sdb1, double verify that you are resyncing the correct drive. Resyncing the wrong drive may result in data corruption.
Next we start the array with only /dev/sda1.
# mdadm --assemble /dev/md1 --force /dev/sda1
mdadm: /dev/md1 has been started with 1 drive (out of 2).
It's good time to mount /dev/md1, and verify that everything is correct. Then finally we re-add /dev/sdb1.
# mdadm --manage /dev/md1 --add /dev/sdb1
mdadm: re-added /dev/sdb1
After this mdadm should be resyncing /dev/sdb1. To verify this, and to follow the progress, run the following:
# cat /proc/mdstat
After the syncing has finished, the order is hopefully once again restored.