我注意到即使我有 SSD,我的设备启动速度也变得越来越慢,所以我尝试深入研究它。
首先,我发现文件 resume 中有一个错误,将其更改为 resume=none。我看到了一点提升。
在更改恢复文件(一开始不存在)之前,加载时间为 5 37 秒,这很糟糕。
现在:用户空间耗时 3 分 14.290 秒。
systemd-analyze time 892 11:00:03
Startup finished in 7.298s (firmware) + 3.630s (loader) + 2.673s (kernel) + 3min 688ms (userspace) = 3min 14.290s
graphical.target reached after 1min 38.373s in userspace
我试图查看其中的问题,然后我看到了 dev-loop 设备。我不知道如何处理它,我是否可以阻止它们,以及它是否会对我的笔记本电脑产生影响)
systemd-analyze blame 893 11:00:10
7.517s plymouth-quit-wait.service
6.558s NetworkManager-wait-online.service
2.220s dev-sda6.device
2.053s snapd.service
891ms networkd-dispatcher.service
658ms dev-loop8.device
639ms dev-loop9.device
631ms dev-loop11.device
630ms dev-loop13.device
629ms dev-loop12.device
591ms dev-loop16.device
590ms dev-loop15.device
584ms dev-loop10.device
579ms dev-loop14.device
579ms dev-loop1.device
575ms dev-loop4.device
570ms dev-loop5.device
565ms dev-loop2.device
564ms dev-loop3.device
560ms dev-loop0.device
543ms snap-core18-1705.mount
541ms snap-vlc-1397.mount
540ms snap-heroku-3881.mount
528ms dev-loop7.device
526ms snap-gnome\x2dcharacters-399.mount
522ms systemd-backlight@backlight:intel_backlight.service
518ms dev-loop6.device
493ms dev-loop22.device
491ms dev-loop19.device
490ms dev-loop20.device
475ms dev-loop17.device
462ms dev-loop21.device
461ms snap-gtk\x2dcommon\x2dthemes-1440.mount
459ms dev-loop18.device
455ms systemd-logind.service
445ms snap-postman-102.mount
435ms udisks2.service
402ms snap-gnome\x2dcalculator-544.mount
393ms systemd-rfkill.service
389ms apparmor.service
351ms ModemManager.service
328ms snap-skype-115.mount
318ms upower.service
303ms accounts-daemon.service
293ms snap-core18-1668.mount
291ms systemd-journal-flush.service
287ms keyboard-setup.service
278ms NetworkManager.service
270ms snap-gnome\x2dcalculator-704.mount
263ms snap-musixmatch-18.mount
255ms snap-postman-103.mount
247ms snap-gnome\x2dlogs-81.mount
243ms grub-common.service
241ms snap-gnome\x2dsystem\x2dmonitor-127.mount
237ms snap-core-8689.mount
236ms systemd-udev-trigger.service
231ms plymouth-read-write.service
208ms snap-skype-118.mount
207ms fwupd.service
203ms [email protected]
201ms speech-dispatcher.service
186ms bluetooth.service
184ms snap-hello\x2dworld-29.mount
175ms snap-gtk\x2dcommon\x2dthemes-1474.mount
171ms systemd-journald.service
171ms apport.service
171ms gpu-manager.service
168ms snap-gnome\x2d3\x2d28\x2d1804-116.mount
156ms snap-core-8935.mount
155ms snap-gnome\x2dcharacters-495.mount
150ms wpa_supplicant.service
141ms snap-gnome\x2dlogs-93.mount
137ms snap-gnome\x2dsystem\x2dmonitor-135.mount
117ms avahi-daemon.service
114ms thermald.service
102ms systemd-resolved.service
99ms packagekit.service
92ms systemd-udevd.service
86ms systemd-timesyncd.service
84ms [email protected]
80ms systemd-backlight@leds:dell::kbd_backlight.service
77ms rsyslog.service
76ms bolt.service
74ms snapd.seeded.service
73ms polkit.service
73ms alsa-restore.service
49ms systemd-modules-load.service
49ms plymouth-start.service
48ms gdm.service
43ms systemd-fsck@dev-disk-by\x2duuid-105D\x2d71B7.service
41ms networking.service
40ms systemd-sysctl.service
35ms colord.service
35ms pppd-dns.service
33ms dns-clean.service
32ms systemd-tmpfiles-setup.service
27ms dev-disk-by\x2duuid-606cd432\x2d01a6\x2d4c87\x2dbdcf\x2d22c1d60
25ms dev-mqueue.mount
24ms systemd-tmpfiles-setup-dev.service
24ms systemd-remount-fs.service
24ms kerneloops.service
22ms kmod-static-nodes.service
21ms ufw.service
14ms boot-efi.mount
14ms sys-fs-fuse-connections.mount
13ms ureadahead-stop.service
12ms sys-kernel-config.mount
11ms systemd-update-utmp-runlevel.service
11ms systemd-update-utmp.service
9ms sys-kernel-debug.mount
8ms dev-hugepages.mount
8ms systemd-user-sessions.service
8ms rtkit-daemon.service
7ms console-setup.service
7ms systemd-random-seed.service
5ms setvtrgb.service
2ms snapd.socket
lines 95-117/117 (END)
我从 ubuntu 中删除了 snap 来看看对启动有多大影响。
systemd-analyze blame 973 09:42:30
29.641s apt-daily.service
8.675s plymouth-quit-wait.service
7.869s fstrim.service
6.578s NetworkManager-wait-online.service
6.166s apt-daily-upgrade.service
2.297s dev-sda6.device
919ms motd-news.service
722ms systemd-journal-flush.service
711ms systemd-backlight@backlight:intel_backlight.service
485ms upower.service
478ms apparmor.service
469ms networkd-dispatcher.service
426ms packagekit.service
409ms udisks2.service
394ms systemd-logind.service
380ms apport.service
379ms plymouth-read-write.service
348ms grub-common.service
316ms systemd-udevd.service
298ms systemd-rfkill.service
287ms speech-dispatcher.service
265ms ModemManager.service
252ms NetworkManager.service
245ms keyboard-setup.service
212ms fwupd.service
202ms systemd-udev-trigger.service
200ms [email protected]
191ms bluetooth.service
157ms systemd-journald.service
143ms avahi-daemon.service
137ms thermald.service
133ms alsa-restore.service
127ms bolt.service
118ms rng-tools.service
118ms accounts-daemon.service
105ms gpu-manager.service
100ms gdm.service
95ms pppd-dns.service
92ms plymouth-start.service
89ms systemd-timesyncd.service
85ms [email protected]
81ms wpa_supplicant.service
67ms systemd-resolved.service
66ms colord.service
59ms systemd-modules-load.service
55ms systemd-tmpfiles-setup-dev.service
54ms kerneloops.service
48ms systemd-fsck@dev-disk-by\x2duuid-105D\x2d71B7.service
48ms systemd-backlight@leds:dell::kbd_backlight.service
45ms dns-clean.service
44ms rsyslog.service
40ms networking.service
38ms dev-disk-by\x2duuid-606cd432\x2d01a6\x2d4c87\x2dbdcf\x2d22c1d60
35ms systemd-random-seed.service
34ms polkit.service
28ms systemd-remount-fs.service
26ms systemd-sysctl.service
26ms systemd-tmpfiles-setup.service
20ms systemd-user-sessions.service
20ms dev-mqueue.mount
19ms kmod-static-nodes.service
18ms ufw.service
17ms systemd-update-utmp.service
16ms dev-hugepages.mount
16ms ureadahead-stop.service
13ms sys-kernel-debug.mount
13ms sys-fs-fuse-connections.mount
12ms systemd-update-utmp-runlevel.service
11ms boot-efi.mount
9ms sys-kernel-config.mount
7ms console-setup.service
5ms rtkit-daemon.service
4ms setvtrgb.service
systemd-analyze critical-chain 975 09:44:43
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
graphical.target @1min 39.346s
└─multi-user.target @1min 39.346s
└─kerneloops.service @1min 37.195s +54ms
└─network-online.target @1min 37.193s
└─NetworkManager-wait-online.service @1min 30.614s +6.578s
└─NetworkManager.service @1min 30.354s +252ms
└─dbus.service @1min 30.310s
└─basic.target @1min 30.238s
└─sockets.target @1min 30.238s
└─dbus.socket @1min 30.235s
└─sysinit.target @1min 30.229s
└─apparmor.service @2.594s +478ms
└─local-fs.target @2.585s
└─run-user-1000-gvfs.mount @1min 56.316s
└─run-user-1000.mount @1min 55.465s
└─local-fs-pre.target @454ms
└─keyboard-setup.service @209ms +245ms
└─systemd-journald.socket @196ms
└─system.slice @195ms
└─-.slice @192ms
答案1
随着对这个问题的进一步挖掘,我记得删除了一个分区交换(因为我有 2 个用于交换的分区),按照这个说明后,我的问题解决了。
问题出在启动时
Linux 尝试安装交换但失败,这大大增加了您的启动时间。
解决方案:
在您的文件中,/etc/fstab
您声明了 4 个分区以作为交换分区挂载,但您的“lsblk”显示只有 2 个分区被挂载。我相信“sdb”是您的 HDD,“sda”是您的 SSD。在这种情况下,您确实在使用 HDD 中的交换分区,但我相信 Linux 仍在尝试从 SSD 加载交换分区,但由于您删除了该分区,因此无法加载。
首先,保持简单:使用 1 个交换分区。我不完全确定您的驱动器为何如此格式化(您有双启动吗?),但您当前正在使用 8 GB 分区(sdb2)和 16 GB 分区(sdb5)作为交换。决定要用作交换的 1 个分区(sdb2 和 sdb5 已正确格式化)。然后使用“ lsblk -f
”获取要用作交换的分区的 UUID 并将其记下来。现在以 root 身份在您喜欢的文本编辑器中打开 /etc/fstab/。删除所有与交换相关的行,但请注意不要编辑 root 和 home 分区的行。现在向文件添加一个新行,如下所示:
代码:
UUID=00000000-0000-0000-0000-000000000000 none swap sw 0 0
但是,请将我用作示例的空 UUID 替换为您记下的 UUID。保存该文件,关闭文本编辑器并重新启动。现在,启动时应该只有一个交换分区被挂载,并且启动时间应该恢复正常。 关联感谢 leon.p