Skip to content

Instantly share code, notes, and snippets.

@azmodude
Last active November 20, 2023 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azmodude/6d9daae64685f229b48223505d8ea114 to your computer and use it in GitHub Desktop.
Save azmodude/6d9daae64685f229b48223505d8ea114 to your computer and use it in GitHub Desktop.
ZFS supplementary service files
[Unit]
Description=Load %I encryption keys
Before=systemd-user-sessions.service zfs-mount.service
After=zfs-import.target
Requires=zfs-import.target
DefaultDependencies=no
[Service]
Type=oneshot
RemainAfterExit=yes
# first try to load keyfile, if unsuccessful try to ask for a password and pipe it
ExecStart=/usr/bin/bash -c 'until (zfs load-key %I || systemd-ask-password "Encrypted ZFS password for %I" --no-tty | zfs load-key %I); do echo "Try again!"; done'
[Install]
WantedBy=zfs-mount.service
[Unit]
Description=Scrub ZFS Pool
Requires=zfs.target
After=zfs.target
[Service]
Type=oneshot
Nice=19
IOSchedulingClass=idle
ExecStartPre=-/usr/sbin/zpool scrub -s %i
ExecStart=/usr/sbin/zpool scrub %i
[Unit]
Description=Scrub ZFS pool twice a month on %i
[Timer]
OnCalendar=*-*-1,15 2:00:00
Persistent=true
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment