出现启动消息之前启动过程缓慢

出现启动消息之前启动过程缓慢

我在两台 PC 上运行最新的 MINT Linux Vanessa (Ubuntu 22.04 LTS),并且我经历了同样长的启动时间。我遵循了所有提示和技巧,但尚未找到任何解决方案。两种安装均基于 BIOS,无 EFI 引导程序。

  • 我已经从 grub 配置中删除了 nosplash 和 Quiet,这样我就可以看到所有启动消息。
  • 从启动菜单中选择一个选项后,它需要大约20秒屏幕上出现第一条启动消息。这正是我的问题。在这个阶段会发生什么?
  • 所有用于了解每个启动步骤需要多长时间的好工具都没有真正的帮助。 systemd-analyze 告诉我启动大约需要 18 秒,但前 20 秒似乎不包括在内。
  • 20 秒的延迟与冷启动或从休眠状态唤醒无关。
  • 我遵循了一些提示,例如将 pci=noaer,nomsi 添加到启动选项但没有成功

我的问题是:如何加快启动过程?目前大约需要 45 秒(这并不是很引人注目),但如果正确理解启动过程中实际发生的情况,可能只需要 18 秒。

这里有一些信息:

Output of systemd-analyze 
Startup finished in 9.311s (kernel) + 8.854s (userspace) = 18.166s 
graphical.target reached after 8.846s in userspace



Output of systemd-analyze blame
4.211s NetworkManager-wait-online.service
3.463s grub-initrd-fallback.service
2.312s systemd-udev-settle.service
1.103s dev-sda4.device
1.013s [email protected]
 844ms blueman-mechanism.service
 634ms influxdb.service
 570ms cups.service
 501ms networkd-dispatcher.service
 421ms systemd-resolved.service
 374ms udisks2.service
 311ms accounts-daemon.service
 294ms avahi-daemon.service
 288ms ModemManager.service
 277ms bluetooth.service
 251ms ubuntu-system-adjustments.service
 238ms NetworkManager.service
 226ms apparmor.service
 213ms alsa-restore.service
 200ms systemd-timesyncd.service
 199ms systemd-logind.service
 195ms mono-xsp4.service
 188ms zfs-load-module.service

虽然有很多信息,但我在下面添加了 dmesg 输出的第一部分,感谢您的任何好主意!

[    0.000000] microcode: microcode updated early to revision 0x2f, date = 2019-11-12
[    0.000000] Linux version 5.15.0-56-generic (buildd@lcy02-amd64-004) (gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 (Ubuntu 5.15.0-56.62-generic 5.15.64)
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.15.0-56-generic root=UUID=06c00ee6-9db7-4bac-8bbf-efff4eb6ef97 ro resume=UUID=a542e607-0a04-410f-b47e-47fe4c4ae9bc
[    0.000000] KERNEL supported cpus:
[    0.000000]   Intel GenuineIntel
[    0.000000]   AMD AuthenticAMD
[    0.000000]   Hygon HygonGenuine
[    0.000000]   Centaur CentaurHauls
[    0.000000]   zhaoxin   Shanghai  
[    0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[    0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[    0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[    0.000000] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256
[    0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
[    0.000000] signal: max sigframe size: 1776
[    0.000000] BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009c7ff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009c800-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000009cf4afff] usable
[    0.000000] BIOS-e820: [mem 0x000000009cf4b000-0x000000009d41dfff] reserved
[    0.000000] BIOS-e820: [mem 0x000000009d41e000-0x00000000a2284fff] usable
[    0.000000] BIOS-e820: [mem 0x00000000a2285000-0x00000000a2342fff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000a2343000-0x00000000a2368fff] ACPI data
[    0.000000] BIOS-e820: [mem 0x00000000a2369000-0x00000000a2c98fff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x00000000a2c99000-0x00000000a2ffefff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000a2fff000-0x00000000a2ffffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000a3800000-0x00000000a7ffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000f8000000-0x00000000fbffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fed00000-0x00000000fed03fff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fed1c000-0x00000000fed1ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000ff000000-0x00000000ffffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x0000000456ffffff] usable
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] SMBIOS 2.8 present.
[    0.000000] DMI:  /NUC5i5RYB, BIOS RYBDWi35.86A.0385.2020.0519.1558 05/19/2020
[    0.000000] tsc: Fast TSC calibration using PIT
[    0.000000] tsc: Detected 1596.228 MHz processor
[    0.000858] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
[    0.000862] e820: remove [mem 0x000a0000-0x000fffff] usable
[    0.000872] last_pfn = 0x457000 max_arch_pfn = 0x400000000
[    0.001011] x86/PAT: Configuration [0-7]: WB  WC  UC- UC  WB  WP  UC- WT  
[    0.001996] total RAM covered: 16288M
[    0.002149]  gran_size: 64K  chunk_size: 64K     num_reg: 10     lose cover RAM: 16M
[    0.002153]  gran_size: 64K  chunk_size: 128K    num_reg: 10     lose cover RAM: 16M
[    0.002155]  gran_size: 64K  chunk_size: 256K    num_reg: 10     lose cover RAM: 16M
[    0.002157]  gran_size: 64K  chunk_size: 512K    num_reg: 10     lose cover RAM: 16M
[    0.002159]  gran_size: 64K  chunk_size: 1M  num_reg: 10     lose cover RAM: 16M
[    0.002161]  gran_size: 64K  chunk_size: 2M  num_reg: 10     lose cover RAM: 16M
[    0.002163]  gran_size: 64K  chunk_size: 4M  num_reg: 10     lose cover RAM: 16M
[    0.002165]  gran_size: 64K  chunk_size: 8M  num_reg: 10     lose cover RAM: 16M
[    0.002167]  gran_size: 64K  chunk_size: 16M     num_reg: 10     lose cover RAM: 16M
[    0.002169]  gran_size: 64K  chunk_size: 32M     num_reg: 10     lose cover RAM: 0G
[    0.002171]  gran_size: 64K  chunk_size: 64M     num_reg: 10     lose cover RAM: 0G

答案1

由于 20 秒的延迟发生在第一个内核消息之前,这表明它可能与 GRUB 有关,或者可能与内核与系统固件的最早交互有关(当内核接收到e820内存映射、ACPI 表、DMI 信息和固件中的其他内容)。

如果您想构建自定义内核,有一个名为“early printk”的内核功能,它可能会提供有关内核启动的最早步骤的更多见解。

另一方面,20 秒的延迟很可能是 GRUB 中的问题。您可以打印出 GRUB 配置,然后转到 GRUB 命令提示符并尝试正常 Linux 引导菜单项中的命令。这样您就可以看到某些命令是否花费了异常长的时间。

GRUB 的search命令将尝试按照固件提供的任何顺序访问所有磁盘,直到该命令找到它被告知要搜索的内容。我建议测试所有相关search命令,看看其中是否有任何一个是罪魁祸首。然后,您可以尝试使用命令来加载内核和 initramfs 文件(如果适用)。

您还可以尝试 GRUB 的 TAB 补全:键入ls (hd,按TAB两次该键,然后查看 GRUB 可以看到多少个磁盘。然后尝试识别它们。例如,如果发现在您的实际系统磁盘之前显示了旧且速度慢的磁盘,则您可能必须交换 SATA 电缆,以便首先显示最快的磁盘。

最坏的情况是,您会发现磁盘旋转速度变慢,这可能是即将发生硬件故障的迹象。

相关内容