Diary of an ex-GeeXboX developer…

QNAP RAID resyncing

Posted at — Aug 30, 2023

With the QNAP Web configurator, it’s easy to change the (re)syncing priorities from low, to medium or high priorities. But what does it mean? These settings affect the resync speed min and (possibly) max values. You can consider in the case of QNAP that only the min speed is changed. To increase the priority, it increases the min speed by following this table:

low (service first) medium (default) high (resync first)
min 1000 40000 500000
max 500000 500000 500000

The values are in KB/s. What happens when you set the high priority? It can be very difficult to return to the QNAP Web configurator. In this table you can see that the min value is set to 500 MB/s. It means that it tries to use as much as possible the hardware. I experienced these settings and it’s good only for a QNAP which is not used in production. So, maybe in this case we can use the default settings in production and everything would be fine. Sometimes it’s right, and sometimes it’s a problem too because the max value is always very high and it’s possible that in production you want the NAS to be more reactive.

In this article, you will learn how to change these settings without the QNAP Web configurator while the resyncing is already performing.

All steps to see and configure the priorities

Switch to SSH

I consider that you know SSH and you have activated SSH on the QNAP. If it’s not the case, it’s the first thing to do.

ssh admin@the.qnap.nas.ip

Forget the root account, QNAP uses admin for all the operations. Even if the QNAP is very busy, it’s (in my experiences) always possible to reach the console management via SSH.

Once you are connected, a menu appears and looks like:

  |  Console Management - Main menu                                |
  |                                                                |
  |  1: Show network settings                                      |
  |  2: System event logs                                          |
  |  3: Reset to factory default (password required)               |
  |  4: Activate/ deactivate a license                             |
  |  5: App management                                             |
  |  6: Reboot in Rescue mode (w/o configured disk)                |
  |  7: Reboot in Maintenance Mode                                 |
  |  Q: Quit (return to normal shell environment)                  |

Press the q keystroke because we want to go to the normal shell environment.

Dump the current status

Now that we have an admin prompt, what about the RAID? You can easily dump the status via the /proc virtual filesystem.

[~] # cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
md1 : active raid6 sdh3[13] sdg3[7] sde3[8] sda3[11] sdf3[12] sdd3[10] sdc3[9]
      87841850880 blocks super 1.0 level 6, 512k chunk, algorithm 2 [7/7] [UUUUUUU]
      [=========>...........]  resync = 45.5% (8009035776/17568370176) finish=3791.9min speed=76015K/sec

md322 : active raid1 sdh5[8](S) sdg5[4](S) sde5[5] sda5[7](S) sdf5[2] sdd5[3](S) sdc5[6](S)
      7235136 blocks super 1.0 [2/2] [UU]
      bitmap: 0/1 pages [0KB], 65536KB chunk

md256 : active raid1 sdh2[8](S) sdg2[4](S) sde2[5] sda2[7](S) sdf2[2] sdd2[3](S) sdc2[6](S)
      530112 blocks super 1.0 [2/2] [UU]
      bitmap: 0/1 pages [0KB], 65536KB chunk

md13 : active raid1 sdh4[25] sdg4[27] sde4[24] sda4[30] sdf4[29] sdd4[26] sdc4[28]
      458880 blocks super 1.0 [24/7] [UUUUUUU_________________]
      bitmap: 1/1 pages [4KB], 65536KB chunk

md9 : active raid1 sdh1[30] sdg1[27] sde1[24] sda1[28] sdf1[29] sdd1[26] sdc1[25]
      530048 blocks super 1.0 [24/7] [UUUUUUU_________________]
      bitmap: 1/1 pages [4KB], 65536KB chunk

In this dump, we see that it’s md1 which is resyncing with a current speed of 76 MB/s. Of course, the min value is set to 500 MB/s (we have set the high priority), then the resync follows this limit. The hardware is limited mostly by the magnetic harddisk capabilities and 76 MB/s seems to be the best possible speed here.

How to see the current speed settings for md1?

Just do it:

[~] # cat /sys/block/md1/md/sync_speed_min
500000 (local)

You can look the max speed is you want, just with sync_speed_max instead of sync_speed_min. Here it’s the current speed limit for this device only.

Fine but I want to reach the QNAP Web configurator

Reduce the min speed, and the Web GUI will works again. Because on Linux/Unix everything is file, just write the new limit for this device in order to drive the device.

echo 1000 > /sys/block/md1/md/sync_speed_min

This action is immediat, the minimal speed will be set to 1 MB/s. Now you can use the QNAP Web configurator as usual. Use cat /proc/mdstat in order to verify that the speed is changing.

Here we have not changed the max limit, then the speed can still be high if the QNAP is mostly “idle” for other operations.

OK, thank you and good bye

Please wait, it’s not finished. Of course, the system seems more usable but if your QNAP is used in production, it can still be a problem even with the low priority. The main reason is the max value which is always set to 500 MB/s. It’s very high and it means that the speed can be very low but very high too. In our case we have a virtual machine harddisk directly mounted via NFS. This virtual harddisk must be reachable everytime for the virtual machine. It’s not acceptable to have a max of 500 MB/s for the RAID resyncing. The solution is very simple, of course the resyncing will be longer (it’s not magic).

echo 20000 > /sys/block/md1/md/sync_speed_max

Now the max speed is limited to 20 MB/s. We are sure, that the RAID will be all the time between 1 MB/s and 20 MB/s. We can imagine to use a CRON job in order to change the value according to the daylight. Maybe the night we want more speed because the system is less stressed.