7

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.

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

1 Answer 1

5

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/system/multi-user.target.wants/myservice.service'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .