July 7, 2026

How Systemd Thinks: Units, Dependencies, Ordering, and Boot Failures

A unit file can look completely reasonable, boot in the right order, and still fail in production.

That usually happens when we read systemd files as if they were shell scripts.

We see:

After=network.target

and mentally translate it to:

“Start my daemon once the network is ready.”

But that is not what the line says. It only describes ordering, and only when both units are part of the same job transaction. It does not pull a network unit in. It does not prove that an address exists. It does not prove that DNS works. It definitely does not prove that a remote server, credentials or an MQTT broker are ready for your application.

That difference is the source of many confusing boot failures.

In the previous article, systemd Is More Than systemctl , we built the broad map: systemd manages more than service processes. It owns units, jobs, logs, service identities, filesystem state, cgroups, resource limits and activation. This article zooms in on the part that is easiest to misuse: how systemd decides what to start, in which order, and what happens when a unit fails.

systemd thinks in graphs, not scripts

Stop reading unit files from top to bottom


A classic init script is easy to imagine as a sequence:

mount storage
start network
start database
start application

That model is sequential. One action finishes, then the next action begins.

systemd is designed differently. It manages units and resolves a graph of relationships between them. If two units have no dependency or ordering relationship, systemd may start them in parallel. That is one reason systemd can boot systems efficiently, but it also means that accidental or overly broad dependencies can slow boot or create fragile startup chains.

When you ask systemd to start one unit, it does not simply execute its ExecStart= line. It loads the relevant unit configuration, expands dependencies, considers conflicts, creates jobs, applies ordering rules and then executes the resulting transaction.

For practical reasoning, keep these three layers separate:

  1. Unit state — is this unit loaded, active, inactive, activating, deactivating or failed?
  2. Jobs — is systemd currently trying to start, stop, reload or restart it?
  3. The transaction — what set of jobs, dependencies, orderings and conflicts did systemd calculate from the original request?

Useful question during debugging

Do not ask only “why did my service not run?” Ask: what transaction did systemd build, which job failed, and which relationship caused that result?

A start request becomes a transaction


Imagine this command on a test device:

systemctl start device-telemetry.service

systemd creates a start job for device-telemetry.service. Then it looks at the relationships declared by that unit and by units connected to it. A request that looked like one operation can become a transaction containing several start, stop or reload jobs.

For example, the requested service may:

  • pull in a mount unit because it needs persistent data;
  • pull in network-online.target because its initial client work benefits from waiting until the enabled wait-online implementation considers the local network configured;
  • be ordered after those units so that it does not start in parallel with them;
  • stop a conflicting maintenance service before it begins;
  • be skipped because a Condition... check does not apply on this hardware variant;
  • or fail because there is no valid way to satisfy the dependency graph.

This transactional model also explains why changing a single dependency line can affect much more than one service. You are not adding a local instruction. You are changing the graph systemd must resolve.

one start request, many jobs

The most important distinction: requirements versus ordering


Most systemd dependency problems come from mixing up two independent questions:

  • Should starting A also pull in B?
  • If both A and B are started, which one must complete startup first?

The first question is about requirement dependencies. The second question is about ordering dependencies.

They are deliberately separate. This lets systemd start independent units in parallel and lets you express whether a missing dependency is fatal, optional or a runtime precondition.

DirectivePrimary question it answersWhat it does not mean
Wants=“Also try to start this unit.”It does not require success and does not define order.
Requires=“This is a stronger startup requirement.”It does not define order and does not continuously guarantee the other unit remains active.
Requisite=“This must already be active.”It does not start the other unit for you.
BindsTo=“My active lifetime is tied to this unit.”It does not replace an explicit ordering rule when startup order matters.
After=“Start me after this unit, if both are started.”It does not pull the other unit into the transaction.
Before=“Start me before this unit, if both are started.”It does not make the other unit a requirement.
PartOf=“Stop/restart this unit when that parent unit is stopped/restarted.”It does not pull the parent in or make start propagation bidirectional.
Conflicts=“These units cannot be active together.”It does not say which one should be wanted at boot.

The rule worth remembering is:

Rule of thumb

Wants=, Requires=, Requisite= and BindsTo= answer whether units are related as requirements. After= and Before= answer only the ordering question.

pullinvsordering

Wants=: pull it in, but keep the system resilient


Wants= is a weak requirement. Starting this unit also attempts to start the listed units. But if a wanted unit cannot be started, the original unit may still start.

That makes Wants= a good default when the dependent feature improves behaviour but should not make the entire device unavailable.

[Unit]
Description=Device telemetry daemon
Wants=network-online.target
After=network-online.target

This says:

  • when telemetry is started, also try to reach network-online.target;
  • if both jobs exist, wait until that target has been reached before starting telemetry;
  • but do not treat an unavailable network as a permanent reason to keep telemetry from starting.

For many connected embedded daemons, that is the right approach. Start the process, let it perform its own reconnect and retry policy, and avoid making the whole boot depend on one DHCP lease or a temporarily unavailable access point.

Do not use network targets as remote-service readiness checks

network-online.target is intended for clients that genuinely cannot operate without a configured network connection. Its meaning depends on the configured network stack and any enabled “wait online” service; it is not a universal definition of end-to-end connectivity. It does not prove that your DNS name resolves, that your backend accepts TLS, or that your remote API is healthy. Keep those retries and timeouts inside the application protocol.

Requires=: stronger, but not “always alive”


Requires= is stronger than Wants=. Starting A also starts B. When A is ordered After=B, a failure to start B prevents A from starting.

This pattern is common when the service cannot safely initialize without a prerequisite:

[Unit]
Description=Device inventory service
Requires=data.mount
After=data.mount

The two lines work together:

  • Requires=data.mount pulls the mount into the transaction as a strong requirement.
  • After=data.mount prevents the service from beginning startup before that mount has completed its startup operation.

Without After=, systemd may start the service and mount in parallel. That is usually wrong when the daemon reads configuration or opens a database on that filesystem during startup.

Requires= also propagates an explicit stop request: if B is explicitly stopped, systemd stops A as well. But it is still not a full active-lifetime binding.

If B becomes inactive by itself later, for example because a device disappears or a service exits, A is not necessarily stopped. When your service must not remain active without its counterpart, use the stronger lifetime relationship described next.

BindsTo=: tie the active lifetime together


BindsTo= includes a Requires=-like activation relationship and adds stronger runtime coupling: when B becomes inactive, A is stopped too. Use it when the relationship is not merely a startup preference but a runtime truth.

For example, imagine a hardware protocol service that only makes sense while a USB device exists:

[Unit]
Description=USB measurement adapter service
BindsTo=dev-ttyUSB0.device
After=dev-ttyUSB0.device

The intent is clear:

  • do not start the protocol daemon before the device unit exists;
  • if the hardware disappears, stop the daemon rather than leaving a process running against a dead assumption.

For a mount or a device that must stay present, BindsTo= together with After= expresses a much stronger contract than Requires= alone.

Choose the weakest dependency that expresses the real contract

A strong dependency can turn a local fault into a wider outage. Do not use BindsTo= because it sounds safer. Use it only when an active service without the other unit would be incorrect or unsafe.

Requisite=: check a precondition without starting it


Requisite= is less common, but useful when a unit must already be active and the current service should not activate it implicitly.

[Unit]
Description=Factory calibration exporter
Requisite=factory-mode.target
After=factory-mode.target

This expresses a policy boundary: the exporter may run only when the device is already in factory mode. Starting the exporter does not silently switch the product into that mode.

That distinction can be valuable for privileged or product-state-sensitive operations. The dependency is a check, not an activation request.

PartOf=: coordinate stop and restart, not startup


PartOf= is often misunderstood as another way to create a startup dependency. It is not.

It propagates stop and restart operations from the listed unit to this one. The relationship is one way.

[Unit]
Description=Device diagnostics API
PartOf=device-stack.target

