Ubuntu 20.04 启动速度极慢

Ubuntu 20.04 启动速度极慢

我在 Ubuntu 20.04 上遇到了极慢的启动速度。我有一台联想 Thinkpad X201。对于我在另一个分区上安装的另一个 Ubuntu 18.04,启动时间不会那么长。

在终端中运行 dmesg 并读取输出显示以下可能与启动延迟有关的行:

[   39.616283] audit: type=1400 audit(1626546618.403:82): apparmor="DENIED" operation="open" profile="/{,usr/}sbin/dhclient" name="/proc/775/task/848/comm" pid=775 comm="dhclient" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[   39.616480] audit: type=1400 audit(1626546618.403:83): apparmor="DENIED" operation="open" profile="/{,usr/}sbin/dhclient" name="/proc/775/task/849/comm" pid=775 comm="dhclient" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[   39.616563] audit: type=1400 audit(1626546618.403:84): apparmor="DENIED" operation="open" profile="/{,usr/}sbin/dhclient" name="/proc/775/task/850/comm" pid=775 comm="dhclient" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[   62.154604] audit: type=1400 audit(1626546640.939:85): apparmor="DENIED" operation="capable" profile="/usr/sbin/cups-browsed" pid=971 comm="cups-browsed" capability=23  capname="sys_nice"
[  370.614154] aufs 5.4.3-20200302
[  370.614638] aufs aufs_fill_super:918:mount[1790]: no arg
[  370.744875] overlayfs: missing 'lowerdir'
[  388.973010] audit: type=1400 audit(1626546967.759:86): apparmor="DENIED" operation="ptrace" profile="snap.docker.dockerd" pid=1905 comm="ps" requested_mask="read" denied_mask="read" peer="/{,usr/}sbin/dhclient"
[  405.113288] Initializing XFRM netlink socket
[  483.800276] rfkill: input handler disabled
[  502.044283] audit: type=1400 audit(1626547080.831:91): apparmor="DENIED" operation="mknod" profile="/usr/share/hplip/systray.py" name="/var/crash/_usr_share_hplip_systray.py.1000.crash" pid=2732 comm="hp-systray" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000
[  626.132953] perf: interrupt took too long (2512 > 2500), lowering kernel.perf_event_max_sample_rate to 79500
[  951.554434] perf: interrupt took too long (3142 > 3140), lowering kernel.perf_event_max_sample_rate to 63500
[ 1251.050145] perf: interrupt took too long (3930 > 3927), lowering kernel.perf_event_max_sample_rate to 50750

启动需要那么长时间的原因是什么以及如何解决?


更多信息:

cat /etc/fstab 的输出:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=7dd9bc28-9780-4a60-9f94-87c3471f2089 /               ext4    errors=remount-ro 0       1
/swapfile                                 none            swap    sw              0       0

sudo blkid 的输出:

/dev/sda1: UUID="7dd9bc28-9780-4a60-9f94-87c3471f2089" TYPE="ext4" PARTUUID="d19045a2-01"
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/loop7: TYPE="squashfs"
/dev/sda2: UUID="a566bb53-bff0-452b-9eb8-5ae08eb31dd0" TYPE="ext4" PARTUUID="d19045a2-02"
/dev/sda5: UUID="17b4a94c-68db-418f-83be-4453f380a4d6" TYPE="ext4" PARTUUID="d19045a2-05"
/dev/loop8: TYPE="squashfs"
/dev/loop9: TYPE="squashfs"
/dev/loop10: TYPE="squashfs"
/dev/loop11: TYPE="squashfs"
/dev/loop12: TYPE="squashfs"
/dev/loop13: TYPE="squashfs"
/dev/loop14: TYPE="squashfs"
/dev/loop15: TYPE="squashfs"
/dev/loop16: TYPE="squashfs"
/dev/loop17: TYPE="squashfs"
/dev/loop18: TYPE="squashfs"
/dev/loop19: TYPE="squashfs"
/dev/loop20: TYPE="squashfs"
/dev/loop21: TYPE="squashfs"
/dev/loop22: TYPE="squashfs"
/dev/loop23: TYPE="squashfs"
/dev/loop24: TYPE="squashfs"
/dev/loop25: TYPE="squashfs"
/dev/loop26: TYPE="squashfs"
/dev/loop27: TYPE="squashfs"
/dev/loop28: TYPE="squashfs"
/dev/loop29: TYPE="squashfs"
/dev/loop30: TYPE="squashfs"
/dev/loop31: TYPE="squashfs"

