generated from jackyzha0/quartz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
date: 2024-01-05 | ||
title: Automatically load zfs keys at boot | ||
description: Creating a systemd service to automatically load zfs keys | ||
tags: | ||
- zfs | ||
--- | ||
I recently setup a new encrypted dataset. Ubuntu/openzfs came with a systemd service to handle mounting it at boot, but not loading the keys - therefore, on reboot, it would fail to mount | ||
|
||
I did some googling and found this: https://github.com/openzfs/zfs/issues/8750#issuecomment-497500144 | ||
|
||
```bash | ||
cat << 'EOF' > /etc/systemd/system/[email protected] | ||
[Unit] | ||
Description=Load ZFS keys | ||
DefaultDependencies=no | ||
Before=zfs-mount.service | ||
After=zfs-import.target | ||
Requires=zfs-import.target | ||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/sbin/zfs load-key %I | ||
[Install] | ||
WantedBy=zfs-mount.service | ||
EOF | ||
``` | ||
|
||
Use like so: | ||
```bash | ||
systemctl enable zfs-load-key@tank-enc | ||
``` | ||
|
||
to, for example, enable key loading for the volume `tank/enc`. It will automatically replace / with - |