linux – 如何使用systemd-firstboot.service?

前端之家收集整理的这篇文章主要介绍了linux – 如何使用systemd-firstboot.service?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在制作Debian Jessie的形象.在启动时,系统没有/ etc / machine-id文件.这会导致一些无法启动的日志问题.

我在systemd repo中发现了:

  1. # This file is part of systemd.
  2. #
  3. # systemd is free software; you can redistribute it and/or modify it
  4. # under the terms of the GNU Lesser General Public License as published by
  5. # the Free Software Foundation; either version 2.1 of the License,or
  6. # (at your option) any later version.
  7.  
  8. [Unit]
  9. Description=First Boot Wizard
  10. Documentation=man:systemd-firstboot(1)
  11. DefaultDependencies=no
  12. Conflicts=shutdown.target
  13. After=systemd-remount-fs.service
  14. Before=systemd-sysusers.service sysinit.target shutdown.target
  15. ConditionPathIsReadWrite=/etc
  16. ConditionFirstBoot=yes
  17.  
  18. [Service]
  19. Type=oneshot
  20. RemainAfterExit=yes
  21. ExecStart=@rootbindir@/systemd-firstboot --prompt-locale --prompt-timezone --prompt-root-password
  22. StandardOutput=tty
  23. StandardInput=tty
  24. StandardError=tty

应该放在哪里它会运行?

在systemd 215中,ConditionFirstBoot不可用.怎么处理?

解决方法

我有点惊讶你没有简单地安装systemd这个脚本,但是(一般情况下)我认为答案是你应该把它放到/ etc / systemd / system中.

在这种情况下(因为你正在做所有这些尝试并获得一个机器ID,以使日志工作),我想我可能会更换ConditionFirstBoot检查你关心的文件,/ etc / machine-id .

所以我可能会重新编写Unit部分:

  1. [Unit]
  2. Description=First Boot Wizard
  3. Documentation=man:systemd-firstboot(1)
  4. DefaultDependencies=no
  5. Conflicts=shutdown.target
  6. After=systemd-remount-fs.service
  7. Before=systemd-sysusers.service sysinit.target shutdown.target
  8. ConditionPathIsReadWrite=/etc
  9. ConditionPathExists=!/etc/machine-id

话虽这么说,如果有可能发布一个更新的systemd与您的图像(我不擅长Debian,所以我找不到任何地方检查最新支持的版本是什么),这可能值得研究 – systemd 215有一些问题已经解决(https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=systemd).

猜你在找的Linux相关文章