ansible-edda/root/etc/systemd/system/zfs-trim@.service

17 lines
480 B
SYSTEMD
Raw Normal View History

2022-08-28 04:02:18 +02:00
[Unit]
Description=Zpool trim on %i
Documentation=man:zpool-trim(8)
Requires=zfs.target
After=zfs.target
ConditionACPower=true
ConditionPathIsDirectory=/sys/module/zfs
OnFailure=status-mail@%n.service
[Service]
EnvironmentFile=-/etc/default/zfs
ExecStart=/bin/sh -c '\
if /usr/sbin/zpool status %i | grep -q "(trimming)"; then\
exec /usr/sbin/zpool wait -t trim %i;\
else exec /usr/sbin/zpool trim -w %i; fi'
ExecStop=-/bin/sh -c '/usr/sbin/zpool trim -s %i 2>/dev/null || true'