Boot process hangs at systemd-networkd-wait-online

16,561

Solution 1

It sounds as if you have >1 systemd.network(5) configuration file in /etc/systemd/network (or have [Match] section specifying >1 interface with a wildcard) with none set with the RequiredForOnline=false directive in the [Link] section. In that case, systemd-networkd-wait-online.service will expect all the systemd-networkd managed interfaces to reach a routable operational state.

Though setting that directive will also make it ignored by systemd-networkd-wait-online.service entirely, which is also probably not what you want. If you don't care about ordering against the network-online.target, then you might as well disable and/or mask the unit.

If you would prefer to retain the advantages of ordering dependencies against network-online.target, then the easiest way around this that I've found is to simply use the --any switch. Either create the file /etc/systemd/system/systemd-networkd-wait-online.service.d/override.conf or use sudo systemctl edit systemd-networkd-wait-online.service (which will also create the same file) and include these lines...

[Service]
ExecStart=
ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --any

A subsequent sudo systemctl daemon-reload and sudo systemctl restart systemd-networkd-wait-online.service should tell you immediately whether it worked or not.

Alternatively, you can use the --interface= and/or --ignore= switches with systemd-networkd-wait-online. These may be used in place of, or in conjunction with, the --any switch shown above. If used with the --any switch, it will only consider those interfaces passed to --interface=, or not explicitly disregarded with --ignore=, when determining whether the machine has reached an online state.

Solution 2

Your system is not freezing during the boot process, it's entered a waiting state for the network devices to be completely configured before continuing on. The ultimate fix will come from an examination of of the configuration files in /etc/systemd/network and the service logs as revealed by journalctl -xe | grep networkd, focusing your attention on any links whose status in the report from networkctl status -a is not listed as "configured". This has been known to happen when IPv6 is unavailable or misconfigured, but also for various other reasons.

You should reboot the system in recovery mode via your bootloader (GRUB, rEFInd, etc.) and select the root option from the menu that appears. From there you can examine the system with the above-mentioned commands and/or enable debugging logs for the service by creating a new directory with mkdir /etc/systemd/system/systemd-networkd.service.d and then creating a new file in it called override.conf (e.g. sudoedit /etc/systemd/system/systemd-networkd.service.d/override.conf) with the following contents:

[Service]
Environment=SYSTEMD_LOG_LEVEL=debug

You can test the success of your modifications to the files in /etc/systemd/network while still in recovery mode using the command /usr/lib/systemd/systemd-networkd-wait-online && echo $?. If you've fixed the problem the output will be 0. Failing all else, you can disable the service entirely with sudo systemctl disable systemd-netword-wait-online.service


Relevant man pages:

Share:
16,561

Related videos on Youtube

Stefanx
Author by

Stefanx

Updated on September 18, 2022

Comments

  • Stefanx
    Stefanx over 1 year

    When i want to boot up my laptop it shows this error to me

    [FAILED] Failed to start Dispatcher daemon for systemd-networkd
    

    and this is what happens

    Please help me.

  • Stefanx
    Stefanx about 4 years
    I did what you said(i disabled systemctl)but it didn't work.
  • daniel451
    daniel451 over 3 years
    Why do we need ExecStart twice?
  • WonderWoofy
    WonderWoofy over 3 years
    It is a "drop-in snippet" to add to or replace directives in the service file. Adding is as simple as including the unit section(s) and the directive(s) you wish to set, but to replace a directive that may only used once requires "clearing" the directive first. So the first one blanks out the existing ExecStart= setting, and the second is what we are replacing it with.
  • MarcoZen
    MarcoZen about 3 years
    @WonderWoofy -> --any Works !!! Hope you can edit your answer to show the proper syntax for --interface=
  • MarcoZen
    MarcoZen about 3 years
    .Also must we only add 1 --interface= or we can add few as per the nics in our server ?
  • WonderWoofy
    WonderWoofy about 3 years
    @MarcoZen it is one interface name per --interface switch, but you can use the --interface switch as many times as you need. I'll update my answer for you, as there is a bit more to it than that.
  • WonderWoofy
    WonderWoofy about 3 years
    Aaaaand I have no idea how to edit it on a mobile device. ¯\_(ツ)_/¯ But the gist is that only one interface is allowed because you can also append a minimum and maximum operational state (basically the state it must reach to be considered "up", or 'routable' if unspecified). Just like the -o or --operational switch, but specific to one interface. Glad my answer helped you out though! I'll fix my answer when I get a chance.
  • MarcoZen
    MarcoZen about 3 years
    @WonderWoofy - Thanks !
  • MarcoZen
    MarcoZen about 3 years
    @WonderWoofy - what would the syntax be for NetworkManager-wait-online - Failed to Start ? It must be something similar ? This happens because of 2 NICs i suppose ? How do you find what put into ExecStart ?
  • WonderWoofy
    WonderWoofy about 3 years
    @MarcoZen - I don't know what NetworkManager-wait-online needs, as i don't use it. I actually just read the man page to figure out the systemd-networkd-wait-online args. I imagine Network Manager's might also have a man page. ¯\_(ツ)_/¯
  • MarcoZen
    MarcoZen about 3 years
    @WonderWoofy - man /lib/systemd/system/NetworkManager-wait-online.service
  • WonderWoofy
    WonderWoofy about 2 years
    If you really wanted to make systemd-networkd-wait-online.service not start up, then Peter's suggestion of using systemctl disable ... should work. But another systemd unit could be starting it as a dependency still. If you really want to forcefully prevent it from starting, then mask it with systemctl mask systemd-networkd-wait-online.service. Just beware that the network-online.target has a dependency on one of the "wait-online" services, and that network-online.target may be used to ensure network connectivity prior to firing up other services.
  • WonderWoofy
    WonderWoofy about 2 years
    In any case, my answer below will fix your issue if it is something you're still fighting against.
  • WonderWoofy
    WonderWoofy about 2 years
    @MarcoZen I'm confused by that last response. That isn't how you see man pages. In this case, the documentation info should be a directive in the service file. This means that you should be able to do systemctl help NetworkManager-wait-online.service and it will take you to the appropriate man page. (For that service, it seems that the man page is actually nm-online. So you can also use man nm-online or man 1 nm-online as well.)
  • WonderWoofy
    WonderWoofy about 2 years
    Oof, that one works entirely differently. By default the service runs nm-online -s -q -t 30, where the -s (or --wait-for-startup) makes it report success when NetworkManager simply comes up properly, the -q is short for --quiet, and the -t 30 is equivalent to --timeout=30. So it appears that the removal of the -s switch should cause it to react to network connectivity rather than the state of NetworkManager.service. You can use a drop-in snippet for this too, which I describe above.