Linux启动很慢,查询各服务的启动耗时,可以使用如下命令:
systemd-analyze blame
发现耗时最长的是NetworkManager-wait-online.service,通常此服务是等待所有网络接口都获取到IP,或者120秒超时。
可以编辑/usr/lib/systemd/system/systemd-networkd-wait-online.service,修改为只要一个网络接口OK,就进行下一步:
ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --any
或者改为缩短超时时长:
ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --any --timeout=50