Skip to content

Instantly share code, notes, and snippets.

@da-n
Last active September 20, 2022 13:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save da-n/98f1443cee06d34714cdd9b1ec6a521b to your computer and use it in GitHub Desktop.
Save da-n/98f1443cee06d34714cdd9b1ec6a521b to your computer and use it in GitHub Desktop.
Import ZFS pool
# This service will unlock all ZFS pools at boot time
# It should live in
# /etc/systemd/system/zfs-load-key.service
# Enable it with
# systemctl enable zfs-load-key.service
[Unit]
Description=Load encryption keys
DefaultDependencies=no
Before=zfs-mount.service
After=zfs-import.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c '/sbin/zfs load-key -a'
[Install]
WantedBy=zfs-mount.service
zpool import <nameofzpool>
zfs set keylocation=file:///path/to/key <nameofzpool>/<nameofdataset>
zfs load-key <nameofzpool>/<nameofdataset> # or load all with zfs load-key -a
zfs mount <nameofzpool>/<nameofdataset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment