检测并修复 Ubuntu 20.04 上的启动缓慢问题

检测并修复 Ubuntu 20.04 上的启动缓慢问题

自从我从 Ubuntu 18.04 升级到 20.04 以来,我的启动时间最近变得很慢(90 秒,而过去是 20 秒)。

我使用的是 Ubuntu 20.04.1 LTS 64 位。我正在使用混合 SSD(120GB)+ HHD(500GB)系统,Intel Core i3-6100U CPU @ 2.30GHz × 4 和 8GB RAM DDR4。我的分区是:SSD:249MB EFI(/boot/efi)、40GB 文件系统(/)、8GB 交换和 72 GB 文件系统(/home)。HDD 未安装。

我已经格式化了系统并重新安装了 Ubuntu,但启动时间几乎相同。我还尝试打开/etc/fstab(以超级用户身份),remove(或注释掉)包含旧交换分区的行,设置新的交换:

# /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/sdc2 during installation
UUID=cf116583-5203-458c-855e-6f412a1ba35d /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sdc1 during installation
UUID=4C04-C9BD  /boot/efi       vfat    umask=0077      0       1
# /home was on /dev/sdc4 during installation
UUID=a5f9b844-bb2a-49e0-9a8e-d88c76eeb832 /home           ext4    defaults        0       2
# swap was on /dev/sdc3 during installation
# UUID=3bd915e8-cdd5-4ffd-a477-b355a73d53b3 none            swap    sw              0       0

而且,我还通过添加到取消了Press Ctrl+C to cancel all filesystem checks in progress启动时的消息。fsck.mode=skip/etc/default/grub

以下是我为进行故障排除而运行的一些命令以及它们各自的输出:

$ systemd-analyze time
Startup finished in 23.446s (firmware) + 9.900s (loader) + 5.114s (kernel) + 41.224s (userspace) = 1min 19.686s 
graphical.target reached after 40.975s in userspace
$ systemd-analyze blame
24.614s plymouth-quit-wait.service                                                               
11.743s dev-sdb2.device                                                                          
10.361s snapd.service                                                                            
 9.676s NetworkManager-wait-online.service                                                       
 6.549s dev-loop8.device                                                                         
 6.492s dev-loop10.device                                                                        
 6.460s dev-loop9.device                                                                         
 6.413s dev-loop11.device                                                                        
 4.894s dev-loop0.device                                                                         
 4.856s dev-loop4.device                                                                         
 4.707s dev-loop2.device                                                                         
 4.705s dev-loop1.device                                                                         
 4.693s dev-loop6.device                                                                         
 4.688s dev-loop3.device                                                                         
 4.582s dev-loop7.device                                                                         
 4.526s dev-loop5.device                                                                         
 3.761s upower.service                                                                           
 3.310s systemd-rfkill.service                                                                   
 2.588s udisks2.service                                                                          
 2.232s fwupd.service                                                                            
 2.108s systemd-logind.service                                                                   
 2.025s accounts-daemon.service                                                                  
 1.931s networkd-dispatcher.service                                                              
 1.497s [email protected]                                                                        
 1.383s polkit.service                                                                           
 1.264s avahi-daemon.service                                                                     
 1.223s bluetooth.service                                                                        
 1.214s NetworkManager.service                                                                   
 1.119s systemd-resolved.service                                                                 
 1.037s switcheroo-control.service                                                               
 1.022s apport.service                                                                           
 1.009s keyboard-setup.service                                                                   
  954ms systemd-timesyncd.service                                                                
  900ms systemd-journald.service                                                                 
  868ms snapd.apparmor.service                                                                   
  826ms systemd-udev-trigger.service                                                             
  822ms grub-common.service

在以下命令中,单元激活或启动的时间打印在字符后@。单元启动所用的时间打印在字符后+

$ systemd-analyze critical-chain
graphical.target @40.975s
└─multi-user.target @40.956s
  **└─kerneloops.service @25.596s +293ms**
    └─network-online.target @25.548s
      **└─NetworkManager-wait-online.service @15.866s +9.676s
        └─NetworkManager.service @14.638s +1.214s**
          └─dbus.service @14.590s
            └─basic.target @14.444s
              └─sockets.target @14.443s
                **└─snapd.socket @14.434s +6ms**
                  └─sysinit.target @14.374s
                    **└─snapd.apparmor.service @13.504s +868ms**
                      └─apparmor.service @13.042s +452ms
                        └─local-fs.target @13.032s
                          └─run-user-1000-doc.mount @30.724s
                            └─run-user-1000.mount @18.199s
                              └─swap.target @12.881s
                                **└─dev-sdb3.swap @12.750s +114ms**
                                  └─dev-sdb3.device @12.730s

请注意,我是 Ubuntu 的普通用户,因此我将非常感激实用的解决方案。

编辑 16:35 2020/10/06

@heynnema 询问的截图和信息:

