Course contentsShow
← Linux
Lesson 690 of 1,8197. Storage Management and Logical VolumesFree lesson

RAID rebuild priority management

Tune rebuild bandwidth to prevent performance degradation during array recovery.

In this lesson, you will learn how to balance your server's performance against the urgency of a RAID array recovery by tuning rebuild bandwidth.

When a drive in your mdadm RAID array fails and is replaced, the system automatically begins a "rebuild" (or resync) process to recreate the missing data on the new disk. By default, Linux prioritizes this rebuild to ensure your data is protected as quickly as possible. However, this consumes significant disk I/O, which can make your actual applications—like databases or web servers—crawl to a halt.

To manage this, you can adjust the "sync speed" limits. These parameters tell the kernel how much bandwidth the rebuild process is allowed to consume.

Adjusting Sync Speeds

The kernel provides two key settings in /proc/sys/dev/raid/ to manage this:

  • speed_limit_min: The minimum speed (in KiB/s) the rebuild will maintain, even if it impacts system performance.
  • speed_limit_max: The maximum speed (in KiB/s) the rebuild will reach, ensuring it never fully saturates your disk throughput.

You can check your current limits with:

cat /proc/sys/dev/raid/speed_limit_max

If you notice your applications lagging during a rebuild, you can temporarily lower the maximum speed:

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

(This limits the rebuild to 50 MB/s, leaving more headroom for your services.)

Conversely, if the system is currently idle and you want the rebuild to finish immediately, you can raise the limit:

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

Why tune this?

If your RAID array is hosting a high-traffic production database, setting a very high speed_limit_max might cause timeouts for your users because the disk heads are busy copying rebuild data instead of serving requests. By setting a conservative maximum, you ensure that the rebuild process acts as a "background task," utilizing only the I/O that your applications aren't currently using. Always remember that slowing down the rebuild increases the time the array remains in a "degraded" state, meaning you are more vulnerable if a second drive fails during the recovery.

Key Takeaway: Use /proc/sys/dev/raid/speed_limit_max to throttle rebuild speeds, effectively balancing the risk of an extended recovery window against the immediate need for system performance.