zfs-load-key.service is masked

upbeat

New Member
Oct 1, 2024
3
2
3
Hey, all.

I'm trying to load a zfs keyfile at boot and the arch wiki (along with some helpful posts here) all advise me to create a zfs-load-key.service file to accomplish this. On my 8.2.7 install, I already have a service with this name but it is masked for some reason. I don't want to go mucking around with something that seems intentionally disabled as I don't want to break my system. Can someone update us on the correct recommendation for this process in 2024?

Thanks!
 
This is the solution:

Create a custom systemd service:

nano /etc/systemd/system/zfs-load-key-poolname.service

Create unit file thusly:

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

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/zfs load-key tank1/poolname

[Install]
WantedBy=zfs-mount.service

This will work for datasets encrypted with a keyfile. I hope this helps someone.
 
I believe it will prevent this service from interfering with other boot operations since it won’t get hooked into the default dependency ordering. I copied this from another example that used the passphrase option instead of a key file. I don’t know if that makes a difference.
 
Last edited: