[systemd-devel] Unable to get service to wait for a mount before starting

Andrei Borzenkov arvidjaar at gmail.com
Sun Nov 10 16:46:05 UTC 2024


10.11.2024 17:53, Adam Nielsen wrote:
>> network-online.target by itself does absolutely nothing. You are
>> expected to have some service that is ordered
>> Before=network-online.target and actually waits until network is online.
>> Standard network management applications that asynchronously configure
>> interfaces (NetworkManager, systemd-networkd) have matching services.
>> Some implementations (like SUSE wicked) are synchronous and
>> network-online.target is effectively noop. Nothing stops you from
>> creating your own service that performs custom checks.
> 
> I'm using systemd-networkd with a static configuration, i.e. my
> *.network file contains:
> .
>    [Network]
>    ...
>    DNS=192.168.0.1  # local machine running BIND
>    DNS=192.168.0.2  # second local machine running BIND
> 
> I assumed systemd and networkd would play nice together without any
> special configuration but it seems this is not the case.
> 

"Playing nice" is too subjective.

If you need network at some point during boot you need to ensure it. 
Read "man systemd-networkd-wait-online".

The primary reason for automount is to avoid this hard requirement.

> I can see in the logs:
> 
>    systemd-networkd[505]: eth0: Link UP
>    systemd-networkd[505]: eth0: Gained IPv6LL
> 
> Followed four seconds later by NFS mounts failing because they can't
> resolve the hostname, and ntpd failing because it can't resolve the NTP
> server hostname either.
> 
> systemd tries to restart ntpd nine seconds after that, and that time it
> works.
> 
> Looking at the logs for systemd-resolved, it appears to be started at
> the same second as the NFS mounts and ntpd, so I wonder if that's the
> problem?  The network-online.target doesn't actually wait for
> systemd-resolved to have properly set up DNS?
> 

You seem to fundamentally misunderstand systemd architecture. *Target* 
does not and can not wait for anything except services configured in its 
After directives.


More information about the systemd-devel mailing list