I am looking for a way to instruct systemd to recalculate service dependencies while the system is booting. Specifically, I need one service to be able to enable another service, and have the second service start up later in the same boot sequence. This is part of my automatic deployment process; very early in the boot process, the first time the system starts up, it automatically configures itself. One of the steps that it may need to take is enabling other services. Unfortunately, any changes it makes at that step do not seem to take effect until the following reboot. Rebooting the machine after initial deployment is not an option.

Here's a generalized idea of what I'm trying to achieve


Description=Enable MyService

ExecStart=/bin/systemctl enable myservice.service
ExecStartPost=/bin/systemctl disable firstboot.service






Unfortunately, this doesn't work as I expected; the service is enabled, but is not started before multi-user.target:

$ systemctl status myservice
myservice.service - MyService
   Loaded: loaded (/etc/systemd/system/myservice.service; enabled)
   Active: inactive (dead)

I can force it to start with systemctl isolate multi-user.target or by rebooting the machine.

I have tried adding systemctl daemon-reload and/or systemctl daemon-reexec to ExecStart/ExecStartPost of firstboot.service, but neither seem to have any effect.

Is there any way I can tell systemd to recalculate the boot path and include the changes that were made while it was still booting? Or will I need to do something later in the boot process to force my service to start?

  • 1
    systemd already does this by default - after a fashion - if you have it in initramfs. It execs itself at switchroot. If I were you I would have one initramfs for deployment and one it deploys. If you find the idea interesting look here for more: freedesktop.org/wiki/Software/systemd/InitrdInterface – mikeserv Jun 6 '14 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.