$ grep -i swap /etc/fstab
# swap was on /dev/sdc3 during installation
UUID=316dc5cd-e888-48b8-868a-0e5d6072e480 none            swap    sw              0       0
$ sudo blkid
/dev/sdb2: UUID="cf116583-5203-458c-855e-6f412a1ba35d" TYPE="ext4" PARTUUID="8767a42b-380a-45af-87f9-84c9fe0a6bc4"
/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/sda1: LABEL="HDD" UUID="42365cfd-df11-4b02-9f9b-9047da487338" TYPE="ext4" PARTUUID="ee264f0e-6367-4360-9216-a3b24c63d56b"
/dev/sdb1: UUID="4C04-C9BD" TYPE="vfat" PARTUUID="8648f750-04c5-4508-8b4e-82f7b947e6b9"
/dev/sdb3: UUID="316dc5cd-e888-48b8-868a-0e5d6072e480" TYPE="swap" PARTLABEL="lol" PARTUUID="86bf4b4a-0d1e-4341-94fb-c674c1c39b88"
/dev/sdb4: UUID="a5f9b844-bb2a-49e0-9a8e-d88c76eeb832" TYPE="ext4" PARTUUID="3833323d-93a2-4961-9ba8-a3aee724153e"
/dev/loop8: TYPE="squashfs"
/dev/loop9: TYPE="squashfs"
/dev/loop10: TYPE="squashfs"
/dev/loop11: TYPE="squashfs"
$ ls -al /var/crash
total 8
drwxrwsrwt  2 root whoopsie 4096 jul 31 18:31 .
drwxr-xr-x 14 root root     4096 jul 31 18:35 ..

GParted 和磁盘(SMART)的屏幕截图:

01_磁盘_智能_SSD

02_磁盘_智能_SSD

磁盘_智能_HDD

gparted_sda

分区表

编辑于 2020-10-06 18:07

@heynnema 以下是最后的请求:

$ systemctl status plymouth-quit-wait
     Loaded: loaded (/lib/systemd/system/plymouth-quit-wait.service; stat>
     Active: inactive (dead) since Tue 2020-10-06 17:11:13 CEST; 42min ago
     Process: 1056 ExecStart=/bin/plymouth --wait (code=exited, status=0/S>   
   Main PID: 1056 (code=exited, status=0/SUCCESS)

oct 06 17:10:48 matheus-Vostro-15-3568 systemd[1]: Starting Hold until bo>
oct 06 17:11:13 matheus-Vostro-15-3568 systemd[1]: plymouth-quit-wait.ser>
oct 06 17:11:13 matheus-Vostro-15-3568 systemd[1]: Finished Hold until bo>
$ free -h
              total        used        free      shared  buff/cache   available
Mem:          7,6Gi       1,9Gi       3,9Gi       196Mi      1,9Gi       5,3Gi
Swap:         7,4Gi          0B       7,4Gi
$ sysctl vm.swappiness
vm.swappiness = 60
$ ls -al /
total 84 
drwxr-xr-x 20 root root   4096 oct 5 23:57 . 
drwxr-xr-x 20 root root   4096 oct 5 23:57 .. 
lrwxrwxrwx 1 root root       7 oct 5 23:49 bin -> usr/bin 
drwxr-xr-x 4 root root    4096 oct 6 00:09 boot 
drwxrwxr-x 2 root root    4096 oct 5 23:57 cdrom 
drwxr-xr-x 21 root root   4540 oct 6 17:10 dev 
drwxr-xr-x 127 root root 12288 oct 6 16:20 etc 
drwxr-xr-x 4 root root    4096 oct 5 23:58 home 
lrwxrwxrwx 1 root root       7 oct 5 23:49 lib -> usr/lib 
lrwxrwxrwx 1 root root       9 oct 5 23:49 lib32 -> usr/lib32 
lrwxrwxrwx 1 root root       9 oct 5 23:49 lib64 -> usr/lib64 
lrwxrwxrwx 1 root root      10 oct 5 23:49 libx32 -> usr/libx32 
drwx------ 2 root root   16384 oct 5 23:48 lost+found 
drwxr-xr-x 3 root root    4096 oct 6 16:49 media 
drwxr-xr-x 2 root root    4096 jul 31 18:27 mnt 
drwxr-xr-x 2 root root    4096 jul 31 18:27 opt 
dr-xr-xr-x 251 root root     0 oct 6 17:10 proc 
drwx------ 6 root root    4096 oct 6 00:19 root 
drwxr-xr-x 34 root root    880 oct 6 17:11 run 
lrwxrwxrwx 1 root root       8 oct 5 23:49 sbin -> usr/sbin 
drwxr-xr-x 12 root root   4096 oct 6 02:15 snap 
drwxr-xr-x 2 root root    4096 jul 31 18:27 srv 
dr-xr-xr-x 13 root root      0 oct 6 17:10 sys 
drwxrwxrwt 21 root root   4096 oct 6 17:57 tmp 
drwxr-xr-x 14 root root   4096 jul 31 18:28 usr 
drwxr-xr-x 14 root root   4096 jul 31 18:35 var
$ sudo dmidecode -s bios-version
2.6.0

我的电脑/主板的具体品牌/型号:DELL vVstro 15 3568,i3-6100u

编辑于 2020-10-08 18:05

Esc启动时显示的消息:

启动时按 ESC 键显示的消息

答案1

文件系统检查

fsck.mode=skip从 /etc/default/grub 中删除,然后执行sudo update-grub

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

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

BIOS

戴尔 Vostro 15 3568

您的 BIOS 版本为 2.6.0。

有更新的 BIOS 可用,版本 3.6.0,发布日期为 2020 年 7 月 27 日,可以下载这里

安装说明这里

注意:确认我拥有适合您型号的正确网页。

注意:更新 BIOS 之前请做好备份。

更新#1:

您的无线或以太网接口上有 AER(高级错误报告)错误。如果这是台式计算机,请重新安装无线网卡和以太网卡……否则请执行以下操作……

sudo -H gedit /etc/default/grub# 编辑此文件

寻找:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

更改为:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=noaer"

sudo update-grub# 更新 GRUB

reboot# 重启计算机

相关内容