Ubuntu 20.04 启动时间过长

Ubuntu 20.04 启动时间过长

我在使用 Ubuntu 时遇到了启动速度非常慢的问题,

$ systemd-analyze time
Startup finished in 9.143s (kernel) + 2min 4.895s (userspace) = 2min 14.038s 
graphical.target reached after 2min 4.885s in userspace

这太长了,我使用的也不是史前机器,处理器是英特尔 i5-4200M,还可以,应该花不了 2 分钟。

另外,自从我第一次在这台机器上安装 Ubuntu(大约一年前)以来,我就遇到了这个问题,之前我已经重新安装了 Ubuntu 很多次,但问题仍然存在。

$ systemd-analyze plot > init1.svg

给我(Imgur 不支持 svg,所以必须与链接有关):https://svgshare.com/i/Vx5.svg

这里有一些额外的信息;

$ systemd-analyze blame
1min 20.804s vboxdrv.service                                      
 39.768s snapd.service                                        
 33.076s dev-sda6.device                                      
 21.262s networkd-dispatcher.service                          
 16.373s udisks2.service                                      
 12.864s NetworkManager.service                               
 12.204s NetworkManager-wait-online.service                   
 11.933s accounts-daemon.service                              
 11.776s apache2.service                                      
 11.567s dev-loop45.device                                    
 11.422s dev-loop48.device                                    
 11.399s dev-loop46.device                                    
 11.332s dev-loop44.device                                    
 11.246s dev-loop47.device                                    
 11.148s dev-loop30.device                                    
 11.116s ufw.service                                          
 10.892s dev-loop35.device                                    
 10.771s loadcpufreq.service                                  
 10.661s dev-loop43.device                                    
 10.430s dev-loop42.device                                    
 10.327s dev-loop39.device                                    
 10.234s systemd-journal-flush.service                        
 10.219s dev-loop41.device                                    
 10.110s dev-loop40.device                                    
  9.967s dev-loop37.device                                    
  9.944s dev-loop38.device                                    
  9.705s ModemManager.service                                 
  9.640s dev-loop36.device                                    
  9.466s dev-loop34.device                                    
  9.274s dev-loop33.device                                    
  9.041s thermald.service                                     
  8.999s dev-loop32.device                                    
  8.961s teamviewerd.service                                  
  8.926s dev-loop25.device                                    
  8.893s dev-loop27.device                                    
  8.864s dev-loop31.device                                    
  8.803s snap-anbox-186.mount                                 
  8.746s snap-authy-5.mount                                   
  8.731s dev-loop23.device                                    
  8.644s snap-cheat-2681.mount                                
  8.633s snap-cheat-2698.mount                                
  8.615s snap-cmake-834.mount                                 
  8.594s snap-cmake-846.mount                                 
  8.588s dev-loop29.device                                    
  8.545s wpa_supplicant.service                               
  8.487s snap-code-60.mount                                   
  8.467s dev-loop28.device                                    
  8.209s dev-loop26.device                                    
  8.045s dev-loop24.device                                    
  7.903s polkit.service                                       
  7.815s dev-loop22.device                                    
  7.794s dev-loop21.device                                    
  7.763s dev-loop19.device                                    
  7.494s dev-loop9.device                                     
  7.255s dev-loop8.device                                     
  7.112s avahi-daemon.service                                 
  7.084s dev-loop20.device                                    
  7.077s snap-code-61.mount                                   
  7.040s switcheroo-control.service                           
  7.033s systemd-logind.service                               
  6.921s dev-loop18.device                                    
  6.777s systemd-rfkill.service                               
  6.601s snap-core-10908.mount                                
  6.601s dev-loop17.device                                    
  6.594s snap-core-10958.mount                                
  6.560s dev-loop16.device                                    
  6.428s dev-loop15.device                                    
  6.300s snap-core18-1988.mount                               
  6.254s dev-loop14.device                                    
  6.099s dev-loop13.device                                    
  5.847s dev-loop11.device                                    
  5.833s dev-loop12.device                                    
  5.708s snap-core18-1997.mount                               
  5.666s snap-core20-904.mount                                
  5.582s dev-loop7.device                                     
  5.581s dev-loop10.device                                    
  5.447s gpu-manager.service                                  
  5.249s dev-loop0.device                                     
  5.245s dev-loop6.device                                     
  5.221s dev-loop2.device                                     
  5.058s dev-loop4.device                                     
  4.911s dev-loop1.device                                     
  4.811s dev-loop3.device                                     
  4.639s dev-loop5.device                                     
  4.619s grub-common.service                                  
  4.600s apt-daily-upgrade.service                            
  4.562s apport.service                                       
  4.118s e2scrub_reap.service                                 
  3.602s rsyslog.service                                      
  3.221s systemd-tmpfiles-clean.service                       
  2.904s snap-core20-975.mount                                
  2.877s snap-freecad-19.mount                                
  2.866s snap-freecad-22.mount                                
  2.831s snapd.apparmor.service                               
  2.609s lxc-net.service                                      
  2.208s apparmor.service                                     
  1.777s snap-gnome\x2d3\x2d28\x2d1804-145.mount              
  1.776s snap-gnome\x2d3\x2d34\x2d1804-60.mount               
  1.771s snap-gnome\x2d3\x2d34\x2d1804-66.mount               
  1.702s snap-go-7013.mount                                   
  1.700s snap-go-7221.mount                                   
  1.693s snap-gradle-59.mount                                 
  1.680s snap-gradle-78.mount                                 
  1.678s snap-gtk\x2dcommon\x2dthemes-1513.mount              
  1.677s snap-gtk\x2dcommon\x2dthemes-1514.mount              
  1.675s snap-htop-2069.mount                                 
  1.660s snap-htop-2185.mount                                 
  1.622s snap-kde\x2dframeworks\x2d5\x2dcore18-32.mount       
  1.617s lxc.service                                          
  1.608s snap-ncspot-85.mount                                 
  1.600s snap-nmap-2254.mount                                 
  1.567s snap-nmap-2280.mount                                 
  1.563s grub-initrd-fallback.service                         
  1.535s snap-notepad\x2dplus\x2dplus-258.mount               
  1.524s snap-notepad\x2dplus\x2dplus-260.mount               
  1.510s snap-pdftk-9.mount                                   
  1.508s snap-snap\x2dstore-518.mount                         
  1.507s snap-snapd-11402.mount                               
  1.499s snap-snapd-11588.mount                               
  1.459s snap-spt-264.mount                                   
  1.458s snap-spt-271.mount                                   
  1.436s snap-telegram\x2dcli-34.mount                        
  1.429s systemd-resolved.service                             
  1.399s snap-telegram\x2ddesktop-2480.mount                  
  1.384s snap-telegram\x2ddesktop-2551.mount                  
  1.068s phpsessionclean.service                              
  1.054s systemd-udevd.service                                
  1.024s kerneloops.service                                   
   987ms pppd-dns.service                                     
   954ms upower.service                                       
   945ms systemd-backlight@backlight:intel_backlight.service  
   941ms systemd-udev-trigger.service                         
   889ms systemd-modules-load.service                         
   794ms lm-sensors.service                                   
   785ms systemd-user-sessions.service                        
   761ms swapfile.swap                                        
   702ms systemd-tmpfiles-setup-dev.service                   
   635ms systemd-sysusers.service                             
   605ms systemd-tmpfiles-setup.service                       
   577ms plymouth-quit.service                                
   541ms systemd-sysctl.service                               
   457ms dev-hugepages.mount                                  
   456ms dev-mqueue.mount                                     
   455ms sys-kernel-debug.mount                               
   453ms keyboard-setup.service                               
   453ms systemd-journald.service                             
   452ms kmod-static-nodes.service                            
   451ms [email protected]                                 
   442ms systemd-fsck@dev-disk-by\x2duuid-E3EC\x2dEBB0.service
   417ms snap-tetris\x2dthefenriswolf-4.mount                 
   400ms atopacct.service                                     
   399ms snap-tizonia-482.mount                               
   398ms snap-tizonia-503.mount                               
   350ms setvtrgb.service                                     
   344ms systemd-timesyncd.service                            
   300ms rtkit-daemon.service                                 
   275ms plymouth-start.service                               
   260ms sddm.service                                         
   226ms bluetooth.service                                    
   205ms systemd-random-seed.service                          
   201ms console-setup.service                                
   201ms snap-vlc-2103.mount                                  
   192ms snap-wine\x2dplatform\x2d5\x2dstable-16.mount        
   166ms apport-autoreport.service                            
   160ms plymouth-read-write.service                          
   152ms snap-wine\x2dplatform\x2druntime-216.mount           
   149ms [email protected]                                    
   145ms snap-wine\x2dplatform\x2druntime-212.mount           
   130ms boot-efi.mount                                       
   124ms systemd-remount-fs.service                           
   101ms snapd.seeded.service                                 
    88ms openvpn.service                                      
    56ms systemd-update-utmp.service                          
    46ms cpufrequtils.service                                 
    41ms motd-news.service                                    
    27ms vboxweb-service.service                              
    26ms [email protected]                        
    25ms vboxballoonctrl-service.service                      
    24ms vboxautostart-service.service                        
     7ms alsa-restore.service                                 
     6ms systemd-update-utmp-runlevel.service                 
     4ms sys-fs-fuse-connections.mount                        
     3ms sys-kernel-config.mount                              
   596us snapd.socket