If device-stack.target is stopped or restarted, the diagnostics API follows. But starting device-stack.target does not automatically start this service merely because the service says PartOf=device-stack.target.

To pull a service into a target at boot, use a wanted or required relationship, commonly through the unit’s [Install] section:

[Install]
WantedBy=device-stack.target

That creates the boot-time relationship. PartOf= is for coordinated stop and restart behaviour after the units are already connected.

After= is ordering, not readiness


This is the rule engineers most often need during code review:

[Unit]
After=database.service

does not mean:

  • start database.service;
  • wait until the database accepts authenticated queries;
  • retry when the database restarts later;
  • make the database a strong startup requirement.

It means only this:

If both units are being started, start this unit after systemd considers the other unit’s startup complete.

Ordering is reversed during shutdown. If A declares After=B, systemd starts A after B, but stops A before B.

For service units, “startup complete” depends on the service type and configured start commands. With Type=simple, systemd considers startup complete once it has started the main process and proceeds with dependent jobs; it does not wait for the daemon to prove that initialization finished. With Type=notify, the service can explicitly report that its local initialization is complete. Neither model proves that every higher-level dependency your process needs is operational.

Better embedded design

Use systemd to establish local process and resource prerequisites. Use your application protocol to handle remote readiness, reconnection, backoff, authentication and degraded operation.

Conditions and asserts: skip versus reject


Not every unit should run on every hardware variant, image flavour or boot mode. Conditions and asserts let you express that before a service starts.

[Unit]
ConditionPathExists=/dev/ttyS4
ConditionKernelCommandLine=gr8.factory_mode=1

A failed Condition... means the unit is skipped. It is useful for optional hardware and conditional product features. It should not be used to hide a broken mandatory setup.

[Unit]
AssertPathIsDirectory=/var/lib/device-inventory

An Assert... expresses a stronger statement: this environment must be valid for the unit to activate. If the assertion is false, systemd aborts the activation with an error. Conditions and asserts are evaluated when the queued start job is about to run; a failed condition is not the same thing as a service process crash.

This distinction matters during diagnostics. A service may be inactive because it was deliberately skipped, not because its executable ever ran and failed.

A practical service example: local prerequisites and remote retry


Consider a daemon that reads durable state from /var/lib/device-inventory and uploads device inventory to a remote backend.

Its local storage is a startup prerequisite. The remote backend is not: a device should still boot when the backend is down.

[Unit]
Description=Device inventory service
Documentation=man:systemd.service(5)

# Pull in the mount units needed to access this path,
# and order the service after them.
RequiresMountsFor=/var/lib/device-inventory

# Start after network-online when it is available, but do not make
# a temporary network failure fatal for the local daemon lifecycle.
Wants=network-online.target
After=network-online.target

OnFailure=device-inventory-failure@%p.service

[Service]
Type=notify
User=device-inventory
ExecStart=/usr/bin/device-inventory
Restart=on-failure
RestartSec=3

[Install]
WantedBy=multi-user.target

The interesting part is not the exact unit file. It is the split of responsibility:

  • RequiresMountsFor= declares that local filesystem access is mandatory and lets systemd add the required mount relationships for that path.
  • Wants=network-online.target plus After=network-online.target gives the network a chance to become configured before startup without turning a transient connectivity problem into a boot blocker.
  • Type=notify lets the daemon decide when its own local initialization is complete.
  • Restart=on-failure covers process-level failure, while the application still owns retries to the remote backend.
  • OnFailure= provides an explicit place to attach a product-specific diagnostic or recovery action.

Do not copy network dependencies by habit

Some services only expose local D-Bus APIs or wait for a client connection. They do not need network-online.target at all. Every extra boot dependency has a cost and can create a new failure mode.

localremote

Why boot failures happen even when every line looks reasonable


Most boot failures come from a small set of design errors.

A unit is ordered after something that is never pulled in

[Unit]
After=database.service

If nothing else starts database.service, this line does not do it. Your service may start because there is no database job in the transaction to wait for.

Fix the design with a requirement relationship only when the database is genuinely part of the service’s local startup contract:

