Last active
July 5, 2022 07:20
-
-
Save ricco386/4dd6cae0ad4e0397a5ba7a1e4b5b1f6d to your computer and use it in GitHub Desktop.
Systemd timer for BTRFS Scrub. Usage: systemctl enable btrfs-scrub@pictures.timer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/conf.d/btrfs-scrub-pictures | |
mountpoint=/data/pictures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/systemd/system/btrfs-scrub@.service | |
[Unit] | |
Description=Scrub BTRFS filesystem (%i), check volume for errors | |
Documentation=man:btrfs-scrub | |
# After=fstrim.service | |
[Service] | |
Type=oneshot | |
EnvironmentFile=/etc/conf.d/btrfs-scrub-%i | |
ExecStart=/usr/sbin/btrfs scrub start -B $mountpoint | |
IOSchedulingClass=idle | |
CPUSchedulingPolicy=idle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/systemd/system/btrfs-scrub@.timer | |
[Unit] | |
Description=Trigger BTRFS scrub on filesystem (%i) | |
[Timer] | |
OnCalendar=monthly | |
Persistent=true | |
[Install] | |
WantedBy=timers.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Benjaminrenz the reason for this behavior is that the service uses
Type=oneshot
(the service will be in the activation state unil the command exits, the start command will wait for activation to complete).Removing that directive will use the default
simple
type (which IMO is more correct). Removing the-B
will allow the service to be started multiple times without the scrub compleng (which will cause the service to fail).