Ubuntu 18.04 启动时间缓慢

Ubuntu 18.04 启动时间缓慢

为什么 Ubuntu budgie 18.10 在我的带 HDD 的上网本 ASUS X201EP 上启动需要这么长时间。没有双启动,上网本上只安装了 Ubuntu。Ubuntu 从 18.04 升级,没有全新安装。启动时间比 Ubuntu 18.04 长。

$ systemd-analyze
Startup finished in 3.327s (firmware) + 4.594s (loader) + 4.539s (kernel) + 
1min 18.844s (userspace) = 1min 31.306s
graphical.target reached after 1min 14.162s in userspace

$ systemd-analyze blame | head -20
 23.886s nmbd.service
 18.962s dev-sda2.device
 15.733s systemd-journal-flush.service
 13.936s udisks2.service
 12.884s networkd-dispatcher.service
 10.675s snapd.service
 10.005s ModemManager.service
 9.179s dev-loop7.device
 9.168s plymouth-quit-wait.service
 9.153s lightdm.service
 9.086s NetworkManager-wait-online.service
 9.030s ufw.service
 8.736s accounts-daemon.service
 8.647s dev-loop4.device
 8.535s dev-loop3.device
 8.434s dev-loop6.device
 8.290s dev-loop5.device
 7.993s NetworkManager.service
 7.964s dev-loop0.device
 7.544s dev-loop1.device

$ systemd-analyze critical-chain
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.

graphical.target @1min 14.162s
└─multi-user.target @1min 14.160s
  └─smbd.service @1min 10.516s +3.643s
    └─nmbd.service @46.627s +23.886s
      └─network-online.target @46.625s
        └─NetworkManager-wait-online.service @37.538s +9.086s
          └─NetworkManager.service @29.536s +7.993s
            └─dbus.service @29.523s
              └─basic.target @28.866s
                └─sockets.target @28.866s
                  └─snapd.socket @28.846s +19ms
                    └─sysinit.target @28.740s
                      └─apparmor.service @24.626s +4.113s
                        └─local-fs.target @24.611s
                          └─run-user-1000.mount @1min 7.287s
                            └─local-fs-pre.target @7.454s
                              └─systemd-tmpfiles-setup-dev.service @6.190s +1.26
                                └─systemd-sysusers.service @4.776s +1.411s
                                  └─systemd-remount-fs.service @4.522s +250ms
                                    └─systemd-journald.socket @4.423s

$ journalctl -b --unit smbd
-- Logs begin at Sat 2018-07-07 19:57:48 CEST, end at Wed 2018-10-24 21:45:47 CE
oct. 24 20:31:38 fred-X201EP systemd[1]: Starting Samba SMB Daemon...
oct. 24 20:31:42 fred-X201EP systemd[1]: Started Samba SMB Daemon.

$ journalctl -b --unit nmbd
-- Logs begin at Sat 2018-07-07 19:57:48 CEST, end at Wed 2018-10-24 21:51:09 CE
oct. 24 20:31:15 fred-X201EP systemd[1]: Starting Samba NMB Daemon...
oct. 24 20:31:38 fred-X201EP systemd[1]: Started Samba NMB Daemon.

sudo systemctl stop smbd 
sudo systemctl disable smbd 
sudo systemctl disable NetworkManager-wait-online.service 

$ systemd-analyze critical-chain

graphical.target @1min 13.716s
└─multi-user.target @1min 13.716s
  └─nmbd.service @36.178s +37.536s
    └─network-online.target @36.176s
      └─network.target @36.174s
        └─NetworkManager.service @28.766s +7.405s
          └─dbus.service @28.714s
            └─basic.target @28.706s
              └─sockets.target @28.706s
                └─snapd.socket @28.680s +26ms
                  └─sysinit.target @28.630s
                    └─apparmor.service @24.894s +3.735s
                      └─local-fs.target @24.892s
                        └─run-user-1000.mount @1min 6.484s
                          └─local-fs-pre.target @6.986s
                            └─keyboard-setup.service @4.537s +2.449s
                              └─systemd-journald.socket @4.535s
                                └─-.mount @4.506s
                                  └─system.slice @4.506s
                                    └─-.slice @4.506s

`

表明桑巴网络管理器-等待在线.服务现在不要在启动期间启动,这样就快了 1 分 10.516 秒 +3.643 秒和 37.538 秒 +9.086 秒。但我仍然得到这个:

$ systemd-analyze 
Startup finished in 3.312s (firmware) + 4.447s (loader) + 4.513s (kernel) + 1min 16.469s (userspace) = 1min 28.743s 
graphical.target reached after 1min 13.716s in userspace 

启动时间仍然接近 3 分钟,但是 systemd-analyze 我用时钟测量了启动时间为 2 分钟,为什么会有这样的差异?因为桑巴网络管理器-等待在线.服务禁用,systemd-analyze应该显示更快的启动时间?

systemd-analyze blame | head -20

     `23.031s systemd-journal-flush.service
     19.634s dev-sda2.device
     14.908s udisks2.service
     13.562s ufw.service
     11.586s networkd-dispatcher.service
     11.428s ModemManager.service
     10.517s lightdm.service
     10.486s plymouth-quit-wait.service
      9.811s snapd.service
      8.519s accounts-daemon.service
      8.076s dev-loop6.device
      7.916s dev-loop3.device
      7.779s dev-loop7.device
      7.572s dev-loop0.device
      7.093s avahi-daemon.service
      6.804s dev-loop4.device
      6.743s dev-loop1.device
      6.692s apparmor.service
      6.641s systemd-logind.service
      6.641s thermald.service`

答案1

  • 尝试禁用 samba:

    sudo systemctl stop smbd
    sudo systemctl disable smbd
    

    如果您还有其他问题:

    sudo systemctl mask smbd 
    
  • 根据NetworkManager-wait-online.service @37.538s +9.086s,尝试禁用此服务:

    sudo systemctl disable NetworkManager-wait-online.service
    

    有关此问题的更多信息,请访问:https://askubuntu.com/a/1018731/790920

相关内容