Encrypted ZFS Dataset – Unlock @boot

Ich habe bei mir gerade unter Ubuntu 19.10 auf die native ZFS Verschlüsselung umgestellt und dabei nur mein Data-Pool mittels Passphrase verschlüsselt, nicht jedoch den System Pool.

Beim System Pool sollte wohl direkt beim Booten eine Passphrase-Abfrage zu kommen, bei meinem Data allerdings nicht. Nach dem Boot sind die Datasets zwar da, aber nicht lesbar weil noch nicht entsperrt.

Nach einigem Basteln hat sich diese systemd service file bei mir als funktional erwiesen:

cat /etc/systemd/system/zfs-load-key.service

[Unit]
Description=Import key for ZFS pool
Documentation=man:zfs(8)
DefaultDependencies=no
After=systemd-udev-settle.service
After=zfs-import.target
After=systemd-remount-fs.service
Before=zfs-mount.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c 'systemd-ask-password "Encrypted ZFS password" --no-tty | zfs load-key -a'

[Install]
WantedBy=zfs.target

Setzt allerdings aktuel voraus, das alle Datasets den selben Passphrase haben und checkt auch nicht ob valide und ggfs Retry notwendig ist 😉

Quelle:
https://wiki.archlinux.org/index.php/ZFS#Unlock_at_boot_time