Ubuntu 20.04 启动速度极慢

Ubuntu 20.04 启动速度极慢

在过去的几个月里,尤其是升级到 Ubuntu 20.04 之后,启动变得非常慢。我今天记录了以下时间:

  • 从打开笔记本电脑到屏幕上出现密码请求 - 02:40.24
  • 输入密码后,桌面出现 - 01:53.58

以下是有关我的系统的一些信息:

Desktop: Gnome 3.36.9 Distro: Ubuntu 20.04.3 LTS (Focal Fossa)
Type: Laptop System: Dell product: Latitude E6410
Topology: Dual Core model: Intel Core i5 M 560 bits: 64 type: MT MCP 
  L2 cache: 3072 KiB 

跑步后systemd-analyze

Startup finished in 4.884s (kernel) + 2min 8.324s (userspace) = 2min 13.208s 
graphical.target reached after 2min 7.779s in userspace

一些输出systemd-analyze blame

1min 14.416s plymouth-quit-wait.service                                               
 1min 8.179s fwupd.service                                                            
 1min 6.091s mysql.service                                                            
     52.731s snapd.service                                                            
     41.142s [email protected]                                               
     37.991s ua-messaging.service                                                     
     34.569s vboxdrv.service                                                          
     32.004s dev-sda5.device                                                          
     31.959s networkd-dispatcher.service                                              
     28.590s [email protected]                                                      
     24.746s systemd-journal-flush.service                                            
     23.763s apport-autoreport.service                                                
     23.591s apache2.service                                                          
     22.546s udisks2.service                                                          
     18.203s accounts-daemon.service                                                  
     16.181s dev-loop19.device                                                        
     16.133s NetworkManager-wait-online.service                                       
     15.961s dev-loop12.device                                                        
     15.744s ModemManager.service                                                     
     15.728s dev-loop21.device                                                        
     15.717s dev-loop23.device                                                        
     15.610s dev-loop25.device                                                        
     15.307s dev-loop22.device                                                        
     15.285s dev-loop24.device                                                        
     15.227s dev-loop13.device                                                        
     14.943s dev-loop17.device                                                        
     14.389s dev-loop18.device                                                        
     14.101s dev-loop4.device                                                         
     13.544s dev-loop15.device                                                        
     13.231s dev-loop20.device                                                        
     13.150s NetworkManager.service                                                   
     13.043s avahi-daemon.service                                                     
     12.515s polkit.service                                                           
     12.434s grub-common.service                                                      
     12.051s dev-loop7.device                                                         
     11.738s dev-loop16.device                                                        
     11.714s dev-loop11.device                                                        
     11.703s dev-loop9.device                                                         
     11.687s dev-loop10.device   

   

最后,输出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 7.779s
└─multi-user.target @2min 7.779s
  └─mysql.service @53.227s +1min 6.091s
    └─network.target @52.904s
      └─NetworkManager.service @39.753s +13.150s
        └─dbus.service @39.741s
          └─basic.target @39.576s
            └─sockets.target @39.576s
              └─snapd.socket @39.574s +1ms
                └─sysinit.target @39.422s
                  └─swap.target @39.422s
                    └─dev-disk-by\x2duuid-30378a1f\x2ddb3d\x2d468b\x2dbc15\x2d5545a99daaaf.swap @39.193s +228ms
                      └─dev-disk-by\x2duuid-30378a1f\x2ddb3d\x2d468b\x2dbc15\x2d5545a99daaaf.device @39.192s

由于我对 Linux 还不是很熟悉,有人能看出有什么需要修复,以便我可以恢复到合理的启动时间吗?

答案1

这是一个相当简朴的 Ubuntu 20.04

$ systemd-analyze
启动耗时 6.458 秒(固件)+ 4.588 秒(加载器)+ 2.911 秒(内核)+ 9.150 秒(用户空间)= 23.108 秒
用户空间中 9.136 秒后达到 graphic.target

$ systemd-analyze 关键链
在“@”字符后打印单元激活或启动的时间。
设备启动所需的时间打印在“+”字符后面。

graphic.target @9.136s
└─multi-user.target @9.136s
  └─kerneloops.service @8.674秒+18毫秒
    └─network-online.target @8.672s
      └─NetworkManager-wait-online.service @2.341s +6.330s
        └─NetworkManager.service @2.224s +115ms
          └─dbus.service @2.221s
            └─basic.target @2.209秒
              └─sockets.target @2.209s
                └─snapd.socket @2.207s +1ms
                  └─sysinit.target @2.201s
                    └─systemd-timesyncd.service @2.065s +135ms
                      └─systemd-tmpfiles-setup.service @2.028s +32ms
                        └─local-fs.target @2.025s
                          └─run-user-125-gvfs.mount @3.152s
                            └─run-user-125.mount @2.975s
                              └─swap.target @2.057秒
                                └─dev-disk-by\x2duuid-ed163828\x2d666c\x2d4dae\x2db43c\x2dce7dd1d8bdd2.swap @1.987s +69ms
                                  └─dev-disk-by\x2duuid-ed163828\x2d666c\x2d4dae\x2db43c\x2dce7dd1d8bdd2.device @1.983s

