Manually Starting or Stopping a RAID check in Linux

If you want to manually start or stop a RAID consistency check in Linux it’s quite simple.

Starting a check on md0:

root@desktop:~# echo check > /sys/block/md0/md/sync_action

Stopping a check on md0:

root@desktop:~# echo idle > /sys/block/md0/md/sync_action

If you’re using Debian (or a Debian based distro, e.g. Ubuntu), there is a script to do this.

root@desktop:~# /usr/share/mdadm/checkarray -h
checkarray -- MD array (RAID) redundancy checker tool
Copyright © martin f. krafft <[email protected]>
Released under the terms of the Artistic Licence 2.0
 
Usage: checkarray [options] [arrays]
 
Valid options are:
-a|--all check all assembled arrays (ignores arrays in command line).
-s|--status print redundancy check status of devices.
-x|--cancel queue a request to cancel a running redundancy check.
-i|--idle perform check in a lowest scheduling class (idle)
-l|--slow perform check in a lower-than-standard scheduling class
-f|--fast perform check in higher-than-standard scheduling class
--realtime perform check in real-time scheduling class (DANGEROUS!)
-c|--cron honour AUTOCHECK setting in /etc/default/mdadm.
-q|--quiet suppress informational messages
(use twice to suppress error messages too).
-h|--help show this output.
-V|--version show version information.
 
Examples:
checkarray --all --idle
checkarray --quiet /dev/md[123]
checkarray -sa
checkarray -x --all
 
Devices can be specified in almost any format. The following are equivalent:
/dev/md0, md0, /dev/md/0, /sys/block/md0
 
You can also control the status of a check with /proc/mdstat file.

 
 
Update on 2017-09-11:
When you echo “idle” to “sync_action”, the raid check will stop, but may immediately restart.
If this is happening, try echoing “frozen” to “sync_action” instead. This will stop the check and prevent it from restarting.

root@desktop:~# echo frozen > /sys/block/md0/md/sync_action

This will stop the check, but still leave the array in a partially checked state. You can safely leave it in this state. The next time a check starts, it will start from where it left off.
If you want the next consistency check to check the whole array (and not just resume from where it left off last time), you can do this:

root@desktop:~# echo none > /sys/block/md0/md/resync_start
root@desktop:~# echo idle > /sys/block/md0/md/sync_action

Echoing “none” to “resync_start” tells it that no resync is needed right now. The next time it starts, it will start at the beginning of the array.
I first saw this on a forum post at 45drives.com. Kudos to “kevin” for sharing this.
 
 
For more information, please see the (almost always) wonderful Arch wiki article on RAID.
There’s also an md admin guide that’s part of the kernel. This seems more useful as a reference for what the sysfs entries mean than as a proper guide. I’d start with the Arch wiki.

Author: Voxel@Night

Comments

  1. After using
    echo frozen > /sys/block/md0/md/sync_action
    I didn’t know what to do to continue the sync so I used
    echo check > /sys/block/md0/md/sync_action
    But the speed went from 90,000k to 133k

Leave a Reply