r5test: RAID 5 recovery utility

r5test is a program I hacked together to recover from accidentally wiping out the metadata of a RAID 5 on a 3ware controller. r5test is not a polished program, and is not easy to use. Accomplishing anything worthwhile with it will require a detailed understanding of how RAID 5 works, many hours of experimentation, and probably even study of the r5test source code. Improper use of r5test could easily corrupt the very data one is trying to recover. I am making r5test available because there is some small chance that it might be helpful to someone who is in a situation similar to mine.

There is no real documentation for r5test. Here is an example sequence of r5test commands that creates a set of files containing pseudorandom test data in a RAID 5 organization, extracts the data from the RAID 5 into a single file, then verifies that the pseudorandom test data was extracted correctly:


r5test wr5t -c 2000 foo1 foo2 foo3 foo4

r5test extract -c -1 foo1 foo2 foo3 foo4 foo

r5test rt -c -1 foo

The first command, "wr5t", writes pseudorandom data to a RAID 5. The "-c 2000" tells it to write 2000 stripes. For other possible arguments, invoke r5test with no command to get the usage message. foo1 through foo4 are the RAID 5 "devices"; in this example they are files, but hardware devices or partitions work equally well.

The second command extracts an image of the RAID 5 into a single file, verifying the parity. The "-c -1" (count of negative one) tells it to continue until the end of a file, or an error. foo1 through foo4 are the source devices. The last file on the comamnd line, foo, is the destination. For recovery from an actual set of RAID 5 disks, the source files would normally be the hardware devices, i.e., /dev/sda etc.

The third command verifies the pseudorandom data.

The default seetings seem to be correct for a RAID 5 as created by a 3ware RAID controller with default parameters. They may not match other 3ware RAID 5 configurations, or RAID 5 sets as created by any other controller or software. Adjusting the settings may be useful, but it may also be necessary to edit the source code, e.g., if the rotation of the parity is different.

It should be noted that one thing r5test WILL NOT do for you is determine the order of the RAID devices. It can't even tell you if you've got the order right. Doing this requires manually studying the contents of the drive (e.g., by a hex dump), and possibly trying various permutations. Typically two drives out of a RAID 5 set will have a block zero that looks like the master boot record; one of those two drives contains the actual stripe 0 data, and the other is the first parity stripe.

If you have a small number of drives, it may be easiest to try all the permutations. With four drives, there are 24 permutations possible, though if you determine which drives appear to have a valid MBR, you can reduce that to four permutations. For each permutation, run an "r5test extract", then try mounting partitions in the resulting file via the loopback device, with the read-only option. The correct permutation will mount with few or no errors, while an incorrect permutation will normally report many errors.


Download

r5test is made available under the terms of the Free Software Foundation's General Public License, Version 3.

Source code is available for download.


Last updated May 18, 2008

Copyright 2008 Eric Smith

eric@brouhaha.com

hacker emblem
Best Viewed With Any Browser Valid HTML 4.01! Valid CSS!

check now

check now