我想在启动后自动挂载cryfs文件系统。
我安装了一项新服务:
[Unit]
After=network.target media-SB01_Cloud.mount
[Service]
ExecStart=/root/scripts/sb01_cloud_encypted_mount
[Install]
WantedBy=default.target
该服务已安装并正在运行。该服务正在调用以下脚本:
#!/usr/bin/env bash
CONTAINER_PASSWORD='XXXXXXXX'
export CRYFS_FRONTEND=noninteractive
echo "$CONTAINER_PASSWORD"
echo "$CONTAINER_PASSWORD" | cryfs /media/SB01_Cloud/encrypted /media/SB01_Cloud_Decrypted -o uid=1000,gid=1000,umask=007
但文件系统在挂载后立即关闭。systemctl status sb01_cloud_decrypt
显示以下输出:
Nov 14 21:51:57 host sb01_cloud_encypted_mount[796254]: CryFS Version 0.10.2
Nov 14 21:51:57 host sb01_cloud_encypted_mount[796254]: Password:
Nov 14 21:52:02 host sb01_cloud_encypted_mount[796254]: Deriving encryption key (this can take some time)...done
Nov 14 21:52:02 host sb01_cloud_encypted_mount[796254]: Mounting filesystem. To unmount, call:
Nov 14 21:52:02 host sb01_cloud_encypted_mount[796254]: $ cryfs-unmount "/media/SB01_Cloud_Decrypted"
Nov 14 21:52:02 host cryfs[796303]: Filesystem started.
Nov 14 21:52:02 host cryfs[796303]: Filesystem stopped.
Nov 14 21:52:02 host systemd[1]: sb01_cloud_decrypt.service: Deactivated successfully.
Nov 14 21:52:02 host systemd[1]: sb01_cloud_decrypt.service: Consumed 29.059s CPU time.
如果我从终端调用脚本,它会正常安装并保持安装状态。为什么我会得到这一行:cryfs[796303]: Filesystem stopped.
?
是的,我知道在文件中包含明文密码的风险。以及自动挂载加密文件夹的风险,但在这种情况下我只是不信任原始挂载。 (外部Samba共享)
答案1
该问题似乎是服务已停止,也许有人可以评论为什么这会终止保险丝安装。我能够通过向服务添加Type=oneshot
和选项来解决该问题。RemainAfterExit=true
[Unit]
After=network.target media-SB01_Cloud.mount
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/root/scripts/sb01_cloud_encypted_mount
[Install]
WantedBy=default.target