This is a repost of a question I asked on ServerFault and was automatically deleted for lack of activity. Let's hope it will have better luck here.
After performing a "check" (by writing
/sys/class/block/md0/md/sync_action) of a md software RAID array with redundancy on Linux, the
md subsystem will update the
/sys/class/block/md0/md/mismatch_cnt virtual file with the number of sectors comprised in chunks that have a mismatch.
Unfortunately, it doesn't tell which chunk or sector they are.
On a RAID 1 array with 2 drives (for instance md0 on sda and sdb), one can do:
blockdev --flushbufs /dev/md0 /dev/sda /dev/sdb cmp -l /dev/sda /dev/sdb > sda-sdb.diff
To find out which bytes differ, and then derive the sector and additional information (like which file is affected if there's a filesystem there).
But is there a way to get the same information for other RAID levels? For instance, with this RAID10 array:
$ cat /sys/class/block/md0/md/mismatch_cnt 4608 $ cat /proc/mdstat [...] md0 : active raid10 sdd1 sdc1 sdb1 sda1 3906763776 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]
How would I know where the mismatches are on
In this particular instance, the algorithm is not too complicated: we can use
mdadm -E to find out where the data starts in the devices, and then sda1 is meant to be the same as sdb1 and sdc1 the same as sdd1, the first chunk of /dev/md0 is found in the first chunk of both sda1 and sda2, the second in the first chunk of both sdc1 and sdd1, so given the offset of a byte difference in a pair of devices, it's not two difficult to find out the corresponding offset in the md device, but I was hoping there was a way to avoid have to run down the algorithm manually