Mdadm: stopping and starting RAID check in Linux

From lxadm | Linux administration tips, tutorials, HOWTOs and articles
Jump to: navigation, search

Linux distributions like Debian or Ubuntu with software RAID (mdadm) run a check once a month (as defined in /etc/cron.d/mdadm).

To check if a test is running, do:

# cat /proc/mdstat                                       
Personalities : [raid1] [raid10] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] 
md2 : active raid5 sdd3[4] sdb3[1] sdc3[2] sda3[0]
      17500952064 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]
      
md0 : active raid1 sdd1[3] sdb1[1] sdc1[2] sda1[0]
      523712 blocks super 1.2 [4/4] [UUUU]

md1 : active raid10 sdd2[3] sdb2[1] sdc2[2] sda2[0]
      52396032 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]
      [>....................]  check =  0.0% (1536/52396032) finish=9565.1min speed=90K/sec


As you can see, it is running, with 90K/sec speed (very overloaded array).

To cancel a running test, use:

# echo idle > /sys/devices/virtual/block/md1/md/sync_action

Confirm with "cat /proc/mdstat" after that if the check didn't start on a different array.


To start a check manually, do:

# echo check > /sys/devices/virtual/block/md1/md/sync_action


Some older kernels may have "sync_action" located elsewhere, i.e. /sys/block/md0/md/sync_action.


Below ones will find the files where you can start/stop the array check:

# find /sys -name sync_action
/sys/devices/virtual/block/md2/md/sync_action
/sys/devices/virtual/block/md0/md/sync_action
/sys/devices/virtual/block/md1/md/sync_action

# find /sys -name sync_action|xargs cat
check
idle
check