I have two systemd units A and B, which should not be running simultaneously. Both provide access to the same resource, but in different ways, and one handles being stopped 'from outside' less gracefully than the other.

If I specify a Conflicts= dependency between them, starting one of the units will stop the other. I would prefer a stronger relation, analogous (in one direction) to Requsite=:

  • If A is already started, starting B should fail.
  • If B is already started, starting A should trigger stopping B; if that fails, starting A should fail as well.

Is there a way to accomplish this?

1 Answer 1


I ended up doing this:

in B.service:

ExecStartPre=/bin/systemctl stop A.mount

in A.mount:


in B-stopped.service:

ExecStart=/bin/sh -c '! systemctl --quiet is-active B'

You must log in to answer this question.

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