diff options
author | Georgy Yakovlev <[email protected]> | 2021-12-16 11:47:22 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2021-12-16 11:47:22 -0800 |
commit | 2300621dc7450adccf86ddbf397c72f8e5e2d76c (patch) | |
tree | da579686a40650ff2849da4ea9d9b0278c190eec /etc | |
parent | f291fa658efd146540b03ce386133632bde237bf (diff) |
systemd: add weekly and monthly scrub timers
Timers can be enabled as follows:
systemctl enable [email protected] --now
systemctl enable [email protected] --now
Each timer will pull in zfs-scrub@${poolname}.service, which is not
schedule-specific.
Added PERIODIC SCRUB section to zpool-scrub.8.
Reviewed-by: Richard Laager <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Georgy Yakovlev <[email protected]>
Closes #12193
Diffstat (limited to 'etc')
-rw-r--r-- | etc/systemd/system/.gitignore | 1 | ||||
-rw-r--r-- | etc/systemd/system/Makefile.am | 5 | ||||
-rw-r--r-- | etc/systemd/system/[email protected] | 12 | ||||
-rw-r--r-- | etc/systemd/system/[email protected] | 12 | ||||
-rw-r--r-- | etc/systemd/system/[email protected] | 14 |
5 files changed, 43 insertions, 1 deletions
diff --git a/etc/systemd/system/.gitignore b/etc/systemd/system/.gitignore index efada54ad..4813c65a2 100644 --- a/etc/systemd/system/.gitignore +++ b/etc/systemd/system/.gitignore @@ -1,3 +1,4 @@ *.service *.target *.preset +*.timer diff --git a/etc/systemd/system/Makefile.am b/etc/systemd/system/Makefile.am index c374a52ac..5e65e1db4 100644 --- a/etc/systemd/system/Makefile.am +++ b/etc/systemd/system/Makefile.am @@ -12,7 +12,10 @@ systemdunit_DATA = \ zfs-volume-wait.service \ zfs-import.target \ zfs-volumes.target \ - zfs.target + zfs.target \ SUBSTFILES += $(systemdpreset_DATA) $(systemdunit_DATA) diff --git a/etc/systemd/system/[email protected] b/etc/systemd/system/[email protected] new file mode 100644 index 000000000..903068468 --- /dev/null +++ b/etc/systemd/system/[email protected] @@ -0,0 +1,12 @@ +[Unit] +Description=Monthly zpool scrub timer for %i +Documentation=man:zpool-scrub(8) + +[Timer] +OnCalendar=monthly +Persistent=true +RandomizedDelaySec=1h +Unit=zfs-scrub@%i.service + +[Install] +WantedBy=timers.target diff --git a/etc/systemd/system/[email protected] b/etc/systemd/system/[email protected] new file mode 100644 index 000000000..ede699500 --- /dev/null +++ b/etc/systemd/system/[email protected] @@ -0,0 +1,12 @@ +[Unit] +Description=Weekly zpool scrub timer for %i +Documentation=man:zpool-scrub(8) + +[Timer] +OnCalendar=weekly +Persistent=true +RandomizedDelaySec=1h +Unit=zfs-scrub@%i.service + +[Install] +WantedBy=timers.target diff --git a/etc/systemd/system/[email protected] b/etc/systemd/system/[email protected] new file mode 100644 index 000000000..bebe91d74 --- /dev/null +++ b/etc/systemd/system/[email protected] @@ -0,0 +1,14 @@ +[Unit] +Description=zpool scrub on %i +Documentation=man:zpool-scrub(8) +Requires=zfs.target +After=zfs.target +ConditionACPower=true +ConditionPathIsDirectory=/sys/module/zfs + +[Service] +ExecStart=/bin/sh -c '\ +if @sbindir@/zpool status %i | grep "scrub in progress"; then\ +exec @sbindir@/zpool wait -t scrub %i;\ +else exec @sbindir@/zpool scrub -w %i; fi' +ExecStop=-/bin/sh -c '@sbindir@/zpool scrub -p %i 2>/dev/null || true' |