NOTE: these directions shouldn't be used. This was me screwing around before I read about what else is in /sys/block/md?/md/.
In particular, after a check, the mismatch_cnt will be updated: if it's nonzero, it means there is mismatching data somewhere.


How to check data integrity on an mdadm raid-1 array

Note that echo "check" > /sys/block/md?/md/sync_action does not do any comparison of array data -- for an array consistning of /dev/sda1 and /dev/sdb1, it does the equivalent of:

dd if=/dev/sda1 > /dev/null
dd if=/dev/sdb1 > /dev/null

i.e., it will notice if the drive returns a read error, but it won't notice if the data on sda1 differs from that on sdb1.

There appears to be no data comparison capability in mdadm, so you have to do it yourself. But, the data on two members of a RAID1 will not be identical, because the RAID superblocks will differ (i.e., each member's superblock has data that says "I am device number X from this array"). So, you want to compare all the data that *isn't* superblock. The way to do this and exclude the superblocks is to get the size from mdadm --detail on your array.

Then divide the size by 64 (since mdadm arrays work in 64K blocks). for a 0.90 array, this number is all you need; you can then do something like:

dd if=/dev/sda1 bs=64K count=(array size in 64K blocks) | md5sum
dd if=/dev/sdb1 bs=64K count=(array size in 64K blocks) | md5sum

(in 0.90 arrays, the superblock data is at the end, so by taking the data size of the array as above, you omit the last couple blocks with the superblocks).

For 1.2 superblock arrays, the chunk size and offset is variable. use mdadm -E /dev/sda1 to see what it is for your particular array, then md5sum the stuff after the superblock.

dd if=/dev/sda1 bs=(chunk size) count=(number of chunks) | md5sum
dd if=/dev/sdb1 bs=(chunk size) count=(number of chunks) | md5sum