为什么 Ubuntu 启动速度这么慢?矛盾的消息

为什么 Ubuntu 启动速度这么慢?矛盾的消息

我一直在浏览这些论坛,试图弄清楚到底发生了什么。首先:

pc@my_pc: uname -a
Linux my_pc 5.8.0-45-generic #51-Ubuntu SMP Fri Feb 19 13:24:51 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

我的电脑是联想 Legion Y545,正在运行 Ubuntu 20.10 和 Windows 双启动。

今天早上我遇到了启动缓慢的问题。以下是我遇到的情况:

pc@my_pc: systemd-analyze time
Startup finished in 6.568s (firmware) + 4.890s (loader) + 5.536s (kernel) + 2min 31.339s (userspace) = 2min 48.334s 
graphical.target reached after 2min 31.330s in userspace
pc@my_pc: systemd-analyze blame 
1min 55.831s plymouth-quit-wait.service                           
     26.497s apt-daily-upgrade.service                            
     24.608s man-db.service                                       
     17.170s systemd-journal-flush.service                        
     15.791s networkd-dispatcher.service                          
     14.018s dev-sda4.device                                      
     13.332s udisks2.service                                      
     12.832s snapd.service                                        
     11.636s logrotate.service                                    
     11.411s accounts-daemon.service                              
      7.947s avahi-daemon.service                                 
      7.943s bluetooth.service                                    
      7.934s NetworkManager.service                               
      7.893s apache2.service                                      
      7.872s polkit.service                                       
      7.300s dev-loop5.device                                     
      6.689s dev-loop6.device                                     
      6.627s dev-loop9.device                                     
      6.238s dev-loop12.device                                    
      5.895s dev-loop11.device                                    
      5.859s dev-loop7.device                                     
      5.775s dev-loop4.device                                     
      5.755s dev-loop8.device                                     
      5.615s fwupd.service                                        
      5.603s dev-loop0.device                                     
      5.556s dev-loop10.device                                    
      5.420s gdm.service                                          
      5.413s switcheroo-control.service                           
      5.162s ModemManager.service                                 
      5.034s apport.service                                       
      4.841s systemd-resolved.service                             
      4.750s grub-common.service                                  
      4.540s systemd-logind.service                               
      4.539s thermald.service                                     
      4.537s wpa_supplicant.service                               
      4.509s apparmor.service                                     
      4.157s dev-loop1.device                                     
      4.078s dev-loop2.device                                     
      3.920s secureboot-db.service                                
      3.919s rsyslog.service                                      
      3.661s e2scrub_reap.service                                 
      3.660s gpu-manager.service                                  
      3.563s nvidia-persistenced.service                          
      3.562s pppd-dns.service                                     
      3.173s upower.service                                       
      2.359s systemd-udevd.service                                
      2.084s colord.service                                       
      2.073s systemd-rfkill.service                               
      1.486s kerneloops.service                                   
      1.255s systemd-random-seed.service                          
      1.169s openvpn.service                                      
      1.161s systemd-sysusers.service
pc@my_pc: systemd-analyze critical chain
graphical.target @2min 31.330s
└─multi-user.target @2min 31.330s
  └─snapd.service @2min 18.496s +12.832s
    └─snap-snapd-11402.mount @1min 54.289s +29ms
      └─dev-loop13.device @1min 54.316s +2ms

我的第一个想法是“普利茅斯退出等待服务是罪魁祸首“。根据此链接由于 plymouth-quit-wait.service + ubuntu 18.04 导致启动缓慢的问题但事实并非如此。我的第二个想法是,通过查看关键链输出,我可以看到发生了什么。我看到 dev-loop13.device 似乎花费了很多时间。然而,在 blame 输出中,dev-loop13.device 只占用了 2ms 的时间。Snapd 服务也存在同样的差异。

最后我使用 plymouth-quit-wait.service 作为 critical-chain 的参数。下面是我得到的结果

pc@my_pc: systemd-analyze critical-chain plymouth-quit-wait.service
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.

plymouth-quit-wait.service +1min 55.831s
└─systemd-user-sessions.service @32.380s +212ms
  └─network.target @31.581s
    └─NetworkManager.service @23.646s +7.934s
      └─dbus.service @23.638s
        └─basic.target @23.589s
          └─sockets.target @23.588s
            └─snapd.socket @23.584s +2ms
              └─sysinit.target @23.439s
                └─systemd-timesyncd.service @23.243s +195ms
                  └─systemd-tmpfiles-setup.service @22.130s +1.066s
                    └─systemd-journal-flush.service @4.959s +17.170s
                      └─systemd-journald.service @4.224s +734ms
                        └─systemd-journald.socket @4.209s
                          └─system.slice @3.295s
                            └─-.slice @3.295s

不用说,我有点迷茫了。这里的其他帖子有更具体的问题,问题从错误消息中或多或少可以清楚看出。我不确定如何解释我的消息。问题到底是什么?我该如何解决?有什么建议吗?

相关内容