-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add weekly and monthly systemd timers for trimming
On machines using systemd, trim timers can be enabled on a per-pool basis. Weekly and monthly timer units are provided. Timers can be enabled as follows: systemctl enable zfs-trim-weekly@rpool.timer --now systemctl enable zfs-trim-monthly@datapool.timer --now Each timer will pull in zfs-trim@${poolname}.service, which is not schedule-specific. The manpage zpool-trim has been updated accordingly. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Julian Brunner <julian.brunner@gmail.com> Closes #13544
- Loading branch information
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=Monthly zpool trim timer for %i | ||
Documentation=man:zpool-trim(8) | ||
|
||
[Timer] | ||
OnCalendar=monthly | ||
Persistent=true | ||
RandomizedDelaySec=1h | ||
Unit=zfs-trim@%i.service | ||
|
||
[Install] | ||
WantedBy=timers.target |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=Weekly zpool trim timer for %i | ||
Documentation=man:zpool-trim(8) | ||
|
||
[Timer] | ||
OnCalendar=weekly | ||
Persistent=true | ||
RandomizedDelaySec=1h | ||
Unit=zfs-trim@%i.service | ||
|
||
[Install] | ||
WantedBy=timers.target |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=zpool trim on %i | ||
Documentation=man:zpool-trim(8) | ||
Requires=zfs.target | ||
After=zfs.target | ||
ConditionACPower=true | ||
ConditionPathIsDirectory=/sys/module/zfs | ||
|
||
[Service] | ||
EnvironmentFile=-@initconfdir@/zfs | ||
ExecStart=/bin/sh -c '\ | ||
if @sbindir@/zpool status %i | grep -q "(trimming)"; then\ | ||
exec @sbindir@/zpool wait -t trim %i;\ | ||
else exec @sbindir@/zpool trim -w %i; fi' | ||
ExecStop=-/bin/sh -c '@sbindir@/zpool trim -s %i 2>/dev/null || true' |
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