我想说的是,您需要查看在启动/登录时需要启动哪些 SW 包。

MySQL 和 Apache 可能会引起你的兴趣。

$ systemd-analyze blame #所有输出

6.777s plymouth-退出-等待.服务                                               
6.330s NetworkManager-wait-online.service                                       
1.640s dev-nvme0n1p3.device                                                     
 913ms snapd.service                                                            
 631ms systemd-logind.service                                                   
 544ms fwupd.服务                                                            
 458ms dev-loop1.device                                                         
 391ms dev-loop2.device                                                         
 333ms udisks2.service                                                          
 309ms dev-loop5.device                                                         
 303ms dev-loop3.device                                                         
 298ms dev-loop4.device                                                         
 227ms accounts-daemon.service                                                  
 208ms snap-gnome\x2d3\x2d34\x2d1804-72.mount                                   
 206ms snap-snapd-13640.mount                                                   
 202ms snap-snap\x2dstore-547.mount                                             
 197ms systemd-resolved.service                                                 
 186ms networkd-dispatcher.service                                              
 174ms snap-bare-5.mount                                                        
 172ms snap-gtk\x2dcommon\x2dthemes-1519.mount                                  
 137ms upower.服务                                                           
 135ms systemd-timesyncd.服务                                                
 133ms dev-loop0.device                                                         
 130ms systemd-rfkill.service                                                   
 118ms snap-core18-2246.mount                                                   
 117ms systemd-udev-trigger.service                                             
 117ms avahi-daemon.service                                                     
 116ms 蓝牙服务                                                        
 115ms NetworkManager.service                                                   
 108ms apparmor.service                                                         
 105ms polkit.service                                                           
  99ms systemd-journald.service                                                 
  89ms 键盘设置服务                                                   
  86毫秒[电子邮件保护]                                                         
  86ms switcheroo-control.service                                               
  86ms apport.服务                                                           
  81ms thermald.service                                                         
  77ms wpa_supplicant.service                                                   
  77毫秒[电子邮件保护]                                                        
  77ms systemd-udevd.service                                                    
  73ms grub-common.service                                                      
  69ms dev-disk-by\x2duuid-ed163828\x2d666c\x2d4dae\x2db43c\x2dce7dd1d8bdd2.swap
 67ms gpu-manager.service                                                      
  52ms systemd-journal-flush.service                                            
  47ms ModemManager.服务                                                     
  46ms systemd-modules-load.service                                             
  44ms snapd.apparmor.service                                                   
  42ms secureboot-db.service                                                    
  35毫秒 e2scrub_reap.service                                                     
  33ms rsyslog.服务                                                          
  32ms systemd-tmpfiles-setup.service                                           
  30ms plymouth-start.service                                                   
  29ms systemd-fsck@dev-disk-by\x2duuid-32BD\x2d13BA.service                    
  27ms gdm.服务                                                              
  26毫秒[电子邮件保护]                                                     
  26ms nvidia-persistenced.service                                              
  23ms systemd-random-seed.service                                              
  22ms systemd-tmpfiles-clean.service                                           
  21ms colord.service                                                           
  21ms pppd-dns.服务                                                         
  21ms snapd.seed.service                                                     
  20ms alsa-restore.service                                                     
  19ms systemd-backlight@leds:asus::kbd_backlight.service                       
  19ms systemd-sysusers.service                                                 
  19ms 系统内核跟踪.mount                                                 
  19ms 系统内核调试.mount                                                   
  18ms dev-mqueue.mount                                                         
  18ms dev-hugepages.mount                                                      
  18ms kerneloops.service                                                       
  18ms systemd-tmpfiles-setup-dev.service                                       
  15ms systemd-remount-fs.service                                               
  14毫秒[电子邮件保护]                                             
  14ms kmod-静态节点.service                                                
  14ms systemd-sysctl.service                                                   
  12ms systemd-update-utmp.service                                              
  11ms plymouth-read-write.service                                              
  10毫秒[电子邮件保护]                                            
  10ms grub-initrd-fallback.service                                             
   9ms systemd-update-utmp-runlevel.service                                     
   9ms systemd-用户会话.服务                                            
   9ms ufw.服务                                                              
   8ms systemd-backlight@backlight:intel_backlight.service                      
   7ms rtkit-daemon.service                                                     
   6ms 启动-efi.mount                                           
  6ms 系统文件系统保险丝连接.mount                                            
   5ms 系统内核配置.mount                                                  
   4ms openvpn.服务                                                          
   3ms setvtrgb.服务                                                         
   3ms 控制台设置.服务                                                    
   1ms snapd.socket        

相关内容