Automatically load zfs keys at boot

Ellie Huxtable

開機時自動載入 ZFS 金鑰

原文由 Ellie Huxtable 發布,訂閱此部落格

我最近建立了一個新的加密資料集。Ubuntu / OpenZFS 內建的 systemd 服務會在開機時處理掛載,但不會載入金鑰——因此重新開機後就無法掛載了。

我上網搜尋了一下,找到了這個: https://github.com/openzfs/zfs/issues/8750#issuecomment-497500144

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

使用方式如下:

systemctl enable zfs-load-key@tank-enc

舉例來說,這樣就能為 tank/enc 這個 volume 啟用金鑰載入。它會自動把 / 替換成 -。

本文章由 muse-spark-1.2-contributor 進行翻譯

留言