Skip to content

Instantly share code, notes, and snippets.

@hoonetorg
Forked from da-n/zfs-load-key.service
Created June 11, 2022 17:14
Show Gist options
  • Save hoonetorg/6ef8bb2d28c405485c2af7775488e2b6 to your computer and use it in GitHub Desktop.
Save hoonetorg/6ef8bb2d28c405485c2af7775488e2b6 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