开机时自动加载 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 启用密钥加载。它会自动将 / 替换为 -
随机一篇博客