Speed up Synology SHR rebuild

One of the hard drives in my Synology DS1513+ crashed overnight. I replaced it, but the rebuild is going so slowly!

SSH into your DiskStation. To view the status of your rebuild:

$ cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4]
md2 : active raid5 sdd5[6] sda5[5] sde5[7] sdc5[2] sdb5[1]
      7795118592 blocks super 1.2 level 5, 64k chunk, algorithm 2 [5/4] [UUU_U]
      [=>...................]  recovery =  5.2% (103271424/1948779648) finish=672.9min speed=45708K/sec

Initially, the rebuild speed is 45708 Kb/sec (~45 Mb/sec), with an estimated completion time of 670 minutes, or 11 hours so so.

We can go faster!

RAID rebuilds are speed limited. The default minimum and maximum speeds are, in Kb/sec:

$ cat /proc/sys/dev/raid/speed_limit_max # maximum speed
200000
$ cat /proc/sys/dev/raid/speed_limit_min
1000

Let’s increase that minimum speed a touch:

$ sudo su
# echo 50000 > /proc/sys/dev/raid/speed_limit_min

And see if we’re going any faster:

# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4]
md2 : active raid5 sdd5[6] sda5[5] sde5[7] sdc5[2] sdb5[1]
      7795118592 blocks super 1.2 level 5, 64k chunk, algorithm 2 [5/4] [UUU_U]
      [=>...................]  recovery =  7.3% (142689152/1948779648) finish=543.4min speed=55388K/sec

Yeah, it’s a little faster – up to 55 Mb/sec with an estimated completion two hours sooner.

# echo 100000 > /proc/sys/dev/raid/speed_limit_min
# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4]
md2 : active raid5 sdd5[6] sda5[5] sde5[7] sdc5[2] sdb5[1]
      7795118592 blocks super 1.2 level 5, 64k chunk, algorithm 2 [5/4] [UUU_U]
      [=>...................]  recovery =  8.4% (163878932/1948779648) finish=356.4min speed=83448K/sec

I played around, and with a speed_limit_min value of 100000, we hit a bottleneck and max out at about 85 Mb/sec, but thats pretty much twice as fast as we were going. Not bad. (Note to self: return to default value when the rebuild is finis