Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use systemd service templates #3

Open
Zocker1999NET opened this issue Apr 28, 2023 · 0 comments
Open

Use systemd service templates #3

Zocker1999NET opened this issue Apr 28, 2023 · 0 comments

Comments

@Zocker1999NET
Copy link

Hey, thanks for this great documentation. However I have an idea to further improve it:

You stated one could use multiple ExecStart= lines to control, which drive's keys should be loaded on boot. You can use systemd templates instead of them. I think this may be easier to manage & debug in the long run.

To use them, you need to:

  • append an @ at the end of the service's file name like zfs-load-key@.service
  • use ExecStart=/usr/bin/zfs load-key %i
  • optionally use Description=Load encryption keys for %i
  • select which keys you want to load by enabling the services as required: systemctl enable zfs-load-key@my-dataset.service

This supports multiple instances but then uses one instance / service per dataset. If some import fails, systemd will easily indicate which failed to load. All while maintaining a single main configuration file which doesn't need to be edited to enable another dataset.

And if someone wants to import all, one still can use systemctl enable zfs-load-key@-a.service as systemd will then eventually call zfs load-key -a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant