5

According to systemd-analyze blame, networking-service is taking over 5 minutes to start at boot:

systemd-analyze blame

Why is this happening and how can I fix it?

3

I came up with a solution, though it may be more appropriate to call it a workaround.

The problem is that the networking.service has a default timeout of 5 minutes, and for whatever reason, the full timeout period must expire before the boot continues. So, boot takes a little more than 5 minutes.

The solution I came up with is to do the following:

 sudo systemctl edit networking.service

Add the following line:

TimeoutStartSec=10sec

I still have no idea on root cause, and what exactly it is that's timing out, but reducing the timeout from 5 minues to 10 seconds makes the boot up run quite fast, for obvious reasons.

Here's a link to my solution on Ubuntu Forums: https://ubuntuforums.org/showthread.php?t=2342450&p=13569192#post13569192

Hope that helps.

  • 1
    Link only answers are highly discouraged here. Please consider adding some explanation or make this a comment. – heemayl Nov 13 '16 at 3:54
  • 2
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – Stormvirux Nov 13 '16 at 4:42
  • 1
    Do not edit /lib/systemd/system/networking.service directly. Use systemctl edit networking.service instead. Or your edits will be overwritten the next time whichever package provides that file is upgraded. – muru Dec 6 '16 at 1:46
  • That does't work me. When editing the file with sudo systemctl edit networking.service it still takes 5min to boot. /lib/systemd/system/networking.service shows TimeoutStartSec=5min – rob Jul 20 '18 at 19:58
  • 2
    The answer about changing auto to allow-hotplug is the correct one, this is allowing the networking service to skip interfaces if they are not available at that point in time. Any interface listed as auto causes the networking service to wait until it's up or the timeout is hit. – David Schoen Jan 13 at 4:28
8

Edit /etc/network/interfaces and change "auto" for interfaces to "allow-hotplug"

sudo nano /etc/network/interfaces

Example: auto interface for ethernet card auto eth0 change to allow-hotplug eth0

After that for me "systemd-analyze blame" -> networking.service changes from 5 min to 41 s

  • this save my day :) – Blau Oct 5 '18 at 9:52
  • This also worked on Ubuntu 18.04, and reduced networking.service time from 47 seconds to 1 second. I noticed it in the boot messages (though not the dmesg log) when it got stuck, saying "A start job is running for Raise network interfaces". – Wade Walker Apr 23 at 18:26
0

From what I found maybe it would be appropriate to find a better underlying cause. In my case it seems to be systemd-networkd.service that is stalling the process and still further it is a specific network interface that stalls networkd.

So I decided on two approaches:

  1. Simply time-out the systemd-networkd-wait-online.service after a much more user friendly time. This can be achieved by editing /lib/systemd/system/systemd-networkd-wait-online and adding an option to the ExecStart line that calls the service. To simply time-out faster append --timeout=10, to reduce the wait time to 10s. It is 120S by default. However this might IMHO not be the best approach, maybe it is critical that some interface is indeed available.

    ExecStart=/lib/systemd/systemd-networkd-wait-online --timeout=10
    
  2. Try ignoring an interface you think might be the root cause. In my case this was a non critical wireless link that I had not yet configured properly. It was defined in netplan yaml file, but I had not yet set-up wpa_supplicant to get it up and running as AP with IP etc. This was the dependency that caused the stall. So I appended --ignore=int_wlan0 to the ExecStart line. Sure enough, the critical ethernet interfaces had come-up very quickly but networkd was waiting for something more from the WLAN link. Once the ignore was in place, bootup jumped directly throught the 2min delay.

    ExecStart=/lib/systemd/systemd-networkd-wait-online --ignore=int_wlan0
    

This makes some sense as "man systemd-networkd-wait-online.service" states that "it will wait for all links it is aware of and which are managed by systemd-networkd.service(8) to be fully configured or failed". What networkd considers to be fully configured is an open question. It seems from my set-up this includes having an IP address, but this may be just a special case for wireless links. I don't know. However this fix got things running much faster and at least I know the only dependency was the wireless link.

0

Just adding TimeoutStartSec=10sec didn't work for me - I had to make one slight change. Looking at /lib/systemd/system/networking.service I saw that config attribute was nested under [Service]

I edited /etc/systemd/system/networking.service.d/override.conf to look like the following:

[Service]
TimeoutStartSec=10sec

And now it works

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.