1

I have a .service on a separate partition which is linked with "systemctl enable" but does not automatically start on boot. Running "systemctl status" claims "failed to load" and it works if I run systemctl daemon-reload.

My guess is that this happens because it's on a separate partition and I was able to workaround this by doing "cp -t /etc/systemd/system" explicitly.

This seems like something that should "just work", what am I missing?

2 Answers 2

3

Yes, this is expected and it's documented in the systemctl(1) man page, under the enable command:

The file system where the linked unit files are located must be accessible when systemd is started (e.g. anything underneath /home or /var is not allowed, unless those directories are located on the root file system).

The reason for the limitation is that systemd scans all units and assembles a transaction at startup. Mounting other filesystems is done through units, so units in other filesystems will not be available until the transaction is already in progress. systemd will not rescan the units and recalculate the transaction after those filesystems are mounted.

Copying the units into the root filesystem is an appropriate workaround, as you already found out.

4
  • 1
    This is disappointing: systemd could just reload symlinks as partitions go up. Commented Mar 14, 2020 at 1:01
  • @cdleonard Part of the problem is that you need a full picture to properly resolve dependencies. For example, what if the unit from the other partition declares it wants to run before starting a webserver or a database, but by the time it's available those services are already up? Also, recalculating the whole dependency graph is pretty expensive, so doing so when partitions being mounted means your boot will be slower. And systemd is all about fast boot. Commented Mar 14, 2020 at 1:07
  • 1
    I ran into something like this with 219. Systemd would not enable the service if link is to another partition with "Invalid argument" error, without ever explaining what exactly is wrong (yet agree to start/stop it). Commented Jan 28, 2023 at 21:05
  • A clear error message would be enough... Commented Nov 5, 2023 at 16:37
3

Workaround is possible. Create unit that will call:

systemctl daemon-reload; systemctl start <your service>

Make this unit to start after mounts.

1
  • My service is on the /usr/local/ partition, should I use Wants=usr-local.mount or After=usr-local.mount or Requires=usr-local.mount for my timer to start upon reboots ? And in which section(s) of the service ? Commented Sep 7, 2023 at 15:57

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.