Many Linux administrators encounter situations where scheduled RAID resync operations interfere with system performance during business hours. The default behavior in Debian-based systems (including Squeeze) can be particularly aggressive, with multiple arrays attempting to resync simultaneously during maintenance windows.
When you need to immediately halt an active resync operation:
# First try graceful stop
echo idle > /sys/block/mdX/md/sync_action
# If that fails, use this nuclear option (requires kernel 2.6.29+)
echo frozen > /sys/block/mdX/md/sync_action
Note that simply killing the mdX_resync process (as mentioned in the original question) won't work because the operation is kernel-level.
For temporary performance throttling:
# Set very slow resync speed (in KB/s)
echo 1000 > /proc/sys/dev/raid/speed_limit_max
# Or alternatively:
sysctl -w dev.raid.speed_limit_max=1000
To modify the scheduled check interval:
# Check current settings
cat /proc/sys/dev/raid/speed_limit_min
cat /proc/sys/dev/raid/speed_limit_max
# Make permanent changes in /etc/sysctl.conf
echo "dev.raid.speed_limit_min = 10000" >> /etc/sysctl.conf
echo "dev.raid.speed_limit_max = 100000" >> /etc/sysctl.conf
For precise scheduling control, consider this cron approach:
# /etc/cron.d/raid-maintenance
# Pause resync during business hours
0 8 * * 1-5 root echo frozen > /sys/block/md0/md/sync_action
# Resume at night
0 20 * * 1-5 root echo idle > /sys/block/md0/md/sync_action
To monitor progress and scheduled checks:
# Check current resync status
cat /proc/mdstat
# View next scheduled check (requires mdadm 3.2.5+)
mdadm --examine --scan | grep -o "check=[^ ]*"
# Estimate remaining time
watch -n 60 "cat /proc/mdstat | grep -A1 resync"
While interrupting resync is possible, be aware that:
- Array growth operations are blocked during resync
- Some RAID levels may require complete sync cycles for data consistency
- Frequent interruptions may lead to degraded performance
When dealing with Linux software RAID (mdadm), scheduled resync operations can sometimes interfere with system performance or other maintenance tasks. Unlike emergency rebuilds after disk failures, these are routine consistency checks that run periodically.
Attempting to kill the resync process directly (like with kill -9
) is ineffective because:
# This won't stop the resync
sudo kill -9 $(pgrep md.*_resync)
The kernel automatically restarts these processes as they're managed at a lower system level.
Method 1: Using sysctl to Throttle Speed
The most graceful approach is to dramatically slow down the resync:
# Set extremely low speed limit
sudo sysctl -w dev.raid.speed_limit_max=1000
This makes the operation effectively pause while technically remaining active.
Method 2: Using mdadm Directly
For a complete stop, use mdadm's built-in controls:
# Check current sync status
cat /proc/mdstat
# Stop resync on specific array
sudo mdadm --manage /dev/mdX --stop
To modify when resyncs occur:
# Check current check interval
cat /sys/block/mdX/md/check_interval
# Set new interval (in seconds)
echo 604800 > /sys/block/mdX/md/check_interval # 7 days
For automated control, create a script like:
#!/bin/bash
# Pause resync during business hours
if [[ $(date +%u) -eq 7 && $(date +%H) -ge 8 && $(date +%H) -lt 20 ]]; then
echo 1000 > /proc/sys/dev/raid/speed_limit_max
else
echo 200000 > /proc/sys/dev/raid/speed_limit_max
fi
- Never interrupt a rebuild after disk failure
- Monitor
/proc/mdstat
for operation status - Consider using
ionice
for better I/O prioritization