Last time we discussed the block order of linux-mdraid.
How do you find out which block order your RAID has?
The simplest way requires a working RAID to test against. (Ray created a small (50MB) test-RAID for that). First we get the first few blocks from each raw disk:
for $disk in sda1 sdb1 sdc1 sdd1 ;do for $nr in 0 1 2 3 4;do dd if=/dev/$disk skip=$nr count=1 bs=16k of=B.$disk.$nr done done dd if=/dev/md0 bs=16k count=20 of=RAID
Note that this assumes your stripe-size is 16k. If you know it is different, change it, if not you will find out later and have to retry with an adjusted value.
Now try to match up the first block with the RAID contents like this:
cat B.sda1.0 | cmp - RAID
If the block matches, you will get:
cmp: EOF on stdin
If the block is the wrong one:
stdin RAID differ: char 1, line 1
If none of your first blocks (the files ending with .0) match, either your block-size is too big (try again with half the previous size) or your RAID prefixes the disks with some internal bookkeeping info (in that case you can try to start with later blocks)
Now try to match the next blocks by adding then one by one to the cat command line like this:
cat B.sda1.0 B.sdb1.0 | cmp - RAID
that way you will easily recover the block allocation order of your RAID.
For example our linux-mdraid starts like this:
cat B.sda1.0 B.sdb1.0 B.sdc1.0 B.sdd1.1 B.sda1.1 ...
After that, its only a two-line patch to raidextract to fix that – hope you know C ;-)
That concludes our intermission for today. Tomorrow we will see why all this work wasn't even necessary.