在local-fs.target之后和basic.target之前直接运行systemd单元

时间:2017-11-14 18:50:22

标签: systemd

我正在创建一个嵌入式系统。嵌入式系统安装分区。在安装分区后,我需要准备一个加密文件夹(encfs)。我需要在任何其他multi-user.targetgraphical.target

之前运行此功能

这是我的单位文件,它由自己运作。

[Unit]
Description=Mx Encrypted Folder

[Service]
Type=oneshot
ExecStart=/usr/bin/mxmountencrypted
RemainAfterExit=true
ExecStop=/usr/bin/mxunmountencrypted

此单元文件目前没有定义依赖项。

同样,我需要:

  1. 在挂载文件系统(local-fs.target
  2. 后直接运行此命令
  3. 在任何multi-user.targetgraphical.target之前,必须运行依赖它的服务必须运行。
  4. 它必须在停止local-fs.target之前完全停止,因为在systemd可以卸载分区之前,需要卸载嵌套的挂载。
  5. 我研究过使用systemd.mount项,但它不支持encfs

1 个答案:

答案 0 :(得分:1)

根据您在要求中列出的内容:

[Unit]
Description=Mx Encrypted Folder
Requires=local-fs.target
After=local-fs.target

[Service]
Type=oneshot
ExecStart=/usr/bin/mxmountencrypted
RemainAfterExit=true
ExecStop=/usr/bin/mxunmountencrypted

[Install]
WantedBy=multi-user.target

有关systemd单元文件的更多信息,请访问:https://www.freedesktop.org/software/systemd/man/systemd.unit.html

和systemd服务文件:https://www.freedesktop.org/software/systemd/man/systemd.service.html

相关问题