![Ubuntu 启动缓慢,实际冻结约 5-10 分钟,然后才能正常工作](https://linux22.com/image/1024290/Ubuntu%20%E5%90%AF%E5%8A%A8%E7%BC%93%E6%85%A2%EF%BC%8C%E5%AE%9E%E9%99%85%E5%86%BB%E7%BB%93%E7%BA%A6%205-10%20%E5%88%86%E9%92%9F%EF%BC%8C%E7%84%B6%E5%90%8E%E6%89%8D%E8%83%BD%E6%AD%A3%E5%B8%B8%E5%B7%A5%E4%BD%9C.png)
我已经使用 Ubuntu 一段时间了,但出于某种原因,从某个时候开始,它启动非常慢,大约需要 2 分钟。Systemd-analyze 输出为:
Startup finished in 7.911s (firmware) + 5.078s (loader) + 6.034s (kernel) + 1min 28.681s (userspace) = 1min 47.704s
graphical.target reached after 1min 2.054s in userspace
Systemd-analyze 的罪魁祸首是:
1min 2.056s man-db.service
35.463s udisks2.service
25.140s NetworkManager-wait-online.service
16.481s networkd-dispatcher.service
12.920s dev-sda6.device
12.440s accounts-daemon.service
11.782s systemd-journal-flush.service
11.096s logrotate.service
9.849s ModemManager.service
8.955s polkit.service
8.374s snapd.service
8.130s avahi-daemon.service
8.128s bluetooth.service
8.114s NetworkManager.service
8.018s iio-sensor-proxy.service
7.410s switcheroo-control.service
7.400s systemd-logind.service
7.397s thermald.service
6.710s wpa_supplicant.service
6.115s snapd.seeded.service
5.476s [email protected]
5.302s dev-loop3.device
5.249s mnt-84D85686D8567700.mount
4.658s dev-loop8.device
4.651s gdm.service
4.218s dev-loop7.device
3.913s grub-common.service
3.885s dev-loop4.device
3.694s gpu-manager.service
3.506s tlp.service
3.332s dev-loop6.device
3.289s dev-loop5.device
3.222s dev-loop0.device
3.043s dev-loop2.device
3.019s dev-loop1.device
2.916s cpufreqd.service
2.729s loadcpufreq.service
2.674s apt-daily-upgrade.service
2.649s apport.service
2.298s upower.service
2.245s fwupd.service
2.199s apparmor.service
2.109s systemd-fsck@dev-disk-by\x2duuid-DCCD\x2d34F3.service
2.046s preload.service
1.884s secureboot-db.service
1.866s systemd-tmpfiles-setup.service
1.677s lm-sensors.service
1.606s mnt-82B0CEE6B0CEE031.mount
1.586s rsyslog.service
1.458s systemd-resolved.service
1.445s systemd-udevd.service
1.423s e2scrub_reap.service
1.423s fstrim.service
1.265s snap-core-11606.mount
1.163s snap-chromium-1732.mount
1.148s snapd.apparmor.service
1.127s systemd-sysctl.service
1.115s systemd-modules-load.service
1.005s grub-initrd-fallback.service
995ms snap-auto\x2dcpufreq-71.mount
964ms snap-gtk\x2dcommon\x2dthemes-1515.mount
959ms systemd-backlight@backlight:intel_backlight.service
954ms systemd-random-seed.service
929ms snap-core20-1081.mount
929ms kerneloops.service
914ms binfmt-support.service
873ms keyboard-setup.service
872ms [email protected]
845ms setvtrgb.service
797ms snap-gnome\x2d3\x2d28\x2d1804-161.mount
788ms snap-jdownloader2-17.mount
762ms pppd-dns.service
753ms systemd-tmpfiles-setup-dev.service
686ms snap-core18-2128.mount
667ms openvpn.service
642ms systemd-user-sessions.service
618ms systemd-sysusers.service
564ms colord.service
520ms boot-efi.mount
492ms snap-snapd-12883.mount
471ms systemd-udev-trigger.service
443ms hddtemp.service
377ms ufw.service
330ms dev-disk-by\x2duuid-21455d02\x2d8efb\x2d4566\x2d8474\x2d74ed32541dc7.swap
310ms systemd-journald.service
281ms systemd-timesyncd.service
265ms apport-autoreport.service
245ms dev-mqueue.mount
245ms sys-kernel-debug.mount
244ms sys-kernel-tracing.mount
244ms dev-hugepages.mount
238ms kmod-static-nodes.service
237ms [email protected]
225ms systemd-remount-fs.service
187ms console-setup.service
183ms proc-sys-fs-binfmt_misc.mount
166ms [email protected]
156ms systemd-backlight@leds:dell::kbd_backlight.service
109ms systemd-update-utmp.service
87ms snapd.socket
34ms snap-auto\x2dcpufreq-72.mount
27ms snap-snapd-13170.mount
23ms alsa-restore.service
20ms sys-fs-fuse-connections.mount
20ms sys-kernel-config.mount
17ms plymouth-read-write.service
17ms [email protected]
14ms systemd-tmpfiles-clean.service
11ms cpufrequtils.service
9ms systemd-update-utmp-runlevel.service
8ms dev-loop10.device
2ms rtkit-daemon.service
2ms dev-loop9.device
2ms e2scrub_all.service
1ms plymouth-quit-wait.service
289us clean-mount-point@media-j-Seagate\x20Expansion.service
Systemd-分析关键链:
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 2.054s
└─udisks2.service @26.590s +35.463s
└─basic.target @25.113s
└─sockets.target @25.108s
└─snapd.socket @25.011s +87ms
└─sysinit.target @24.746s
└─snapd.apparmor.service @23.595s +1.148s
└─apparmor.service @21.394s +2.199s
└─local-fs.target @21.392s
└─run-user-1000-gvfs.mount @1min 11.515s
└─run-user-1000.mount @58.284s
└─swap.target @19.048s
└─dev-disk-by\x2duuid-21455d02\x2d8efb\x2d4566\x2d8474\x2d74ed32541dc7.s>
└─dev-sda7.device @18.715s
即便如此,启动缓慢并不是最严重的问题。最严重的问题是,启动后,需要大约五分钟才能真正使用。它很滞后,会冻结,打开程序需要很长时间,当它打开时,比如说 Firefox,它会滞后,如果打开两个左右的选项卡,它会显示“Firefox 已冻结,您要等待还是强制关闭?”。然后会出现需要几分钟才能打开的更新程序,过了一会儿它就开始正常运行,而且速度相当快。有什么想法吗?可能是更新程序在运行吗?我怎样才能禁用它并在需要时打开它?谢谢。这是我的 neofetch:
j@j-Inspiron-17-7779
--------------------
OS: Ubuntu 20.04.3 LTS x86_64
Host: Inspiron 17-7779
Kernel: 5.11.0-27-generic
Uptime: 24 mins
Packages: 2424 (dpkg), 17 (flatpak), 10 (snap)
Shell: bash 5.0.17
Resolution: 1920x1080
DE: GNOME
WM: Mutter
WM Theme: Adwaita
Theme: Yaru-light [GTK2/3]
Icons: Yaru [GTK2/3]
Terminal: gnome-terminal
CPU: Intel i7-7500U (4) @ 3.500 GHz
GPU: NVIDIA GeForce 940MX
GPU: Intel HD Graphics 620
Memory: 3414MiB / 15880MiB
磁盘:[![分区 3 和 4 在启动时挂载。我将退出分区 3,因为我不想再挂载它,但分区 4 用于存储文件,因此我需要在启动时挂载它。][1]][1]
猫/ etc / fstab:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda6 during installation
UUID=0523d920-7cab-41b3-a0c0-341c5de2fce1 / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sda1 during installation
UUID=DCCD-34F3 /boot/efi vfat umask=0077 0 1
# swap was on /dev/sda7 during installation
UUID=21455d02-8efb-4566-8474-74ed32541dc7 none swap sw 0 0
/dev/disk/by-uuid/82B0CEE6B0CEE031 /mnt/82B0CEE6B0CEE031 auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-name=Windows 0 0
/dev/disk/by-uuid/84D85686D8567700 /mnt/84D85686D8567700 auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-name=Datos 0 0
免费-h:
total used free shared buff/cache available
Mem: 15Gi 2,9Gi 2,8Gi 646Mi 9,7Gi 11Gi
Swap: 3,3Gi 0B 3,3Gi
swapon -s:
Filename Type Size Used Priority
/dev/sda7 partition 3458044 0 -2
j@j-Inspiron-17-7779:~$
启动时卸载后:
j@j-Inspiron-17-7779:~$ systemd-analyze blame
29.376s udisks2.service
26.747s systemd-journal-flush.service
18.215s snapd.service
18.054s networkd-dispatcher.service
16.949s NetworkManager-wait-online.service
13.361s apport-autoreport.service
11.996s dev-sda6.device
11.744s accounts-daemon.service
8.674s polkit.service
7.918s avahi-daemon.service
7.915s bluetooth.service
7.897s NetworkManager.service
7.814s iio-sensor-proxy.service
6.968s [email protected]
6.842s switcheroo-control.service
6.829s systemd-logind.service
6.828s thermald.service
6.162s wpa_supplicant.service
4.966s dev-loop3.device
4.796s cpufreqd.service
4.760s dev-loop9.device
4.675s tlp.service
4.503s dev-loop8.device
4.453s gpu-manager.service
4.124s secureboot-db.service
3.996s loadcpufreq.service
3.869s dev-loop2.device
3.694s dev-loop7.device
3.488s gdm.service
3.461s dev-loop6.device
3.445s dev-loop5.device
3.444s dev-loop4.device
3.162s grub-common.service
3.147s apport.service
j@j-Inspiron-17-7779:~$ systemd-analyze
Startup finished in 7.798s (firmware) + 5.318s (loader) + 6.766s (kernel) + 1min 16.122s (userspace) = 1min 36.005s
graphical.target reached after 1min 8.645s in userspace
我在想可能是 snap 的问题?为了比较,我刚刚尝试在 Ubuntu 中复制超过 3.3 GB 的内容……速度大约为 2 MBps,耗时约 10 分钟。Linux Mint 中的情况相同,耗时 1 分钟,速度为 30 MBps……
所以说实话我真的很困惑,我想我不会碰它,或者无论如何我都会重新安装它。
按照说明安装后:
j@j-Inspiron-17-7779:~$ systemd-analyze
Startup finished in 7.881s (firmware) + 4.504s (loader) + 6.694s (kernel) + 57.510s (userspace) = 1min 16.589s
graphical.target reached after 54.163s in userspace
j@j-Inspiron-17-7779:~$ systemd-analyze blame
25.849s snapd.service
25.055s udisks2.service
15.271s NetworkManager-wait-online.service
13.105s dev-sda6.device
10.788s [email protected]
10.720s systemd-journal-flush.service
9.544s networkd-dispatcher.service
8.785s accounts-daemon.service
8.559s apport-autoreport.service
6.585s polkit.service
6.387s NetworkManager.service
6.205s avahi-daemon.service
6.200s bluetooth.service
5.696s iio-sensor-proxy.service
5.676s dev-loop4.device
5.186s dev-loop8.device
5.067s switcheroo-control.service
5.047s systemd-logind.service
5.037s thermald.service
4.772s wpa_supplicant.service
4.504s dev-loop9.device
4.215s dev-loop6.device
3.966s systemd-tmpfiles-setup.service
3.835s gpu-manager.service
3.801s gdm.service
3.777s dev-loop3.device
3.635s dev-loop7.device
3.576s dev-loop1.device
3.563s dev-loop2.device
3.334s dev-loop5.device
3.075s dev-loop0.device
2.948s cpufreqd.service
2.681s secureboot-db.service
2.467s loadcpufreq.service