The real(!) solution to this problem is following command:
sudo sed -i.old-`date +%Y%m%d-%H%M%S` '/^auto lo$/!s/^auto /allow-hotplug /' /etc/network/interfaces
In /etc/network/interfaces
this changes all interfaces (except lo
) from auto
to allow-hotplug
. This way the boot is no more waiting for the interfaces to come up first.
Warning: After this change a permanently connected interface might stay down after boot until systemd
receives a real plug event. See Notes below.
Example before (look at auto eth0
):
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
Example after (look at allow-hotplug eth0
):
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
Notes:
If you mount network shares in /etc/fstab
, use auto
and not allow-hotplug
for the interface to the network shares. Else you might see strange things happen on boot process, because network must be available prior to network share mounts. allow-hotplug
does not ensure this.
If the interfaces are in auto
mode, you express: "These interfaces are crucial for boot, so we must wait for them to come up before we have booted." Hence, if they do not come up, Ubuntu delays the boot with failsafe, waiting for them to appear for up to 120 seconds. And this is the right thing to do.
In contrast, Interfaces which are set to allow-hotplug
tell Ubuntu, that they are optional. Hence they are not essential to boot.
Ubuntu records which interfaces are available at install time, and assumes, that they are important for later operation. This is a conservative choice, in case the interface is later needed because some Service binds to it, as such services fail to start if they miss the interface being up.
There also is a kernel setting which allows processes to bind to nonexistent IPs, so you can always use allow-hotplug
if you like, without harming the stability of the boot process. However, this is a completely different story.
Notes (update 2018-01-04):
At my side, allow-auto
does the same as auto
, so it does not help (tried with br0
).
After upgrading one of my systems to Debian Stretch and switching to SystemD, boot became unbearably delayed while waiting for the (permanently connected outside) interface br0
to come up. However with allow-hotplug
the interface br0
stayed down after boot. Perhaps this is caused by SystemD not receiving any real or synthetic plug event on such an interface. I did not dig deeper into this, as some obscure crontab
entry @reboot /sbin/ifup br0
for root
fixed it for me. (This works, but probably is something, which better should not be recommended to others. I'd like to hear if somebody has some better idea.)
((Text ends here, the rest is for your entertainment))
And here is a bed time story, inspired by this:
Some crops farmers went on rampage. Their crops dried out! So they
investigated why there was not enough water in the irrigation ditch.
In the nearer distcance they immediately spotted their culprit. The
dam! The damned dam held up all the water!
From this moment on it was clear what to do. "Blow up the dam!" they
yelled and started to collect their dynamite. Then they all headed
straight for the dam.
The little son of one of the farmers asked his father about
what was going on. He told his son: "There's not enough water in
the ditch, so we blow up the dam!" Then he immediately left to
follow the pack.
"But", the little one tried to shout after his father, "But there is a
valve! Just open the valve!" Sadly, his voice was too gentle, and
his legs were too short, so this message did not reach anybody.
The boy sat down and cried. Half an hour later he heared the distant "Boom" which destroyed his favorite plaground at the dam, where the valve was located, too.
What happened next?
The Flood swept away all the precious crops.
The bank took away the boy's father's farm.
His father was unable to pay for a good school. So the boy joined the army to get a higher education. There he learned everything about the phyics of explosives and now tries to invent a blast resitant dam.
What has this story to do with this here?
- The crops farmers are the other answers.
- The little boy is this answer here.
- The dam is the Ubuntu failsafe sleeping.
- The valve is the proper interface setting.
- The water is the boot process.
- The crops is your Ubuntu OS.
- And the filled ditch is, how the boot process should look like.
The setting of the interface, which lives in /etc/network/interfaces
, is blown up with the sleep in failsafe removed, and even if somebody sees the closed valve (auto
), nobody spottet that it could be openend as well!