根据主题,Kubuntu 启动需要 1 分 03 秒, 但存在不一致有一些数据:
andrea@Tehesyan:~$ systemd-analyze time
Startup finished in 4.504s (firmware) + 2.140s (loader) + 5.188s (kernel) + 9.054s (userspace) = 20.888s
graphical.target reached after 9.007s in userspace.
正如你所看到的启动时间大约为 30 秒,其他时间系统做什么?
andrea@Tehesyan:~$ systemd-analyze blame --no-pager
6.289s NetworkManager-wait-online.service
1.541s snapd.service
996ms snapd.apparmor.service
970ms systemd-resolved.service
949ms systemd-binfmt.service
948ms systemd-timesyncd.service
809ms lm-sensors.service
555ms snapd.seeded.service
275ms apport.service
230ms dev-nvme0n1p3.device
153ms udisks2.service
149ms accounts-daemon.service
148ms cups.service
147ms [email protected]
134ms systemd-journal-flush.service
114ms plymouth-quit.service
97ms ModemManager.service
94ms ua-timer.service
92ms avahi-daemon.service
92ms bluetooth.service
90ms rsyslog.service
86ms dbus.service
79ms polkit.service
78ms power-profiles-daemon.service
73ms systemd-udev-trigger.service
71ms systemd-udevd.service
71ms smartmontools.service
68ms and.service
63ms virtualbox.service
59ms systemd-logind.service
58ms thermald.service
57ms update-notifier-download.service
51ms gpu-manager.service
49ms systemd-tmpfiles-clean.service
49ms grub-common.service
46ms alsa-restore.service
45ms upower.service
45ms home.mount
40ms boot-efi.mount
36ms keyboard-setup.service
36ms apparmor.service
35ms snap-bare-5.mount
33ms NetworkManager.service
33ms snap-core-14946.mount
32ms e2scrub_reap.service
31ms pure-ftpd.service
31ms snap-core18-2751.mount
30ms systemd-fsck@dev-disk-by\x2duuid-4cc61126\x2d9300\x2d4049\x2d8a21\x2d8efb758016f5.service
30ms snap-core18-2785.mount
28ms snap-core20-1891.mount
26ms snap-core22-634.mount
26ms systemd-modules-load.service
26ms grub-initrd-fallback.service
26ms systemd-fsck@dev-disk-by\x2duuid-A544\x2dD3FB.service
25ms systemd-journald.service
25ms snap-core22-750.mount
24ms snap-gnome\x2d3\x2d38\x2d2004-140.mount
23ms snap-gnome\x2d42\x2d2204-105.mount
22ms snap-gnome\x2d42\x2d2204-111.mount
21ms plymouth-start.service
21ms snapd.socket
21ms snap-gtk2\x2dcommon\x2dthemes-13.mount
20ms snap-gtk\x2dcommon\x2dthemes-1535.mount
20ms colord.service
19ms wpa_supplicant.service
19ms proc-sys-fs-binfmt_misc.mount
19ms snap-snapd-19122.mount
18ms systemd-tmpfiles-setup.service
17ms snap-snapd-19361.mount
17ms systemd-tmpfiles-setup-dev.service
15ms snap-winbox-112.mount
14ms kerneloops.service
13ms systemd-sysusers.service
13ms snap-wine\x2dplatform\x2d5\x2dstable-18.mount
12ms dev-hugepages.mount
12ms dev-mqueue.mount
11ms sys-kernel-debug.mount
11ms sys-kernel-tracing.mount
11ms snap-wine\x2dplatform\x2druntime-348.mount
11ms plymouth-read-write.service
11ms systemd-random-seed.service
9ms snap-wine\x2dplatform\x2druntime-349.mount
9ms systemd-sysctl.service
8ms motd-news.service
8ms systemd-backlight@backlight:intel_backlight.service
7ms [email protected]
7ms kmod-static-nodes.service
7ms systemd-remount-fs.service
7ms [email protected]
7ms dev-disk-by\x2duuid-7cd25b73\x2df94a\x2d4b4a\x2d965c\x2d703a45eb5556.swap
7ms dev-loop14.device
7ms [email protected]
7ms dev-loop13.device
7ms dev-loop12.device
7ms dev-loop8.device
7ms dev-loop11.device
6ms dev-loop9.device
6ms [email protected]
6ms dev-loop16.device
6ms dev-loop15.device
6ms dev-loop10.device
5ms dev-loop17.device
4ms systemd-update-utmp.service
4ms modprobe@efi_pstore.service
4ms systemd-rfkill.service
4ms setvtrgb.service
3ms systemd-user-sessions.service
3ms systemd-update-utmp-runlevel.service
3ms console-setup.service
2ms sddm.service
2ms sys-fs-fuse-connections.mount
2ms rtkit-daemon.service
1ms sys-kernel-config.mount
1ms ufw.service
再次
andrea@Tehesyan:~$ systemd-analyze critical-chain --no-pager
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 @9.031s
└─multi-user.target @9.031s
└─virtualbox.service @8.967s +63ms
└─network-online.target @8.919s
└─NetworkManager-wait-online.service @2.628s +6.289s
└─NetworkManager.service @2.592s +33ms
└─dbus.service @2.503s +86ms
└─basic.target @2.492s
└─sockets.target @2.492s
└─snapd.socket @2.470s +21ms
└─sysinit.target @2.468s
└─snapd.apparmor.service @1.471s +996ms
└─apparmor.service @1.432s +36ms
└─local-fs.target @1.431s
└─run-user-1000.mount @4.336s
└─swap.target @563ms
└─dev-disk-by\x2duuid-7cd25b73\x2df94a\x2d4b4a\x2d965c\x2d703a45eb5556.swap @554ms +7ms
└─dev-disk-by\x2duuid-7cd25b73\x2df94a\x2d4b4a\x2d965c\x2d703a45eb5556.device @549ms
再次
andrea@Tehesyan:~$ journalctl --boot=0 --priority=3 --no-pager
giu 16 16:31:49 Tehesyan kernel: ACPI BIOS Error (bug): Failure creating named object [\_SB.PC00.I2C0.TPL1._PR0], AE_ALREADY_EXISTS (20221020/dswload2-326)
giu 16 16:31:49 Tehesyan kernel: ACPI Error: AE_ALREADY_EXISTS, During name lookup/catalog (20221020/psobject-220)
giu 16 16:31:49 Tehesyan kernel: ACPI BIOS Error (bug): Failure creating named object [\_SB.PC00.I2C0.TPL1._PR3], AE_ALREADY_EXISTS (20221020/dswload2-326)
giu 16 16:31:49 Tehesyan kernel: ACPI Error: AE_ALREADY_EXISTS, During name lookup/catalog (20221020/psobject-220)
giu 16 16:31:49 Tehesyan kernel: ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0], AE_NOT_FOUND (20221020/dswload2-162)
giu 16 16:31:49 Tehesyan kernel: ACPI Error: AE_NOT_FOUND, During name lookup/catalog (20221020/psobject-220)
giu 16 16:31:49 Tehesyan kernel: tpm tpm0: [Firmware Bug]: TPM interrupt not working, polling instead
giu 16 16:31:49 Tehesyan systemd-udevd[494]: event_source: Failed to get device name: No such file or directory
giu 16 16:31:51 Tehesyan bluetoothd[807]: src/plugin.c:plugin_init() Failed to init vcp plugin
giu 16 16:31:51 Tehesyan bluetoothd[807]: src/plugin.c:plugin_init() Failed to init mcp plugin
giu 16 16:31:51 Tehesyan bluetoothd[807]: src/plugin.c:plugin_init() Failed to init bap plugin
giu 16 16:31:56 Tehesyan kernel: rtw_8822ce 0000:03:00.0: failed to do dpk calibration
giu 16 16:32:00 Tehesyan bluetoothd[807]: profiles/audio/avdtp.c:avdtp_connect_cb() connect to 14:79:DB:8A:3E:DF: Host is down (112)
giu 16 16:32:05 Tehesyan bluetoothd[807]: profiles/audio/avdtp.c:avdtp_connect_cb() connect to 10:F0:05:CA:70:FA: Host is down (112)
giu 16 16:32:35 Tehesyan systemd[1129]: Failed to start app-baloo_file-ff4b7f2a20f64e4abb162e3d474e7625.scope - Demone dei file Baloo.
giu 16 16:32:36 Tehesyan hp-systray[1949]: hp-systray[1949]: error: option -s not recognized
giu 16 16:32:40 Tehesyan systemd[1129]: Failed to start app-script\x2dremapping\x2dmouse\x2dkeys-b3f82c270c8046e0b4bd32758d6d46b5.scope - script-remapping-mouse-keys.
giu 16 16:32:40 Tehesyan systemd[1129]: Failed to start app-snap\x2duserd\x2dautostart-5b2d61154fee442aad23110308d429fa.scope - Snap user application autostart helper.
giu 16 16:32:40 Tehesyan systemd[1129]: Failed to start app-spice\x2dvdagent-8817624255bb4aabaffb22400d7d5f9c.scope - Spice vdagent.
giu 16 16:32:40 Tehesyan systemd[1129]: Failed to start app-xbindkeys-6a68845bad8a4b63abd513ce3f205f2d.scope - xbindkeys.
giu 16 16:52:56 Tehesyan kernel: i915 0000:00:02.0: [drm] *ERROR* Atomic update failure on pipe B (start=94294 end=94295) time 257 us, min 1071, max 1079, scanline start 1068, end 1089
giu 16 17:16:25 Tehesyan kernel: i915 0000:00:02.0: [drm] *ERROR* Atomic update failure on pipe B (start=199919 end=199920) time 273 us, min 1071, max 1079, scanline start 1062, end 1063
giu 16 17:30:07 Tehesyan systemd[1129]: Failed to start app-\x2fhome\x2fandrea\x2fprogrammazione\x2fbash\x2dscripts\x2fscript\x2dremapping\x2dmouse\x2dkeys.sh-59cc7cd375644db098a000315149cb04.scope - /home/andrea/programmazione/bash-scripts/script-remapping-mouse-keys.sh.
再次
andrea@Tehesyan:~$ journalctl --boot=0 --priority=4 --no-pager --grep='disk|mount'
giu 16 16:31:49 Tehesyan systemd-udevd[497]: nvme0n1: Process '/usr/bin/unshare -m /usr/bin/snap auto-import --mount=/dev/nvme0n1' failed with exit code 1.
giu 16 16:31:49 Tehesyan systemd-udevd[496]: sda: Process '/usr/bin/unshare -m /usr/bin/snap auto-import --mount=/dev/sda' failed with exit code 1.
giu 16 16:31:49 Tehesyan systemd-udevd[524]: nvme0n1p3: Process '/usr/bin/unshare -m /usr/bin/snap auto-import --mount=/dev/nvme0n1p3' failed with exit code 1.
giu 16 16:31:49 Tehesyan systemd-udevd[523]: nvme0n1p2: Process '/usr/bin/unshare -m /usr/bin/snap auto-import --mount=/dev/nvme0n1p2' failed with exit code 1.
giu 16 16:31:49 Tehesyan systemd-udevd[497]: nvme0n1p1: Process '/usr/bin/unshare -m /usr/bin/snap auto-import --mount=/dev/nvme0n1p1' failed with exit code 1.
giu 16 16:31:49 Tehesyan systemd-udevd[532]: sda1: Process '/usr/bin/unshare -m /usr/bin/snap auto-import --mount=/dev/sda1' failed with exit code 1.
其他信息:
Kernel: 6.2.0-20-generic
arch: x86_64 bits:
64 compiler: N/A
Desktop: KDE Plasma v: 5.27.4
Distro: Ubuntu 23.04 (Lunar Lobster)
product: HP 250 15.6 inch G9 Notebook PC
SAMSUNG SOLID STATE DRIVE SSD 256GB M.2 NVMe
这个笔记本大概有一个月了,我记不太清楚了,但是我觉得一开始并没有占用这么多时间。
我相信问题出在操作系统加载之前,至少我是这样认为的,除非提供的数据systemd-analyze time
不正确。
我希望你帮我调查为什么系统启动需要这么长时间并采取应对措施。谢谢
PS:你在视频中看到的烟是香烟产生的,而不是笔记本产生的,哈哈
答案1
从启动角度来看,您的系统是“几乎“ 完美的
我最初没有检查你链接的视频,就像大多数命令行一样“极客“在这里,我们更喜欢终端的黑色背景,避免使用色彩鲜艳的视频,因为我们认为这可能会伤害我们的眼睛,而且可能冗长且不必要......但是,我错了,你的视频结果是一个非常重要的证据,因为它显示了你从打开机器到看到桌面的时间计算启动时间......我完全不同意......实际上,systemd-analyze
启动时间计算到graphical.target
(systemd
启动过程中的最后一个单元)...是登录管理器的欢迎程序,又名用户登录屏幕...现在,您可以清楚地看到打印启动时间与您自己计算的启动时间graphical.target
存在差异的原因。systemd-analyze
的输出systemd-analyze time
是正确的,您的启动时间是20.888
(稍微多一两个)秒...此外,输出systemd-analyze blame
并systemd-analyze critical-chain
确认最后9.054
几秒支持的更多细节。
为什么 ”几乎“?
因为仅仅等待网络连接就需要大约6
几秒钟的时间9
(用户空间)...这并不一定意味着它会将系统启动延迟整整6
几秒,因为服务可以与没有依赖关系的其他服务并行运行(依赖或反向依赖)与...但是,它可以改进,我建议它考虑到三分之二的用户空间启动时间的比例...请参阅如何减少启动时间如何做到这一点。
剩下的 1 分 03 秒呢?
那是您自己的桌面环境的用户会话加载...这不是启动过程的一部分,而是用户登录过程的一部分,该过程可能会在启动后立即发生,也可能不会发生,并且可能会多次发生,并且对于多个用户,只要系统运行几个小时、几天甚至几个月,用户就会随时登录或退出并重新登录...事实上,您启用了自动登录并不会使其成为系统启动的一部分,它仍然是用户登录会话。
为什么我的用户登录会话要花那么长时间才能加载?
这需要时间(不一定要那么长……可能更少,也可能更多) 来设置您的用户会话,包括绘制 GUI、解析您的用户登录配置文件、加载您的启动应用程序/脚本、挂载您的用户定义的文件系统、连接和配置设备(例如外部显示器)、启动您的用户服务(如音频)......等等......您越是根据您的需要/喜好定制您的用户环境,与您第一次创建用户时相比,加载用户会话所需的时间就越长。
您似乎已经这样做了...例如:
您连接蓝牙设备:
bluetoothd[807]: profiles/audio/avdtp.c:avdtp_connect_cb() connect to 14:79:DB:8A:3E:DF: Host is down (112) bluetoothd[807]: profiles/audio/avdtp.c:avdtp_connect_cb() connect to 10:F0:05:CA:70:FA: Host is down (112)
你有巴鲁已启用(可能是默认的):
Failed to start app-baloo_file-ff4b7f2a20f64e4abb162e3d474e7625.scope - Demone dei file Baloo.
你有hp 系统托盘安装并启用:
hp-systray[1949]: hp-systray[1949]: error: option -s not recognized
您有一个自定义脚本来映射您的鼠标键:
Failed to start app-script\x2dremapping\x2dmouse\x2dkeys-b3f82c270c8046e0b4bd32758d6d46b5.scope - script-remapping-mouse-keys.
ETC。 ...
底线是......它是您的用户体验的一部分,它可以丰富它并自然地增加您的登录时间以满足您在桌面环境用户会话中的需求。