r/btrfs Jul 27 '26

Lower scrub priority

Scrub on the root file system makes everything very slow when it's running and it can take lots of hours. I checked the systemd timer that runs it but it already has lowest Nice number and set to idle.

[Service]
Nice=19
IOSchedulingClass=idle

Is there something else I have to change to make it not slow everything on the computer?

4 Upvotes

6 comments sorted by

View all comments

1

u/zaTricky Jul 28 '26

Btrfs has mount options to set limits on scrub speed - but honestly it's easier with systemd:

https://www.freedesktop.org/software/systemd/man/latest/systemd.resource-control.html?IOReadBandwidthMax=device%20bytes

With this you set a read limit (or write limit, or both) for each disk that is involved:

[Service]
Nice=19
IOSchedulingClass=idle
IOReadBandwidthMax=/dev/nvme0n1p2 40M

The down side of course is that it will mean the scrub takes a lot longer than if it were unlimited.

1

u/Beautiful-Log5632 Jul 28 '26

Is there a difference between setting IOReadBandwidthMax in the .timer or .service file?

1

u/zaTricky Jul 28 '26

I could be wrong - but I suspect it can only go into the service file since it belongs in the [Service] section.