๐Ÿš€ Speed Up Software RAID Sync (RAID 1, 5, 6, 10) on Linux

This guide focuses on optimizing mdadm software RAID performance during resync, rebuild, or reshape operations on AlmaLinux / CloudLinux 9, or any recent systemd-based Linux OS.


๐Ÿ”ง 1. Boost Resync Speeds via sysctl

Applies to: RAID 1, 5, 6, 10

Raise the minimum sync speed (default: 1000 KB/s):

echo 50000 > /proc/sys/dev/raid/speed_limit_min
echo 200000 > /proc/sys/dev/raid/speed_limit_max

To persist across reboots:

cat <<EOF > /etc/sysctl.d/99-raid-speed.conf
dev.raid.speed_limit_min = 50000
dev.raid.speed_limit_max = 200000
EOF

sysctl --system

๐Ÿ“ฆ 2. Increase Disk Readahead

Applies to: RAID 1, 5, 6, 10

Improves sequential disk I/O during rebuild.

for dev in /dev/md*; do
  blockdev --setra 65536 "$dev"
done

Repeat for physical disks (e.g., /dev/sd[a-z]).

To persist:

  • Add to /etc/rc.d/rc.local or a custom systemd service.

๐Ÿ“Š 3. Tune stripe_cache_size (RAID 5/6 only)

Applies to: RAID 5, 6

(Not used by RAID 1 or 10)

echo 16384 > /sys/block/md0/md/stripe_cache_size
  • Acceptable range: 17โ€“32768
  • Each unit = 1 page (~4 KB)
  • Larger values = faster rebuilds but more RAM

Check current value:

cat /sys/block/md0/md/stripe_cache_size

Persist with a systemd override or /etc/rc.local.


๐Ÿง  4. Enable Bitmap Indexing

Applies to: RAID 1, 5, 6, 10

Bitmaps accelerate resync after unclean shutdowns by tracking changed blocks.

mdadm --grow --bitmap=internal /dev/md0

To disable:

mdadm --grow --bitmap=none /dev/md0

๐Ÿงต 5. Tune Resync Threads (Optional)

Applies to: RAID 5, 6, 10 (not RAID 1)

You can increase the number of active threads used during resync:

echo 8 > /sys/block/md0/md/group_thread_cnt

Default is typically 1. Use 4โ€“16 depending on CPU cores and load.


โŒ 6. Disable NCQ on Disks (May Help with SATA Drives)

Applies to: All RAID types

for d in /sys/block/sd*/device/queue_depth; do
  echo 1 > "$d"
done

Do not apply on SSDs or enterprise NVMe drives unless advised by the vendor.


๐Ÿ”„ 7. Monitor Rebuild or Resync Progress

cat /proc/mdstat

Example output:

md0 : active raid5 sdc1[2] sdb1[1] sda1[0]
      976630464 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
      [>....................]  resync =  4.0% (39208960/976630464) finish=90.5min speed=172999K/sec

๐Ÿงฐ 8. Per-RAID-Level Summary

RAID LevelRelevant Tweaks
RAID 1speed_limit_*, bitmap, readahead, optional NCQ disable
RAID 5All of above + stripe_cache_size, optional thread tuning
RAID 6Same as RAID 5; may benefit more from thread tuning due to dual parity overhead
RAID 10speed_limit_*, bitmap, readahead, optional thread tuning (depends on layout), rarely needs stripe cache

๐Ÿ’ก 9. Optional: Auto-apply with Systemd (e.g. md-raid-boost.service)

Create /etc/systemd/system/md-raid-boost.service:

[Unit]
Description=RAID Speedup Tweaks
After=local-fs.target

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/md-raid-boost.sh
RemainAfterExit=true

[Install]
WantedBy=multi-user.target

Then create /usr/local/sbin/md-raid-boost.sh:

#!/bin/bash
sysctl -w dev.raid.speed_limit_min=50000
sysctl -w dev.raid.speed_limit_max=200000

for dev in /dev/md*; do
  blockdev --setra 65536 "$dev"
  [ -f /sys/block/$(basename $dev)/md/stripe_cache_size ] && echo 16384 > /sys/block/$(basename $dev)/md/stripe_cache_size
done

for d in /sys/block/sd*/device/queue_depth; do
  echo 1 > "$d"
done

Make executable:

chmod +x /usr/local/sbin/md-raid-boost.sh
systemctl enable --now md-raid-boost

๐Ÿ“˜ References

Scroll to Top