How to Identify Which Disk is Being Rebuilt in mdadm RAID1 Array During Resync Operation


4 views

When working with Linux software RAID (mdadm), the /proc/mdstat file provides crucial real-time information about array status. In your case, the output shows:

md1 : active raid1 sda2[0] sdb2[1]
  955789176 blocks super 1.0 [2/2] [UU]
  [==============>......]  resync = 72.2% (690357504/955789176) finish=4025.9min speed=1098K/sec

The key indicators here:

  • [2/2] means both devices are present
  • [UU] shows both devices are up
  • resync = 72.2% indicates an active resynchronization

To identify which disk is being rebuilt, we need to examine the device state more closely:

# mdadm --examine /dev/sda2
# mdadm --examine /dev/sdb2

The disk with the older Events count is the one being rebuilt. Compare the output from both devices - the one with fewer events is catching up.

Here's a complete diagnostic workflow:

# Check array status
cat /proc/mdstat

# Detailed array info
mdadm --detail /dev/md1

# Examine individual disks
mdadm --examine /dev/sda2 | grep -E "Events|Update"
mdadm --examine /dev/sdb2 | grep -E "Events|Update"

# Alternative method using smartctl
smartctl -i /dev/sda | grep -i serial
smartctl -i /dev/sdb | grep -i serial

The disk with:

  • Lower "Events" count in mdadm --examine output
  • Earlier "Update Time" in mdadm --detail

is the one being rebuilt. The resync process will continue until both disks have identical event counts.

For ongoing monitoring, consider these approaches:

# Continuous monitoring
watch -n 60 "cat /proc/mdstat"

# Detailed progress
watch -n 60 "mdadm --detail /dev/md1 | grep -A10 Resync"

# Speed adjustment (if needed)
echo 200000 > /proc/sys/dev/raid/speed_limit_min

After resync completes, verify both disks show identical status:

mdadm --detail /dev/md1 | grep -i events

Both should display the same event count, indicating full synchronization.


When working with Linux software RAID (mdadm), monitoring array health is crucial. The resync operation shown in your /proc/mdstat output indicates data synchronization between disks:

# cat /proc/mdstat
md1 : active raid1 sda2[0] sdb2[1]
  955789176 blocks super 1.0 [2/2] [UU]
  [==============>......]  resync = 72.2% (690357504/955789176) finish=4025.9min speed=1098K/sec

To determine which disk is being rebuilt, we need to look beyond basic status indicators. The output shows both disks as [UU] (Up,Up) but still resyncing. This suggests one of these scenarios:

  • A disk was temporarily removed/reconnected
  • An automatic recovery was triggered
  • The array was manually marked as needing sync

Use these commands to get detailed disk status:

# Check individual disk states
mdadm --examine /dev/sda2 | grep -E 'Events|State'
mdadm --examine /dev/sdb2 | grep -E 'Events|State'

# Compare event counts (lower count indicates rebuilding disk)
mdadm --examine /dev/sda2 | grep 'Events'
mdadm --examine /dev/sdb2 | grep 'Events'

# Check kernel messages for recent disk events
dmesg | grep -i sd[ab]

Here's how to interpret the output from mdadm --examine:

# Example output from healthy disk
/dev/sda2:
Events : 222
State : clean

# Example output from rebuilding disk
/dev/sdb2:
Events : 180
State : recovering

For continuous monitoring during rebuild:

watch -n 60 'cat /proc/mdstat; echo; mdadm --detail /dev/md1 | grep -A1 "Resync Status"'

Consider implementing these monitoring solutions:

# Simple monitoring script
#!/bin/bash
ARRAY=/dev/md1
THRESHOLD=1000 # KB/s

current_speed=$(grep -oP 'speed=\\K\\d+' /proc/mdstat)
if [ "$current_speed" -lt "$THRESHOLD" ]; then
    echo "Low resync speed detected: ${current_speed}KB/s" | mail -s "RAID Alert" admin@example.com
fi