Optimize Linux SW RAID rebuild speed

Change minimum rebuild speed:

By default Linux SW RAID minimum rebuild speed is quite low by today’s storage standard. Regular mechanical HDD easily performs 50MB+ and a SSD easily performs between 250-500MB. The default RAID rebuild minimum speed is 1MB and maximum is 200MB.

While the maximum rebuild speed is fine but the minimum speed isn’t. Let’s increase the minimum rebuild speed to 50MB. But keep in mind by raising the speed it might tax the overall system usage a little higher.

sysctl -w dev.raid.speed_limit_min=50000

You can also hard set this value in /etc/sysctl.conf file so persists between reboots.

dev.raid.speed_limit_min = 50000


Set Bitmap:

Bitmap optimizes rebuild time. Turn it on during rebuild and turn it off after rebuild.

Turn on:

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

Turn off:

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


Disable NCQ:
echo 1 > /sys/block/sda/device/queue_depth

If you have like five disks (sda, sdb, sdc, sdd, sde) you can run a for loop.

for v in sd{a..e}; do echo 1 > /sys/block/$i/device/queue_depth; done



Set readahead to 512-byte sectors.

blockdev --setra 65536 /dev/md0


Stripe cache size:

Only available on RAID-5 or RAID-6 configuration.

This cache is used when synchronizing both read and write operations. Default is 256KB. Maximum is 32MB. If you have enough memory just set to max.

echo 32768 > /sys/block/md0/md/stripe_cache_size

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.