WARNING: mismatch_cnt is not 0 on /dev/md0

I was about to head to bed when I receive a disturbing email from my BlackBerry phone.

A email from weekly cron.d send me this:

WARNING: mismatch_cnt is not 0 on /dev/md0

A quick command shows that the RAID array (md0) is the number of
unsynchronized blocks in the raid.

As you can see below, md0 is having 128 count of unsynchronized blocks.

[svr4:/root]# cat /sys/block/md0/md/mismatch_cnt
128
[svr4:/root]# cat /sys/block/md1/md/mismatch_cnt
0

Let’s attempt to fix it.

a) Let’s tell the raid to attempt a repair.

echo repair /sys/block/md0/md/sync_action

b) The raid should be rebuilding itself now.

cat /proc/mdstat
md0 : active raid1 sdb1[1] sda1[0]
4192896 blocks [2/2] [UU]
[...................]  resync =  5.6% (236352/4192896) finish=0.5min speed=118176K/sec

c) Let’s tell the raid to check the health again.

echo "check" > /sys/block/md0/md/sync_action

d) Let’s see the count again and see if it still mis-match

cat /sys/block/md0/md/mismatch_cnt

It should show as below:

[svr4:/root]# cat /sys/block/md0/md/mismatch_cnt
0

Great! It is back to normal health. I can head to bed now.

Hope this helps someone out there!