Skip to content

ZFS

systemd services for ZFS

Docker needs to start after your storage otherwise it will populate empty directories where your zpool will be mounted and ZFS will show empty mounted directories.

wait-for-zfs.service
[Unit]
Description=Wait for ZFS before starting Docker
#RequiredBy=docker.service
Before=docker.service
Requires=zfs.target
After=zfs.target

[Service]
Type=oneshot
ExecStart=/bin/true
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Force loading of ZFS keys. Added this to my Ubuntu setup years ago when unloaded keys were errors more than once.

zfs-load-key.service
[Unit]
Description=Load encryption keys
DefaultDependencies=no
After=zfs-import.target
Before=zfs-mount.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/zfs load-key -a
StandardInput=tty-force

[Install]
WantedBy=zfs-mount.service