I want to have a custom service that I've placed into /lib/systemd/system start at boot, but th eonly way I know how at the moment is to run

systemctl enable myservice.service

but I would like to be able to do this without booting into the actual file system so that I can automate the deployment of this configuration.

  • I assume that you have your Debian filesystem mounted somewhere? Can you simply run chroot /mountpoint systemctl enable myservice.service?
    – Zoredache
    May 29 '13 at 1:21
  • Or rather systemd-nspawn -b -D /mountpoint instead of chroot – but in this case symlinking will be sufficient.
    – Debilski
    Aug 25 '14 at 16:02

What systemctl enable does is creates a symlink for the service you specify from the /lib/systemd/system folder to /etc/systemd/multi-user.target.wants, so you can simply do:

ln -s '/lib/systemd/system/myservice.service' '/etc/systemd/multi-user.target.wants/myservice.service'

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.