Sunday, February 13, 2011

Restore drives that have been erroneously marked as failed in a Raid 5/6 array

Transferred from my old blog.

You have a raid5/6 array (/dev/md0) in which one or more drives have been marked as failed. For instance, I had a motherboard problem in my server recently which would cause my esata controller to spontaneously reset ports and knock 3-4 drives off my array at a time, putting the array in a failed state. All is lost, yes? No! Since in my scenario the array immediately fails upon having more than two drives disappear (this is a raid6 array), no data has changed on the actual file system, you can use the following command to force reassemble the drive. If possible, mdadm will up the event count on the “failed” drive(s) and clear the faulty flag for it. NOTE: Be careful with this, if a given drive was knocked out of your array before a modification to your array (i.e. writing to the array or an array reshape), this can cause massive, non-recoverable data corruption. Only do this if you are SURE that your array contents has not been changed/written to between the time these one or more drives were removed from your array and now.

If you have filled out mdadm.conf with your array and corresponding drives:

mdadm -Af /dev/md0

If you do not have mdadm.conf filled out and rely on mdadm auto assembling your array upon start up, use the following:

mdadm -Af /dev/md0

Where devices is replaced by the drives that make up your array, example:

mdadm -Af /dev/md0 /dev/sd[b-d] /dev/sd[h-o]

No comments:

Post a Comment