从这里我可以看到

1分钟20.804秒vboxdrv.service39.768
秒snapd.service33.076
秒dev-sda6.device21.262
秒networkd-dispatcher.service16.373秒
udisks2.service

很可能是罪魁祸首,现在有办法禁用它们吗?我应该完全禁用它们吗?我有一个 /dev/sda6,所以我认为不应该禁用它。

$ 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 @2min 4.885s
└─multi-user.target @2min 4.885s
  └─vboxweb-service.service @2min 4.858s +27ms
    └─network-online.target @1min 9.043s
      └─NetworkManager-wait-online.service @56.838s +12.204s
        └─NetworkManager.service @43.973s +12.864s
          └─dbus.service @43.970s
            └─basic.target @43.948s
              └─sockets.target @43.948s
                └─snapd.socket @43.948s +596us
                  └─sysinit.target @43.868s
                    └─snapd.apparmor.service @41.036s +2.831s
                      └─apparmor.service @38.813s +2.208s
                        └─local-fs.target @38.812s
                          └─run-snapd-ns-anbox.mnt.mount @58.454s
                            └─run-snapd-ns.mount @57.779s
                              └─local-fs-pre.target @7.442s
                                └─systemd-tmpfiles-setup-dev.service @6.739s +702ms
                                  └─systemd-sysusers.service @6.102s +635ms
                                    └─systemd-remount-fs.service @5.215s +124ms
                                      └─systemd-journald.socket @4.761s
                                        └─system.slice @4.757s
                                          └─-.slice @4.757s



 

如果您需要更多信息,请告诉我,我会添加。

编辑:

我的 dmesg 输出(太大因此 pastebin 链接):https://pastebin.com/E1DdC5rT

相关内容