systemd-analyze blame 的输出:

1min 15.451s apt-daily-upgrade.service                          
     43.216s ifupdown-pre.service                               
     41.231s dev-sda1.device                                    
     30.067s snapd.service                                      
     28.683s networkd-dispatcher.service                        
     27.266s dev-loop28.device                                  
     25.981s udisks2.service                                    
     25.328s dev-loop31.device                                  
     24.464s dev-loop12.device                                  
     24.307s dev-loop27.device                                  
     24.008s accounts-daemon.service                            
     23.806s dev-loop26.device                                  
     23.798s dev-loop23.device                                  
     23.590s dev-loop30.device                                  
     23.359s dev-loop29.device                                  
     23.130s dev-loop25.device                                  
     23.093s dev-loop13.device                                  
     22.859s networking.service                                 
     20.989s dev-loop22.device                                  
     20.909s dev-loop17.device                                  
     20.907s dev-loop24.device                                  
     20.905s dev-loop14.device                                  
     20.905s dev-loop11.device                                  
     19.782s dev-loop8.device                                   
     19.482s openvpnas.service                                  
     18.305s dev-loop9.device                                   
     18.304s dev-loop5.device                                   
     18.303s dev-loop6.device                                   
     18.301s dev-loop7.device                                   
     18.300s dev-loop16.device                                  
     18.297s dev-loop15.device                                  
     18.293s dev-loop19.device                                  
     16.610s dev-loop4.device                                   
     16.610s dev-loop2.device                                   
     16.609s dev-loop0.device                                   
     16.609s dev-loop1.device                                   
     16.607s dev-loop3.device                                   
     16.606s dev-loop10.device                                  
     16.603s dev-loop18.device                                  
     16.598s dev-loop20.device                                  
     16.597s dev-loop21.device                                  
     15.768s avahi-daemon.service                               
     15.294s NetworkManager.service                             
     15.178s polkit.service                                     
     14.492s switcheroo-control.service                         
     14.484s thermald.service                                   
     14.430s systemd-logind.service                             
     14.417s wpa_supplicant.service                             
     13.653s winbind.service                                    
     12.544s systemd-journal-flush.service                      
     11.046s grub-common.service                                
      9.978s apport.service                                     
      8.960s gpu-manager.service                                
      8.902s apache2.service                                    
      8.655s systemd-udevd.service                              
      8.618s NetworkManager-wait-online.service                 
      7.669s ModemManager.service                               
      6.905s rsyslog.service                                    
      6.046s teamviewerd.service                                
      4.932s apparmor.service                                   
      4.088s e2scrub_reap.service                               
      3.825s colord.service                                     
      3.223s lm-sensors.service                                 
      3.081s snapd.apparmor.service                             
      2.566s grub-initrd-fallback.service                       
      2.531s lightdm.service                                    
      2.525s plymouth-quit-wait.service                         
      2.514s systemd-sysctl.service                             
      2.484s systemd-tmpfiles-setup.service                     
      2.378s ssh.service                                        
      2.191s dns-clean.service                                  
      1.946s snap-audacity-756.mount                            
      1.884s snap-audacity-857.mount                            
      1.847s systemd-modules-load.service                       
      1.818s snap-chromium-1637.mount                           
      1.811s snap-chromium-1646.mount                           
      1.809s fwupd.service                                      
      1.753s snap-core-11187.mount                              
      1.728s snap-core-11316.mount                              
      1.615s keyboard-setup.service                             
      1.569s snapd.seeded.service                               
      1.539s snap-core18-2066.mount                             
      1.539s upower.service                                     
      1.522s snap-core18-2074.mount                             
      1.487s systemd-random-seed.service                        
      1.467s snap-core20-1026.mount                             
      1.393s snap-docker-471.mount                              
      1.325s snap-docker-796.mount                              
      1.219s snap-gnome\x2d3\x2d26\x2d1604-102.mount            
      1.198s snap-gnome\x2d3\x2d26\x2d1604-104.mount            
      1.143s snap-gnome\x2d3\x2d28\x2d1804-145.mount            
      1.133s systemd-timesyncd.service                          
      1.128s snap-gnome\x2d3\x2d28\x2d1804-161.mount            
      1.070s snap-gnome\x2d3\x2d34\x2d1804-66.mount             
      1.028s systemd-sysusers.service                           
      1.005s snap-gnome\x2d3\x2d34\x2d1804-72.mount             
       889ms snap-gnome\x2d3\x2d38\x2d2004-39.mount             
       861ms systemd-tmpfiles-setup-dev.service                 
       763ms snap-gnome\x2dsystem\x2dmonitor-160.mount          
       734ms snap-gnome\x2dsystem\x2dmonitor-163.mount          
       649ms snap-gtk2\x2dcommon\x2dthemes-13.mount             
       642ms [email protected]                               
       610ms snap-gtk2\x2dcommon\x2dthemes-9.mount              
       564ms snap-gtk\x2dcommon\x2dthemes-1514.mount            
       553ms phpsessionclean.service                            
       542ms snap-gtk\x2dcommon\x2dthemes-1515.mount            
       541ms systemd-udev-trigger.service                       
       494ms snap-handbrake\x2djz-142.mount                     
       438ms swapfile.swap                                      
       437ms systemd-backlight@backlight:acpi_video0.service    
       431ms snap-inkscape-9078.mount                           
       412ms console-setup.service                              
       404ms snap-inkscape-9090.mount                           
       386ms systemd-remount-fs.service                         
       320ms kerneloops.service                                 
       319ms systemd-update-utmp.service                        
       314ms systemd-journald.service                           
       283ms [email protected]                                  
       266ms ufw.service                                        
       263ms systemd-backlight@backlight:intel_backlight.service
       251ms setvtrgb.service                                   
       249ms snap-losslesscut-66.mount                          
       241ms snap-losslesscut-72.mount                          
       233ms plymouth-read-write.service                        
       225ms snap-snap\x2dstore-547.mount                       
