mdadm has a function that can ensure this even without having to rebuild the raid.
Before you can start you always have to make sure that everything is save for the present:
root@nas34 cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] md42 : active raid5 sdd sdb sda sde 4395411456 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]
If everything looks just fine, as above, we would not have to be concerned, if there would not be the risk of bad blocks because they have the characteristic that they become conspicuous only if there are read or write actions performed to them. For ensuring that the array act correct we are going to perform a manual check:
echo check >/sys/block/md42/md/sync_action
Now we have to check that the “check” we have just sent to /sys/block/md42/md/sync_action produces an effect:
cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] md42 : active raid5 sdd sdb sda sde 4395411456 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU] [>....................] check = 0.0% (23564/1465137152) finish=500.0min speed=63564K/sec
Alright! The action has been started. If the Raid does not show any errors:
cat /sys/block/md42/md/mismatch_cnt 0
and does not suddenly start to rebuild we can grant that it is stable and start with the proper work, without being concerned that one of the disk could be damaged any way.
If you want to you can cancel the procedure by sending ‘idle’ to /sys/block/md42/md/sync_action:
echo idle >/sys/block/md42/md/sync_action