解决 Debian 或 Ubuntu 开机时间被 networking 大量占用的问题

问题

首先查看哪些服务占用了开机时间:

1
systemd-analyze blame

本文示例中发现 networking.service 的时间长达 5 分钟。查看该服务状态可发现如下错误:

1
2
3
4
systemd[1]: networking.service: Start operation timed out. Terminating.
systemd[1]: networking.service: Main process exited, code=killed, status=15/TERM
systemd[1]: networking.service: Failed with result 'timeout'.
systemd[1]: Failed to start Raise network interfaces.

解决方案

编辑文件:

1
sudo vim /etc/network/interfaces

将原来的:

1
2
3
4
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

改为:

1
2
3
4
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet dhcp

重启查验结果。


References

interfaces(5) — ifupdown — Debian stretch — Debian Manpages

How to fix “ a start job is running for the raise network ” in ubuntu server 16.0 LTS

At boot, networking.service is incredibly slow (5 minutes) on Ubuntu 16.10

Mastodon