我想知道为什么我的启动时间太长。我不知道这在 Kubuntu 中是否正常,我以前使用 Windows,启动到登录屏幕只需大约 10-20 秒。但现在启动到登录需要大约一分半钟。
我有一个视频链接,显示了加载需要多长时间;我无法录制前 10 秒,但整个视频的前半部分都显示了相同的内容。以下是视频链接:https://streamable.com/kc5cah。
我尝试在 GRUB 中禁用参数,结果如下:
loid-b@loid-b:~$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-6.5.0-26-generic root=UUID=cfd64b2b-38f2-4412-a305-ad2df6cd31b0 ro quiet splash vt.handoff=7 libata.force=2.00:disable
loid-b@loid-b:~$ sudo dmesg | grep libata.force
[sudo] password for loid-b:
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-6.5.0-26-generic root=UUID=cfd64b2b-38f2-4412-a305-ad2df6cd31b0 ro quiet splash vt.handoff=7 libata.force=2.00:disable
[ 0.036289] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-6.5.0-26-generic root=UUID=cfd64b2b-38f2-4412-a305-ad2df6cd31b0 ro quiet splash vt.handoff=7 libata.force=2.00:disable
loid-b@loid-b:~$ sudo lspci -nnk | grep -iA3 'SATA'
06:00.0 SATA controller [0106]: Advanced Micro Devices, Inc. [AMD] FCH SATA Controller [AHCI mode] [1022:7901] (rev 61)
Subsystem: ASUSTeK Computer Inc. FCH SATA Controller [AHCI mode] [1043:18f1]
Kernel driver in use: ahci
Kernel modules: ahci
我还拍了照片:
我还运行了下面这些命令,显示了输出:
ls -l /dev/disk/by-path & lsblk -o 供应商,型号,名称
loid-b@loid-b:~$ ls -l /dev/disk/by-path
total 0
lrwxrwxrwx 1 root root 13 Apr 8 18:23 pci-0000:03:00.0-nvme-1 -> ../../nvme0n1
lrwxrwxrwx 1 root root 15 Apr 8 18:23 pci-0000:03:00.0-nvme-1-part1 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Apr 8 18:23 pci-0000:03:00.0-nvme-1-part2 -> ../../nvme0n1p2
loid-b@loid-b:~$ lsblk -o VENDOR,MODEL,NAME
VENDOR MODEL NAME
loop0
loop1
loop2
loop3
loop4
loop5
loop6
loop7
loop8
loop9
loop10
INTEL SSDPEKNW512G8 nvme0n1
├─nvme0n1p1
└─nvme0n1p2
我尝试检查 BIOS 并查看是否可以对 SATA 做些什么,但我没有看到任何禁用它的选项,如下图所示:
我做了以下一些事情来检查我的系统:
loid-b@loid-b:~$ systemd-analyze time
Startup finished in 6.241s (firmware) + 3.607s (loader) + 1min 5.863s (kernel) + 9.020s (userspace) = 1min 24.732s
graphical.target reached after 8.994s in userspace.
当我systemd-analyze blame
看到这个的时候:
loid-b@loid-b:~$ systemd-analyze blame
9min 44.584s dev-loop2.device
9min 44.581s dev-loop6.device
9min 44.580s dev-loop5.device
9min 44.569s dev-loop1.device
9min 44.567s dev-loop0.device
9min 44.565s dev-loop7.device
9min 44.563s dev-loop4.device
9min 44.560s dev-loop3.device
5.042s NetworkManager-wait-online.service
3.336s plymouth-quit.service
1.997s NetworkManager.service
1.581s dev-loop9.device
830ms gpu-manager.service
678ms snapd.service
545ms udisks2.service
426ms upower.service
417ms accounts-daemon.service
411ms apport.service
369ms dev-nvme0n1p2.device
290ms ModemManager.service
290ms systemd-logind.service
284ms power-profiles-daemon.service
266ms polkit.service
225ms systemd-udev-trigger.service
199ms switcheroo-control.service
195ms e2scrub_reap.service
184ms snapd.seeded.service
181ms blueman-mechanism.service
151ms [email protected]
133ms bluetooth.service
130ms systemd-resolved.service
118ms update-notifier-download.service
118ms rsyslog.service
111ms systemd-journald.service
106ms secureboot-db.service
89ms avahi-daemon.service
86ms smartmontools.service
86ms systemd-timesyncd.service
82ms apparmor.service
76ms grub-common.service
75ms systemd-journal-flush.service
68ms keyboard-setup.service
63ms dbus.service
57ms wpa_supplicant.service
56ms systemd-udevd.service
45ms systemd-remount-fs.service
45ms snapd.apparmor.service
39ms thermald.service
38ms systemd-tmpfiles-clean.service
38ms dev-hugepages.mount
38ms grub-initrd-fallback.service
37ms dev-mqueue.mount
36ms sys-kernel-debug.mount
36ms sys-kernel-tracing.mount
34ms cups.service
33ms systemd-modules-load.service
32ms snapd.socket
31ms kmod-static-nodes.service
30ms [email protected]
30ms systemd-fsck@dev-disk-by\x2duuid-3ABD\x2d6C66.service
30ms systemd-tmpfiles-setup.service
29ms systemd-backlight@leds:asus::kbd_backlight.service
28ms boot-efi.mount
28ms [email protected]
26ms snap-bare-5.mount
26ms [email protected]
24ms snap-core20-2182.mount
23ms alsa-restore.service
22ms plymouth-start.service
22ms snap-core22-864.mount
21ms systemd-binfmt.service
20ms snap-firefox-3216.mount
19ms systemd-backlight@backlight:amdgpu_bl0.service
19ms snap-gnome\x2d3\x2d38\x2d2004-143.mount
17ms snap-gnome\x2d42\x2d2204-141.mount
16ms kerneloops.service
15ms snap-gtk\x2dcommon\x2dthemes-1535.mount
15ms snap-discord-182.mount
14ms snap-snapd-20092.mount
13ms [email protected]
13ms plymouth-read-write.service
13ms snap-spotify-75.mount
12ms systemd-sysusers.service
12ms systemd-tmpfiles-setup-dev.service
11ms systemd-update-utmp.service
11ms console-setup.service
11ms var-snap-firefox-common-host\x2dhunspell.mount
10ms systemd-rfkill.service
9ms proc-sys-fs-binfmt_misc.mount
9ms systemd-sysctl.service
8ms systemd-random-seed.service
8ms sddm.service
7ms systemd-user-sessions.service
7ms systemd-update-utmp-runlevel.service
5ms modprobe@dm_mod.service
5ms sys-kernel-config.mount
5ms dev-loop8.device
5ms nvidia-persistenced.service
4ms ufw.service
4ms rtkit-daemon.service
4ms modprobe@efi_pstore.service
3ms swapfile.swap
3ms [email protected]
3ms sys-fs-fuse-connections.mount
2ms setvtrgb.service
这是它的关键链:
loid-b@loid-b:~$ 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 @8.994s
└─multi-user.target @8.994s
└─kerneloops.service @8.977s +16ms
└─network-online.target @8.953s
└─NetworkManager-wait-online.service @3.909s +5.042s
└─NetworkManager.service @1.892s +1.997s
└─dbus.service @1.821s +63ms
└─basic.target @1.706s
└─sockets.target @1.706s
└─snapd.socket @1.673s +32ms
└─sysinit.target @1.668s
└─systemd-resolved.service @1.536s +130ms
└─systemd-tmpfiles-setup.service @1.501s +30ms
└─local-fs.target @1.493s
└─run-credentials-systemd\x2dresolved.service.mount @2.321s
└─local-fs-pre.target @390ms
└─systemd-tmpfiles-setup-dev.service @378ms +12ms
└─systemd-sysusers.service @364ms +12ms
└─systemd-remount-fs.service @314ms +45ms
└─systemd-journald.socket @280ms
└─system.slice @235ms
└─-.slice @235ms
以下是一些信息:
Kernel: 6.5.0-26-generic
arch: x86_64
Desktop Environment & Version : KDE 5.27.8
Distribution: Ubuntu 23.10
Product: TUF Gaming FX505DD_FX505DD
512GB PCIe® 3.0 NVMe™ M.2 SSD
答案1
经过长时间的调试后,发现主板上的 SATA 控制器出现故障,轮询一个未连接到总线的设备,导致失败并阻碍整个启动过程;
通过添加内核参数libata.force=2:rstonce
(2
列出的不存在的设备在哪里dmesg
),OP 和我能够将启动时间从之前的 1 分 30 秒缩短 1 分钟,最终将总启动时间缩短到仅 30 秒左右。
具体来说,该rstonce
标志将告诉 libata 仅向指定设备发送单个重置命令,最终避免在设备未响应重置命令时浪费时间(出于任何原因:在这种情况下,控制器正在轮询不存在的设备,但是这在驱动器发生故障且未响应重置命令的情况下也会起作用)。