Skip to content

Commit

Permalink
Quartz sync: Jan 5, 2024, 8:10 PM
Browse files Browse the repository at this point in the history
  • Loading branch information
ellie committed Jan 5, 2024
1 parent fb16670 commit 573e0c6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions content/notes/auto load zfs keys at boot.md
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 -

0 comments on commit 573e0c6

Please sign in to comment.