According to systemd-analyze blame
, networking-service
is taking over 5 minutes to start at boot:
Why is this happening and how can I fix it?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityEdit /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
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.
/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.
sudo systemctl edit networking.service
it still takes 5min to boot. /lib/systemd/system/networking.service
shows TimeoutStartSec=5min
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
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:
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
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.