大约 3 周前,我从 Windows 8 转到 ubuntu。我不得不经历非常缓慢的启动过程。我没有双启动或其他东西。此外,我尝试过全新安装 ubuntu,但没有任何变化。我的 PC 是联想 15-ay542tu,配备 8GB 内存和 1TB 硬盘。
以下是 systemd-analyze blame 的输出:
53.630s plymouth-quit-wait.service
23.830s systemd-journal-flush.service
20.806s snapd.service
17.253s networkd-dispatcher.service
16.563s dev-sda2.device
15.555s libvirtd.service
15.205s NetworkManager-wait-online.service
13.684s apport-autoreport.service
13.634s udisks2.service
9.339s accounts-daemon.service
8.641s dev-loop17.device
8.478s dev-loop10.device
8.475s dev-loop15.device
8.475s dev-loop16.device
8.455s dev-loop19.device
8.448s dev-loop18.device
8.307s dev-loop20.device
7.500s dev-loop8.device
7.235s dev-loop4.device
7.195s ModemManager.service
7.123s dev-loop9.device
7.099s dev-loop12.device
6.948s dev-loop13.device
6.890s dev-loop14.device
6.876s polkit.service
6.808s dev-loop11.device
6.761s dev-loop7.device
6.580s avahi-daemon.service
6.578s bluetooth.service
6.500s NetworkManager.service
6.303s dev-loop2.device
6.191s switcheroo-control.service
6.179s thermald.service
6.176s systemd-logind.service
6.173s systemd-machined.service
6.156s wpa_supplicant.service
6.132s fwupd.service
5.977s dev-loop3.device
5.957s dev-loop5.device
5.790s dev-loop1.device
5.749s dev-loop6.device
5.115s bolt.service
4.925s dev-loop0.device
4.382s ufw.service
4.002s systemd-resolved.service
3.159s grub-common.service
2.911s grub-initrd-fallback.service
2.840s gpu-manager.service
2.740s systemd-udevd.service
2.406s gdm.service
2.168s apparmor.service
1.682s apport.service
1.654s rsyslog.service
1.529s motd-news.service
1.498s e2scrub_reap.service
1.294s snap-android\x2dstudio-91.mount
1.261s snapd.apparmor.service
1.228s snap-canonical\x2dlivepatch-95.mount
1.227s snap-code-39.mount
1.195s snap-code-40.mount
1.152s snap-core-9665.mount
1.151s snap-core-9804.mount
964ms snap-core18-1880.mount
886ms snap-core18-1885.mount
864ms snap-discord-112.mount
847ms systemd-tmpfiles-setup.service
834ms systemd-fsck@dev-disk-by\x2duuid-7D17\x2d84A2.service
833ms systemd-udev-trigger.service
784ms systemd-sysctl.service
753ms upower.service
748ms systemd-tmpfiles-setup-dev.service
720ms snap-figma\x2dlinux-70.mount
719ms snap-gnome\x2d3\x2d28\x2d1804-128.mount
654ms systemd-random-seed.service
632ms snap-gnome\x2d3\x2d34\x2d1804-24.mount
599ms snap-gnome\x2d3\x2d34\x2d1804-36.mount
590ms systemd-journald.service
572ms keyboard-setup.service
551ms systemd-modules-load.service
512ms swapfile.swap
500ms snap-gtk\x2dcommon\x2dthemes-1506.mount
499ms snap-intellij\x2didea\x2dcommunity-246.mount
497ms snap-snap\x2dstore-433.mount
467ms snap-snap\x2dstore-467.mount
451ms systemd-sysusers.service
388ms libvirt-guests.service
380ms plymouth-start.service
369ms lm-sensors.service
367ms snapd.seeded.service
348ms systemd-rfkill.service
331ms systemd-timesyncd.service
297ms [email protected]
294ms qemu-kvm.service
253ms dev-hugepages.mount
252ms dev-mqueue.mount
251ms systemd-user-sessions.service
251ms sys-kernel-debug.mount
249ms sys-kernel-tracing.mount
249ms kerneloops.service
247ms blk-availability.service
235ms snap-snapcraft-5279.mount
231ms kmod-static-nodes.service
230ms lvm2-monitor.service
228ms geoclue.service
206ms [email protected]
189ms plymouth-read-write.service
188ms pppd-dns.service
186ms setvtrgb.service
185ms colord.service
184ms snap-snapd-8790.mount
183ms boot-efi.mount
181ms snap-snapcraft-5308.mount
179ms systemd-backlight@backlight:intel_backlight.service
153ms console-setup.service
112ms systemd-update-utmp.service
104ms snap-snapd-8542.mount
103ms systemd-remount-fs.service
102ms rtkit-daemon.service
88ms systemd-tmpfiles-clean.service
82ms hddtemp.service
78ms alsa-restore.service
38ms [email protected]
23ms systemd-update-utmp-runlevel.service
20ms openvpn.service
7ms sys-fs-fuse-connections.mount
4ms sys-kernel-config.mount
3ms libvirtd.socket
1ms snapd.socket
585us clean-mount-point@media-parag-My\x20Files.service
以下是 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 @1min 31.593s
└─multi-user.target @1min 31.593s
└─libvirt-guests.service @53.289s +388ms
└─libvirtd.service @37.692s +15.555s
└─network.target @37.655s
└─NetworkManager.service @31.155s +6.500s
└─dbus.service @31.150s
└─basic.target @30.972s
└─sockets.target @30.972s
└─libvirtd-ro.socket @30.972s
└─libvirtd.socket @30.967s +3ms
└─sysinit.target @30.781s
└─systemd-timesyncd.service @30.449s +331ms
└─systemd-tmpfiles-setup.service @29.579s +847ms
└─systemd-journal-flush.service @5.748s +23.830s
└─systemd-journald.service @5.156s +590ms
└─systemd-journald.socket @5.149s
└─system.slice @5.128s
└─-.slice @5.128s
以下是 systemd-analyze 的输出
Startup finished in 15.485s (firmware) + 4.343s (loader) + 3.662s (kernel) + 1min 31.784s (userspace) = 1min 55.275s
graphical.target reached after 1min 31.593s in userspace
请提出一些建议,我不知道该怎么做。
答案1
选项 1:调整各种服务的设置以改善启动时间
我会给你一些关于systemd-journal-flush.service
和的提示libvirtd.service
。
1. systemd-journal-flush.service:
导致启动时间缓慢的主要原因之一是systemd-journal-flush.service
。
检查你的日志的大小:
journalctl --disk-usage
可能由于某种原因,它变得非常大。
您可以使用以下命令验证刷新日志需要多长时间:
journalctl -b --unit systemd-journald.service
您可以使用 vacuum 选项来减小日志的大小,例如:
journalctl --vacuum-size=100M --vacuum-time=5d --vacuum-files=5
然后检查磁盘使用情况,看看日志是否变小了:
journalctl --disk-usage
您可以使某些日记大小限制永久生效:
编辑/etc/systemd/journald.conf
以用作auto
存储选项并调整最大文件大小、存储的最大文件数或日志的最大大小(SystemMaxUse)。
sudo nano /etc/systemd/journald.conf
例如,添加以下行:
Storage=auto
SystemMaxUse=1G
SystemMaxFileSize=100M
SystemMaxFiles=5
查看这些设置的定义这里。
2. Libvirtd
导致启动时间过长的另一个因素是libvirtd.service
,它耗时 15 秒。
您使用的是虚拟机吗?如果没有,您可以禁用此服务在启动时启动。
sudo systemctl disable libvirtd
您可能还需要禁用访客:
sudo systemctl disable libvirt-guests
选项 2:升级到 SSD
通过将 1 TB 5400 RPM 硬盘替换为 SSD,您将看到启动时间的大幅改善。