Wants=database.service
After=database.service

or, for a stronger startup requirement:

Requires=database.service
After=database.service

Then review whether a hard database dependency is actually appropriate for the product. Often a service that can recover later is better than a service that prevents boot-time functionality entirely.

A wanted unit fails, but the service correctly starts anyway

With Wants=, this is expected. It is not necessarily a systemd bug or a broken ordering rule. The original service is allowed to continue.

The real question is whether your daemon behaves sensibly in that degraded state. Does it retry? Does it expose an accurate health status? Does it emit a D-Bus signal when connectivity returns? Does it avoid crashing because an optional resource was absent?

Requires= is used where BindsTo= was needed

A daemon may start only after a mount, device or companion service starts successfully. Later, that prerequisite might disappear. If the daemon cannot remain correct without it, Requires= is not enough to model the runtime lifetime relationship.

Use BindsTo= plus After= only when active lifetime must truly be coupled.

A condition silently skips the unit

On a product with multiple hardware variants, a condition can be the correct design. But it can look like a mysterious “service did not start” issue if nobody checked the unit status and journal.

Always distinguish these cases:

  • the process ran and failed;
  • systemd did not run the process because a unit assertion rejected activation;
  • systemd skipped the process because a condition did not apply;
  • the unit was never part of the boot transaction at all.

An ordering cycle makes the graph impossible

Cycles are easy to create through several small files and drop-ins:

A.service: After=B.service
B.service: After=C.service
C.service: After=A.service

No startup order can satisfy all three statements. systemd detects the ordering cycle, logs it and may drop a job from the transaction to make progress.

That does not make the dependency graph correct. It means the resulting boot no longer matches the intended design. The fix is not to add another dependency. The fix is to remove the unnecessary relationship or redesign the ownership boundary.

Do not solve boot uncertainty by adding every dependency you can think of

Over-constraining the graph serializes boot, hides weak architecture boundaries and makes cycles more likely. A good unit file has the fewest dependencies that accurately express what must be true.

Targets are synchronization points, not old runlevels with a new name


A .target unit groups or synchronizes other units. It can represent a boot milestone such as multi-user.target, but it can also represent a product-specific state such as device-stack.target or factory-mode.target.

The important question is not “what number runlevel is this?” The useful question is:

Which units should be pulled in together, and what does reaching this target mean for the product?

For example, a product-specific target can group the application-level services that form one feature stack:

# device-stack.target
[Unit]
Description=Device application stack
Wants=device-api.service device-updater.service device-monitor.service

The target can pull in the stack. Each individual service should still own its own true prerequisites and ordering rules. Do not hide every detail in one giant target file.

Also be cautious with DefaultDependencies=no. Normal service units receive useful default boot and shutdown relationships. Disabling them is primarily for early-boot or late-shutdown code that truly needs special handling, not a general solution for “systemd starts my service too late.”

A debugging workflow for boot failures


When a service fails at boot, do not immediately edit dependencies. First inspect what systemd actually loaded and attempted.

Read the effective unit configuration

systemctl cat device-inventory.service

This is more useful than opening only one file under /etc/systemd/system. It shows the unit and active drop-ins together. A vendor unit, a product override and a local debug drop-in can all contribute to the effective configuration.

Check state, result and main process

systemctl status device-inventory.service --no-pager

systemctl show device-inventory.service \
  -p LoadState \
  -p ActiveState \
  -p SubState \
  -p Result \
  -p ConditionResult \
  -p AssertResult \
  -p MainPID \
  -p ExecMainCode \
  -p ExecMainStatus

systemctl status often makes a skipped condition visible immediately. The additional ConditionResult and AssertResult properties provide machine-readable confirmation when a unit was skipped or rejected before its process ran.

Together, these properties distinguish a missing or masked unit from one that activated and then crashed, was skipped, was rejected before execution, or is merely waiting for another job.

Read logs for this boot

journalctl -u device-inventory.service -b --no-pager

