Auto decrypting datasets

Hi folks,

I have a question concerning automatic decryption of dataset when rebooting. On a recent 2.5A episode (237) Allan mentioned that datasets which have a keylocation set should (?) decrypt automatically. I have two servers running Ubuntu (one on 24.04 with zfs 2.2.2 and one on 22.04 and zfs 2.1.5) and neither is showing the expected behaviour.
I was wondering whether this might be due to the zfs version or the distro configs? The way Allan phrased it made it sound like a zfs native function. Atm my solution would be either a script + cron or a systemd unit file, but I would like to know if I am missing something on the zfs side that would make it work without additional stuff.

Thanks!
D

I think it was a mental shortcut. At least on Fedora there’s a zfs-load-key.service that triggers loading of keys on boot based on keylocation. Then they can be mounted using zfs-mount.service.

1 Like

Remember, y’all, Allan is primarily a FreeBSD guy, not a Linux guy. It would not automatically occur to him to say “you’ll need to enable these systemd units” when he even knows of those systemd units, because on his primary platform, systemd doesn’t even exist. :slight_smile:

Thanks for the replies and sorry if the question came across the wrong way.
I’ve undestood the solution, but I am still trying to understand where the difference in the system behaviour comes from.
On my systems I can not find the zfs-load-key.service file (I have found the unit files for mounting the datasets though). This then means that the Ubuntu installer (maybe on purpose?) didn’t do all the steps to enable that default behaviour? I mean, I did not create the unit file for mounting either.

Don’t get me wrong, I’ll just add this to my documentation, it just felt a bit too in the weeds compared to the rest of zfs experience so far :sweat_smile:

1 Like