如何调试 Ubuntu 20.04 上的启动缓慢问题

如何调试 Ubuntu 20.04 上的启动缓慢问题

自从在我的联想 Flex2 Pro 15 上安装 Ubuntu 20.04 以来,从按下电源按钮到屏幕上出现 LENOVO 徽标的时间异常长,超过 30 秒。在此期间屏幕完全是黑色的。

当 LENOVO 徽标最终显示出来后,Ubuntu 徽标紧随其后,启动顺序按预期进行。速度不是特别快,但还不错。

当我安装 Ubuntu 18.04 时情况并非如此(它在启动时没有显示 LENOVO 徽标),所以我怀疑新的徽标功能可能与此问题有关。

我确实启用了 SecureBoot,但我不确定这是否相关。我记得我在 18.04 上也启用了 SecureBoot,但正如所说,我没有遇到启动缓慢的问题。

此外,当我在屏幕黑屏期间按下任意键(F2/Setup 或 F12/Boot 菜单除外)时,屏幕都会无限期地保持黑屏状态并且系统似乎挂起了。

输出systemd-analyze blame

5.177s plymouth-quit-wait.service                                                               
4.186s NetworkManager-wait-online.service                                                       
3.374s dev-sda2.device                                                                          
2.362s dev-loop10.device                                                                        
2.317s dev-loop8.device                                                                         
2.231s dev-loop9.device                                                                         
2.227s snapd.service                                                                            
2.216s dev-loop11.device                                                                        
2.146s dev-loop14.device                                                                        
2.111s dev-loop15.device                                                                        
2.103s dev-loop13.device                                                                        
2.074s dev-loop16.device                                                                        
2.059s dev-loop12.device                                                                        
2.047s dev-loop18.device                                                                        
2.036s dev-loop17.device                                                                        
2.033s dev-loop19.device                                                                        
2.028s dev-loop20.device                                                                        
1.916s [email protected]                                                                        
1.871s dev-loop3.device                                                                         
1.862s dev-loop2.device                                                                         
1.858s dev-loop23.device                                                                        
1.841s dev-loop25.device                                                                        
1.826s dev-loop21.device                                                                        
1.811s dev-loop26.device                                                                        
1.807s dev-loop24.device                                                                        
1.798s dev-loop22.device                                                                        
1.765s dev-loop4.device                                                                         
1.735s dev-loop5.device                                                                         
1.723s dev-loop27.device                                                                        
1.699s dev-loop1.device                                                                         
1.677s dev-loop0.device                                                                         
1.672s dev-loop7.device                                                                         
1.649s dev-loop29.device                                                                        
1.611s dev-loop6.device                                                                         
1.602s dev-loop31.device                                                                        
1.597s dev-loop28.device                                                                        
1.585s dev-loop30.device                                                                        
1.350s systemd-journal-flush.service                                                            
1.255s snap-speedy\x2dduplicate\x2dfinder-22.mount                                              
1.254s snap-speedy\x2dduplicate\x2dfinder-27.mount                                              
1.217s snap-snapd-8790.mount                                                                    
1.194s snap-warzone2100-1573.mount                                                              
1.156s snap-scrcpy-238.mount                                                                    
1.071s snap-warzone2100\x2dvideos-2.mount                                                       
1.067s snap-keepassxc-1006.mount                                                                
1.064s systemd-udevd.service                                                                    
1.052s snap-obs\x2dstudio-1090.mount                                                            
1.044s snap-scrcpy-243.mount                                                                    
1.032s snap-snapd-8542.mount                                                                    
1.010s snap-snap\x2dstore-467.mount                                                             
 986ms networkd-dispatcher.service                                                              
 972ms systemd-rfkill.service                                                                   
 875ms snap-gnome\x2d3\x2d34\x2d1804-36.mount                                                   
 863ms snap-kde\x2dframeworks\x2d5\x2dcore18-32.mount                                           
 847ms snap-signal\x2ddesktop-326.mount                                                         
 809ms snap-sweethome3d\x2dhomedesign-9.mount                                                   
 747ms snap-keepassxc-978.mount                                                                 
 746ms snap-minetest-1521.mount                                                                 
 657ms snap-minetest-1619.mount                                                                 
 628ms snap-snap\x2dstore-454.mount                                                             
 621ms udisks2.service                                                                          
 597ms snap-core18-1880.mount                                                                   
 595ms snap-obs\x2dstudio-1118.mount                                                            
 585ms snap-signal\x2ddesktop-327.mount                                                         
 564ms snap-core-9665.mount                                                                     
 559ms [email protected]                                                              
 555ms snap-gtk\x2dcommon\x2dthemes-1506.mount                                                  
 550ms snap-canonical\x2dlivepatch-95.mount                                                     
 544ms snap-intellij\x2didea\x2dcommunity-249.mount                                             
 511ms snap-core-9804.mount                                                                     
 473ms snap-gnome\x2d3\x2d28\x2d1804-128.mount                                                  
 466ms accounts-daemon.service                                                                  
 455ms systemd-logind.service                                                                   
 446ms plymouth-read-write.service                                                              
 417ms snap-intellij\x2didea\x2dcommunity-246.mount                                             
 372ms snap-core18-1885.mount                                                                   
 332ms upower.service                                                                           
 326ms NetworkManager.service                                                                   
 287ms snap-gimp-281.mount                                                                      
 287ms snap-gimp-292.mount                                                                      
 280ms snapper-boot.service                                                                     
 277ms systemd-resolved.service                                                                 
 276ms fwupd.service                                                                            
 259ms avahi-daemon.service                                                                     
 252ms bluetooth.service                                                                        
 224ms apport.service                                                                           
 223ms polkit.service                                                                           
 215ms motd-news.service                                                                        
 207ms snapd.apparmor.service                                                                   
 197ms ModemManager.service                                                                     
 195ms systemd-timesyncd.service                                                                
 193ms switcheroo-control.service                                                               
 185ms systemd-sysctl.service                                                                   
 184ms plymouth-start.service                                                                   
 180ms wpa_supplicant.service                                                                   
 179ms thermald.service                                                                         
 176ms grub-common.service                                                                      
 168ms gpu-manager.service                                                                      
 165ms rsyslog.service                                                                          
 162ms systemd-journald.service                                                                 
 160ms [email protected]                                                                        
 158ms systemd-modules-load.service                                                             
 154ms secureboot-db.service                                                                    
 150ms e2scrub_reap.service                                                                     
 147ms grub-initrd-fallback.service                                                             
 123ms colord.service                                                                           
 120ms systemd-sysusers.service                                                                 
 110ms apparmor.service                                                                         
 109ms systemd-random-seed.service                                                              
 109ms keyboard-setup.service                                                                   
 102ms systemd-fsck@dev-disk-by\x2duuid-EBBB\x2d0E8C.service                                    
  98ms home.mount                                                                               
  96ms systemd-udev-trigger.service                                                             
  91ms teamviewerd.service                                                                      
  82ms snapd.seeded.service                                                                     
  77ms systemd-tmpfiles-setup-dev.service                                                       
  77ms gdm.service                                                                              
  55ms systemd-update-utmp.service                                                              
  53ms pppd-dns.service                                                                         
  47ms kerneloops.service                                                                       
  46ms rtkit-daemon.service                                                                     
  44ms systemd-tmpfiles-setup.service                                                           
  43ms systemd-fsck@dev-disk-by\x2duuid-139a2ef0\x2d2474\x2d484d\x2dbde8\x2d192ade6e4696.service
  36ms openvpn.service                                                                          
  33ms run-rpc_pipefs.mount                                                                     
  29ms alsa-restore.service                                                                     
  28ms [email protected]                                                            
  27ms rpcbind.service                                                                          
  26ms systemd-remount-fs.service                                                               
  23ms systemd-tmpfiles-clean.service                                                           
  22ms systemd-user-sessions.service                                                            
  22ms [email protected]                                                                     
  20ms boot-efi.mount                                                                           
  19ms dev-hugepages.mount                                                                      
  19ms setvtrgb.service                                                                         
  18ms dev-mqueue.mount                                                                         
  16ms ufw.service                                                                              
  16ms sys-kernel-debug.mount                                                                   
  15ms sys-kernel-tracing.mount                                                                 
  14ms systemd-update-utmp-runlevel.service                                                     
  12ms systemd-backlight@backlight:intel_backlight.service                                      
  11ms kmod-static-nodes.service                                                                
  10ms console-setup.service                                                                    
   9ms nfs-config.service                                                                       
   5ms sys-fs-fuse-connections.mount                                                            
   3ms sys-kernel-config.mount                                                                  
   3ms swapfile.swap                                                                            
   2ms postfix.service                                                                          
   1ms snapd.socket

输出systemd-analyze critical-chain

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.

graphical.target @10.836s
└─multi-user.target @10.836s
  └─postfix.service @10.833s +2ms
    └─[email protected] @8.915s +1.916s
      └─network-online.target @8.912s
        └─NetworkManager-wait-online.service @4.724s +4.186s
          └─NetworkManager.service @4.396s +326ms
            └─dbus.service @4.385s
              └─basic.target @4.362s
                └─sockets.target @4.362s
                  └─snapd.socket @4.361s +1ms
                    └─sysinit.target @4.357s
                      └─snapd.apparmor.service @4.006s +207ms
                        └─apparmor.service @3.894s +110ms
                          └─local-fs.target @3.892s
                            └─run-snapd-ns-canonical\x2dlivepatch.mnt.mount @5.516s
                              └─run-snapd-ns.mount @5.048s
                                └─local-fs-pre.target @638ms
                                  └─systemd-tmpfiles-setup-dev.service @560ms +77ms
                                    └─systemd-sysusers.service @438ms +120ms
                                      └─systemd-remount-fs.service @406ms +26ms
                                        └─systemd-journald.socket @390ms
                                          └─system.slice @382ms
                                            └─-.slice @382ms

相关内容