mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 19:19:32 +03:00
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
This commit is contained in:
parent
87b46d63b2
commit
482505fd42
@ -59,6 +59,9 @@ systemdunit_DATA = \
|
|||||||
%D%/systemd/system/zfs-scrub-monthly@.timer \
|
%D%/systemd/system/zfs-scrub-monthly@.timer \
|
||||||
%D%/systemd/system/zfs-scrub-weekly@.timer \
|
%D%/systemd/system/zfs-scrub-weekly@.timer \
|
||||||
%D%/systemd/system/zfs-scrub@.service \
|
%D%/systemd/system/zfs-scrub@.service \
|
||||||
|
%D%/systemd/system/zfs-trim-monthly@.timer \
|
||||||
|
%D%/systemd/system/zfs-trim-weekly@.timer \
|
||||||
|
%D%/systemd/system/zfs-trim@.service \
|
||||||
%D%/systemd/system/zfs-share.service \
|
%D%/systemd/system/zfs-share.service \
|
||||||
%D%/systemd/system/zfs-volume-wait.service \
|
%D%/systemd/system/zfs-volume-wait.service \
|
||||||
%D%/systemd/system/zfs-volumes.target \
|
%D%/systemd/system/zfs-volumes.target \
|
||||||
|
12
etc/systemd/system/zfs-trim-monthly@.timer.in
Normal file
12
etc/systemd/system/zfs-trim-monthly@.timer.in
Normal file
@ -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
|
12
etc/systemd/system/zfs-trim-weekly@.timer.in
Normal file
12
etc/systemd/system/zfs-trim-weekly@.timer.in
Normal file
@ -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
|
15
etc/systemd/system/zfs-trim@.service.in
Normal file
15
etc/systemd/system/zfs-trim@.service.in
Normal file
@ -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'
|
@ -84,8 +84,29 @@ with no flags on the relevant target devices.
|
|||||||
.It Fl w , -wait
|
.It Fl w , -wait
|
||||||
Wait until the devices are done being trimmed before returning.
|
Wait until the devices are done being trimmed before returning.
|
||||||
.El
|
.El
|
||||||
|
.Sh PERIODIC TRIM
|
||||||
|
On machines using systemd, trim timers can be enabled on a per-pool basis.
|
||||||
|
.Nm weekly
|
||||||
|
and
|
||||||
|
.Nm monthly
|
||||||
|
timer units are provided.
|
||||||
|
.Bl -tag -width Ds
|
||||||
|
.It Xo
|
||||||
|
.Xc
|
||||||
|
.Nm systemctl
|
||||||
|
.Cm enable
|
||||||
|
.Cm zfs-trim-\fIweekly\fB@\fIrpool\fB.timer
|
||||||
|
.Cm --now
|
||||||
|
.It Xo
|
||||||
|
.Xc
|
||||||
|
.Nm systemctl
|
||||||
|
.Cm enable
|
||||||
|
.Cm zfs-trim-\fImonthly\fB@\fIotherpool\fB.timer
|
||||||
|
.Cm --now
|
||||||
|
.El
|
||||||
.
|
.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
|
.Xr systemd.timer 5 ,
|
||||||
.Xr zpoolprops 7 ,
|
.Xr zpoolprops 7 ,
|
||||||
.Xr zpool-initialize 8 ,
|
.Xr zpool-initialize 8 ,
|
||||||
.Xr zpool-wait 8
|
.Xr zpool-wait 8
|
||||||
|
Loading…
Reference in New Issue
Block a user