Then look for the prerequisite units mentioned by the service. If the service needs a mount, inspect the mount. If it waits for a network target, inspect the relevant network manager and wait-online service. Follow the graph instead of reading only the final service log.

Inspect dependencies in both directions

# What does this unit pull in or order around itself?
systemctl list-dependencies device-inventory.service

# What depends on this unit?
systemctl list-dependencies --reverse device-inventory.service

The reverse view is important when stopping or restarting one unit unexpectedly affects a larger product feature.

Validate the unit before rebooting the device

systemd-analyze verify \
  /etc/systemd/system/device-inventory.service

This is useful for checking unit-file correctness and catching obvious configuration or dependency problems before a change reaches a boot test. It is not a substitute for testing the real transaction on the target, especially when other packages install drop-ins or generated units.

Analyze the critical boot path carefully

systemd-analyze critical-chain device-inventory.service

systemd-analyze critical-chain

critical-chain shows a time-critical chain, which is useful when your unit is delayed by an ordered prerequisite. But boot is parallel, and activation can involve sockets or other mechanisms that make any single timeline incomplete.

Use systemd-analyze blame carefully. It lists units by initialization time, but a long time does not automatically mean that unit caused the whole boot delay. It may itself be waiting on something else.

Look at pending jobs while the failure happens

systemctl list-jobs

On a slow boot or a deliberately reproduced failure, this can reveal a unit waiting for a start or stop job that is blocked by another part of the transaction.

debugabootfailurte

What to review in a unit file


Dependency review should be more specific than “looks good” or “we always use After=network.target.” Ask these questions:

  1. What exactly must be present for this process to initialize safely? A mount? A device node? A local broker? A service account? Do not confuse this with remote service availability.
  2. Should systemd pull that prerequisite in? Choose Wants=, Requires=, Requisite= or no relationship at all based on the real contract.
  3. Does startup order matter once both units are present? Add After= or Before= only where a real order is needed.
  4. Must the service stop when the prerequisite disappears later? If yes, consider BindsTo= together with ordering.
  5. What should happen after an explicit restart of the parent stack? Use PartOf= only for deliberate one-way restart and stop propagation.
  6. Is a condition describing an optional feature or hiding a required fault? Use conditions for “not applicable”; use assertions or a normal failure path for “this environment is invalid.”
  7. Can the process survive a temporary remote outage by itself? In most connected devices, application-level reconnect logic is better than turning remote availability into a boot dependency.

Good design signal

You should be able to explain every dependency in one sentence that names the actual failure mode it prevents. “We always add this line” is not a reason.

Common mistakes


  • Using only After= and expecting a dependency. Ordering does not pull a unit into the transaction.
  • Using only Requires= and expecting ordering. Requirement dependencies do not tell systemd which unit should start first.
  • Using Requires= for every relationship. Strong dependencies can make a device less resilient when optional subsystems fail.
  • Assuming Requires= enforces continuous lifetime. Use BindsTo= when an active service without the dependency would be invalid.
  • Adding network-online.target to every network-related service. Pull it in only for software that truly cannot operate until network configuration is available.
  • Using conditions to conceal mandatory configuration errors. A skipped service can be much harder to notice than a deliberate, visible failure.
  • Ignoring drop-ins. The unit file you edited may not be the effective configuration systemd loaded.
  • Turning off default dependencies to “fix” boot order. This can remove important shutdown and basic-system initialization relationships.
  • Treating systemd-analyze blame as a causal diagnosis. Boot is parallel; a slow unit may be waiting rather than causing the delay.

The key idea


If you remember only one thing, remember this:

Tip

systemd does not execute your unit file as a script. It calculates a transaction from requirement relationships, ordering rules, conflicts and unit state. Wants=/Requires= answer what to pull in; After=/Before= answer what starts first.

Once that model is clear, boot failures become less mysterious. Instead of trying random combinations of After=, Requires= and Restart=, you can inspect the graph, identify the actual contract and express only the dependency the service truly needs.

In the next article, we will move from the graph to the service process itself: readiness, restart behaviour, shutdown, timeouts and how to write a production-grade systemd service unit.