我的 ubuntu 20.04 启动速度很慢。以下是我所做的:
- 使用
systemd-analyze blame
已识别的 31 来networkd-dispatcher.service
。 - 执行此操作后
journalctl -b -u networkd.dispatcher.service
会出现以下日志:
15:39:11 systemd[1]: Starting Dispatcher daemon for systemd-networkd...
15:39:42 networkd-dispatcher[1144]: DEBUG:Performed interface scan; state: <Dispatcher({'script_dir': '/etc/networkd-dispatcher:/usr/lib/networkd-dispatcher'})>
15:39:42 networkd-dispatcher[1144]: INFO:Triggering scripts for last-known state for allinterfaces
15:39:42 networkd-dispatcher[1144]: DEBUG:Running immediate triggers for NetworkctlListState(idx=1, name='lo', type='loopback', operational='carrier', administrative='unmanaged')
15:39:43 networkd-dispatcher[1144]: DEBUG:Path '/etc/networkd-dispatcher/unmanaged.d' does not exist; skipping
15:39:43 networkd-dispatcher[1144]: DEBUG:Path '/usr/lib/networkd-dispatcher/unmanaged.d' does not exist; skipping
15:39:43 networkd-dispatcher[1144]: DEBUG:Ignoring notification for interface NetworkctlListState(idx=1, name='lo', type='loopback', operational='carrier', administrative='unmanaged') entering state 'unmanaged': no triggers
15:39:43 networkd-dispatcher[1144]: DEBUG:Ignoring notification for interface NetworkctlListState(idx=1, name='lo', type='loopback', operational='carrier', administrative='unmanaged') entering state 'carrier': no triggers
15:39:43 networkd-dispatcher[1144]: DEBUG:Running immediate triggers for NetworkctlListState(idx=2, name='enp2s0', type='ether', operational='no-carrier', administrative='unmanaged')
15:39:43 networkd-dispatcher[1144]: DEBUG:Path '/etc/networkd-dispatcher/unmanaged.d' does not exist; skipping
15:39:43 networkd-dispatcher[1144]: DEBUG:Path '/usr/lib/networkd-dispatcher/unmanaged.d' does not exist; skipping
15:39:43 networkd-dispatcher[1144]: DEBUG:Ignoring notification for interface NetworkctlListState(idx=2, name='enp2s0', type='ether', operational='no-carrier', administrative='unmanaged') entering state 'unmanaged': no triggers
15:39:44 networkd-dispatcher[1144]: DEBUG:Ignoring notification for interface NetworkctlListState(idx=2, name='enp2s0', type='ether', operational='no-carrier', administrative='unmanaged') entering state 'no-carrier': no triggers
15:39:44 networkd-dispatcher[1144]: DEBUG:Running immediate triggers for NetworkctlListState(idx=3, name='wlp3s0', type='wlan', operational='off', administrative='unmanaged')
15:39:44 networkd-dispatcher[1144]: DEBUG:Path '/etc/networkd-dispatcher/unmanaged.d' does not exist; skipping
15:39:44 networkd-dispatcher[1144]: DEBUG:Path '/usr/lib/networkd-dispatcher/unmanaged.d' does not exist; skipping
15:39:44 networkd-dispatcher[1144]: DEBUG:Ignoring notification for interface NetworkctlListState(idx=3, name='wlp3s0', type='wlan', operational='off', administrative='unmanaged') entering state 'unmanaged': no triggers
15:39:44 networkd-dispatcher[1144]: DEBUG:Ignoring notification for interface NetworkctlListState(idx=3, name='wlp3s0', type='wlan', operational='off', administrative='unmanaged') entering state 'off': no triggers
15:39:44 systemd[1]: Started Dispatcher daemon for systemd-networkd.
15:39:44 networkd-dispatcher[1144]: INFO:Startup complete
15:39:45 networkd-dispatcher[1144]: DEBUG:Signal: typ=dbus.String('org.freedesktop.network1.Link'), data=dbus.Dictionary({dbus.String('CarrierState'): dbus.String('carrier', variant_level=1), dbus.String('OperationalState'): dbus.String('carrier', variant_level=1)}, signature=dbus.Signature('sv')), path=dbus.ObjectPath('/org/freedesktop/network1/link/_32')
15:39:45 networkd-dispatcher[1144]: DEBUG:Ignoring notification for interface NetworkctlListState(idx=2, name='enp2s0', type='ether', operational='carrier', administrative='unmanaged') entering state 'carrier': no triggers
15:39:45 networkd-dispatcher[1144]: DEBUG:Signal: typ=dbus.String('org.freedesktop.network1.Manager'), data=dbus.Dictionary({dbus.String('OperationalState'): dbus.String('carrier', variant_level=1), dbus.String('CarrierState'): dbus.String('carrier', variant_level=1)}, signature=dbus.Signature('sv')), path=dbus.ObjectPath('/org/freedesktop/network1')
15:39:45 networkd-dispatcher[1144]: DEBUG:Ignoring signal received with unexpected typ dbus.String('org.freedesktop.network1.Manager')
15:39:46 networkd-dispatcher[1144]: DEBUG:Signal: typ=dbus.String('org.freedesktop.network1.Link'), data=dbus.Dictionary({dbus.String('AddressState'): dbus.String('routable', variant_level=1), dbus.String('OperationalState'): dbus.String('routable', variant_level=1)}, signature=dbus.Signature('sv')), path=dbus.ObjectPath('/org/freedesktop/network1/link/_32')
15:39:46 networkd-dispatcher[1144]: DEBUG:Ignoring notification for interface NetworkctlListState(idx=2, name='enp2s0', type='ether', operational='routable', administrative='unmanaged') entering state 'routable': no triggers
15:39:46 networkd-dispatcher[1144]: DEBUG:Signal: typ=dbus.String('org.freedesktop.network1.Manager'), data=dbus.Dictionary({dbus.String('OperationalState'): dbus.String('routable', variant_level=1), dbus.String('AddressState'): dbus.String('routable', variant_level=1)}, signature=dbus.Signature('sv')), path=dbus.ObjectPath('/org/freedesktop/network1')
15:39:46 networkd-dispatcher[1144]: DEBUG:Ignoring signal received with unexpected typ dbus.String('org.freedesktop.network1.Manager')
15:40:21 networkd-dispatcher[1144]: DEBUG:Signal: typ=dbus.String('org.freedesktop.network1.Link'), data=dbus.Dictionary({dbus.String('CarrierState'): dbus.String('off', variant_level=1), dbus.String('OperationalState'): dbus.String('off', variant_level=1)}, signature=dbus.Signature('sv')), path=dbus.ObjectPath('/org/freedesktop/network1/link/_34')
15:40:21 networkd-dispatcher[1144]: WARNING:Unknown index 4 seen, reloading interface list
15:40:21 networkd-dispatcher[1144]: DEBUG:Performed interface scan; state: <Dispatcher({'script_dir': '/etc/networkd-dispatcher:/usr/lib/networkd-dispatcher'})>
15:40:21 networkd-dispatcher[1144]: DEBUG:No change represented by operational state 'off' for interface 'docker0'
15:40:21 networkd-dispatcher[1144]: DEBUG:Signal: typ=dbus.String('org.freedesktop.network1.Link'), data=dbus.Dictionary({dbus.String('AddressState'): dbus.String('routable', variant_level=1)}, signature=dbus.Signature('sv')), path=dbus.ObjectPath('/org/freedesktop/network1/link/_34')
15:40:21 networkd-dispatcher[1144]: DEBUG:Signal: typ=dbus.String('org.freedesktop.network1.Link'), data=dbus.Dictionary({dbus.String('AdministrativeState'): dbus.String('unmanaged', variant_level=1)}, signature=dbus.Signature('sv')), path=dbus.ObjectPath('/org/freedesktop/network1/link/_34')
15:40:21 networkd-dispatcher[1144]: DEBUG:Path '/etc/networkd-dispatcher/unmanaged.d' does not exist; skipping
15:40:21 networkd-dispatcher[1144]: DEBUG:Path '/usr/lib/networkd-dispatcher/unmanaged.d' does not exist; skipping
15:40:21 networkd-dispatcher[1144]: DEBUG:Ignoring notification for interface NetworkctlListState(idx=4, name='docker0', type='bridge', operational='off', administrative='unmanaged') entering state 'unmanaged': no triggers
15:40:21 networkd-dispatcher[1144]: DEBUG:Signal: typ=dbus.String('org.freedesktop.network1.Link'), data=dbus.Dictionary({dbus.String('CarrierState'): dbus.String('no-carrier', variant_level=1), dbus.String('OperationalState'): dbus.String('no-carrier', variant_level=1)}, signature=dbus.Signature('sv')), path=dbus.ObjectPath('/org/freedesktop/network1/link/_34')
15:40:21 networkd-dispatcher[1144]: DEBUG:Ignoring notification for interface NetworkctlListState(idx=4, name='docker0', type='bridge', operational='no-carrier', administrative='unmanaged') entering state 'no-carrier': no triggers
如您所见,它于 15:39:11 启动,并于 15:39:44 启动完成,甚至在第一条日志和第二条日志之间也有 31 秒的时间间隔。
我不知道如何更深入地研究并找出时间滞后的问题。
任何指向解决方案的指针和资源都将受到赞赏。