開機時自動載入 ZFS 金鑰
我最近建立了一個新的加密資料集。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 這個資料集啟用金鑰載入。它會自動將 / 取代為 -。
隨機一篇部落格