1min 15.451s apt-daily-upgrade.service                          
1min 15.451s apt-daily-upgrade.service                          
     43.216s ifupdown-pre.service                               
     41.231s dev-sda1.device                                    
     30.067s snapd.service                                      
     28.683s networkd-dispatcher.service                        
     27.266s dev-loop28.device                                  
     25.981s udisks2.service                                    
     25.328s dev-loop31.device                                  
     24.464s dev-loop12.device                                  
     24.307s dev-loop27.device                                  
     24.008s accounts-daemon.service                            
     23.806s dev-loop26.device                                  
     23.798s dev-loop23.device                                  
     23.590s dev-loop30.device                                  
     23.359s dev-loop29.device                                  
     23.130s dev-loop25.device                                  
     23.093s dev-loop13.device                                  
     22.859s networking.service                                 
     20.989s dev-loop22.device                                  
     20.909s dev-loop17.device                                  
1min 15.451s apt-daily-upgrade.service                          
     43.216s ifupdown-pre.service                               
     41.231s dev-sda1.device                                    
     30.067s snapd.service                                      
     28.683s networkd-dispatcher.service                        
     27.266s dev-loop28.device                                  
     25.981s udisks2.service                                    
     25.328s dev-loop31.device                                  
     24.464s dev-loop12.device                                  
     24.307s dev-loop27.device                                  
     24.008s accounts-daemon.service                            
     23.806s dev-loop26.device                                  
     23.798s dev-loop23.device                                  
     23.590s dev-loop30.device                                  
     23.359s dev-loop29.device                                  
     23.130s dev-loop25.device                                  
     23.093s dev-loop13.device                                  
     22.859s networking.service                                 
     20.989s dev-loop22.device                                  
     20.909s dev-loop17.device                                  
     20.907s dev-loop24.device                                  
     20.905s dev-loop14.device                                  
     20.905s dev-loop11.device                                  
     19.782s dev-loop8.device                                   
     19.482s openvpnas.service                                  
     18.305s dev-loop9.device                                   
     18.304s dev-loop5.device                                   
     18.303s dev-loop6.device                                   
     18.301s dev-loop7.device                                   
     18.300s dev-loop16.device                                  
     18.297s dev-loop15.device                                  
     18.293s dev-loop19.device                                  
     16.610s dev-loop4.device                                   
     16.610s dev-loop2.device                                   
     16.609s dev-loop0.device                                   
     16.609s dev-loop1.device                                   
     16.607s dev-loop3.device                                   
     16.606s dev-loop10.device                                  
     16.603s dev-loop18.device                                  
     16.598s dev-loop20.device                                  
     16.597s dev-loop21.device                                  
     15.768s avahi-daemon.service                               
     15.294s NetworkManager.service                             
     15.178s polkit.service                                     
     14.492s switcheroo-control.service                         
     14.484s thermald.service                                   
     14.430s systemd-logind.service                             
     14.417s wpa_supplicant.service                             
     13.653s winbind.service                                    
     12.544s systemd-journal-flush.service                      
     11.046s grub-common.service                                
      9.978s apport.service                                     
      8.960s gpu-manager.service                                
      8.902s apache2.service                                    
      8.655s systemd-udevd.service                              
      8.618s NetworkManager-wait-online.service                 
      7.669s ModemManager.service                               
      6.905s rsyslog.service                                    
      6.046s teamviewerd.service                                
      4.932s apparmor.service                                   
      4.088s e2scrub_reap.service                               
      3.825s colord.service                                     
      3.223s lm-sensors.service                                 
      3.081s snapd.apparmor.service                             
      2.566s grub-initrd-fallback.service                       
      2.531s lightdm.service                                    
      2.525s plymouth-quit-wait.service                         
      2.514s systemd-sysctl.service                             
      2.484s systemd-tmpfiles-setup.service                     
      2.378s ssh.service                                        
      2.191s dns-clean.service                                  
      1.946s snap-audacity-756.mount                            
      1.884s snap-audacity-857.mount                            
      1.847s systemd-modules-load.service                       
      1.818s snap-chromium-1637.mount                           
      1.811s snap-chromium-1646.mount                           
      1.809s fwupd.service                                      
      1.753s snap-core-11187.mount                              
      1.728s snap-core-11316.mount                              
      1.615s keyboard-setup.service                             
      1.569s snapd.seeded.service                               
      1.539s snap-core18-2066.mount                             
      1.539s upower.service                                     
      1.522s snap-core18-2074.mount                             
      1.487s systemd-random-seed.service                        
      1.467s snap-core20-1026.mount                             
      1.393s snap-docker-471.mount                              
      1.325s snap-docker-796.mount                              
      1.219s snap-gnome\x2d3\x2d26\x2d1604-102.mount            
      1.198s snap-gnome\x2d3\x2d26\x2d1604-104.mount            
      1.143s snap-gnome\x2d3\x2d28\x2d1804-145.mount            
      1.133s systemd-timesyncd.service                          
      1.128s snap-gnome\x2d3\x2d28\x2d1804-161.mount            
      1.070s snap-gnome\x2d3\x2d34\x2d1804-66.mount             
      1.028s systemd-sysusers.service                           
      1.005s snap-gnome\x2d3\x2d34\x2d1804-72.mount             
       889ms snap-gnome\x2d3\x2d38\x2d2004-39.mount             
       861ms systemd-tmpfiles-setup-dev.service                 
       763ms snap-gnome\x2dsystem\x2dmonitor-160.mount          
       734ms snap-gnome\x2dsystem\x2dmonitor-163.mount          
       649ms snap-gtk2\x2dcommon\x2dthemes-13.mount             
       642ms [email protected]                               
       610ms snap-gtk2\x2dcommon\x2dthemes-9.mount              
       564ms snap-gtk\x2dcommon\x2dthemes-1514.mount            
       553ms phpsessionclean.service                            
       542ms snap-gtk\x2dcommon\x2dthemes-1515.mount            
       541ms systemd-udev-trigger.service                       
       494ms snap-handbrake\x2djz-142.mount                     
       438ms swapfile.swap                                      
       437ms systemd-backlight@backlight:acpi_video0.service    
       431ms snap-inkscape-9078.mount                           
       412ms console-setup.service                              
       404ms snap-inkscape-9090.mount                           
       386ms systemd-remount-fs.service                         
       320ms kerneloops.service                                 
       319ms systemd-update-utmp.service                        
       314ms systemd-journald.service                           
       283ms [email protected]                                  
       266ms ufw.service                                        
       263ms systemd-backlight@backlight:intel_backlight.service
       251ms setvtrgb.service                                   
       249ms snap-losslesscut-66.mount                          
       241ms snap-losslesscut-72.mount                          
       233ms plymouth-read-write.service                        
       225ms snap-snap\x2dstore-547.mount                       
       206ms snapd.socket                                       
       196ms snap-snap\x2dstore-542.mount                       
       178ms dev-hugepages.mount                                
       177ms dev-mqueue.mount                                   
       175ms sys-kernel-debug.mount                             
       173ms sys-kernel-tracing.mount                           
       167ms kmod-static-nodes.service                          
       161ms pppd-dns.service                                   
       160ms hddtemp.service                                    
       152ms snap-pdftk-9.mount                                 
       121ms systemd-user-sessions.service                      
       119ms wicd.service                                       
       115ms systemd-resolved.service                           
       109ms shadowsocks.service                                
        96ms plymouth-start.service                             
        83ms rtkit-daemon.service                               
        41ms [email protected]                      
        19ms alsa-restore.service                               
        13ms systemd-update-utmp-runlevel.service               
         8ms systemd-rfkill.service                             
         6ms e2scrub_all.service                                
         5ms sys-fs-fuse-connections.mount                      
         4ms sys-kekernelkernelrnel-config.mount

快照列表的输出:

Name                  Version                     Rev    Tracking         Publisher   Notes
audacity              3.0.2                       857    latest/stable    diddledan   -
chromium              91.0.4472.114               1646   latest/stable    canonical*  -
core                  16-2.51.1                   11316  latest/stable    canonical*  core
core18                20210611                    2074   latest/stable    canonical*  base
core20                20210429                    1026   latest/stable    canonical*  base
docker                19.03.13                    796    latest/stable    canonical*  -
gnome-3-26-1604       3.26.0.20210629             104    latest/stable/…  canonical*  -
gnome-3-28-1804       3.28.0-19-g98f9e67.98f9e67  161    latest/stable    canonical*  -
gnome-3-34-1804       0+git.3556cb3               72     latest/stable    canonical*  -
gnome-3-38-2004       0+git.3d25b9b               39     latest/stable    canonical*  -
gnome-system-monitor  40.1-2-ga819fb4b55          163    latest/stable/…  canonical*  -
gtk-common-themes     0.1-52-gb92ac40             1515   latest/stable    canonical*  -
gtk2-common-themes    0.1                         13     latest/stable    canonical*  -
handbrake-jz          1.2.2                       142    latest/stable    jz          -
inkscape              1.1-ce6663b3b7-2021-05-25   9090   latest/stable    inkscape*   -
losslesscut           3.34.3                      72     latest/stable    mifino      -
pdftk                 2.02-4                      9      latest/stable    smoser      -
snap-store            3.38.0-64-g23c4c77          547    latest/stable/…  canonical*  -

cat etc/network/interfaces 的输出:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5). 

source /etc/network/interfaces.d/*

# The loopback network interface 
auto lo
iface lo inet loopback

# The primary network interface 
auto enp0s25 
iface enp0s25 inet dhcp

cat /etc/netplan/*.yaml 的输出:

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

free -h 的输出:

              total        used        free      shared  buff/cache   available
Mem:          3.6Gi       1.8Gi       550Mi       180Mi       1.3Gi       1.4Gi
Swap:         2.0Gi        15Mi       2.0Gi

/etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=7dd9bc28-9780-4a60-9f94-87c3471f2089 /               ext4    errors=remount-ro 0       1
/swapfile                                 none            swap    sw              0       0

磁盘截图:

磁盘截图

答案1

笔记:您可能遇到多个问题。网络、Docker 层、Snap、sda1 和 VPN。

让我们首先检查您的文件系统...

  • 以“试用 Ubuntu”模式启动 Ubuntu Live DVD/USB
  • terminalCtrl+ Alt+打开窗口T
  • 类型sudo fdisk -l
  • 识别“Linux 文件系统”的 /dev/sdXX 设备名称
  • 输入sudo fsck -f /dev/sda1,替换sdXX为您之前找到的数字
  • sudo fsck -f /dev/sda2
  • sudo fsck -f /dev/sda5
  • fsck如果有错误则重复命令
  • 类型reboot

/etc/网络/接口

注释掉以下行并重新启动...

# The primary network interface 
auto enp0s25 
iface enp0s25 inet dhcp

/交换文件

由于只有 4G RAM,2G 的 /swapfile 太小了。我们将它从 2G 改为 4G...

笔记:错误使用rmdd命令可能会导致数据丢失。建议复制/粘贴。

在里面terminal...

sudo swapoff -a           # turn off swap
sudo rm -i /swapfile      # remove old /swapfile

sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

sudo chmod 600 /swapfile  # set proper file protections
sudo mkswap /swapfile     # init /swapfile
sudo swapon /swapfile     # turn on swap
free -h                   # confirm 4G RAM and 4G swap

sudo -H gedit /etc/fstab使用或编辑 /etc/fstab sudo pico /etc/fstab

确认 /etc/fstab 中的此 /swapfile 行...并确认没有其他“交换”行...在此行中使用空格...确认没有制表符...

/swapfile  none  swap  sw  0  0

reboot                    # reboot and verify operation

更新#1:

重新安装了 Ubuntu。

相关内容