我又开始使用 Ubuntu,但 Ubuntu 19.04 的整体性能确实让我很头疼。它运行非常缓慢,会死机,最糟糕的是它需要大约 5 分钟才能启动。
我有一台旧的 Dell Optiplex 7010,配有 i3 3000 处理器、8 GB 内存和 Intel HD 3000 板载显卡。因此性能不应该成为问题。
正如我提到的,我对 Ubuntu 还不熟悉,所以我仍在学习。
在寻找修复方法之后,我找到了这个命令来查看是什么导致启动 Ubuntu 花费了这么长时间:
systemd-analyze blame
这给了我这个输出:
tux@tux-OptiPlex-7010:~$ systemd-analyze blame
5min 13.441s sav-protect.service
1min 20.310s apt-daily.service
57.163s plymouth-quit-wait.service
30.008s systemd-journal-flush.service
27.969s dev-mapper-ubuntu\x2d\x2dvg\x2droot.device
22.765s accounts-daemon.service
22.205s snapd.service
21.924s ModemManager.service
19.630s networkd-dispatcher.service
18.044s udisks2.service
17.974s dev-loop30.device
17.899s dev-loop26.device
17.824s dev-loop49.device
17.768s dev-loop34.device
17.713s dev-loop55.device
17.480s dev-loop45.device
17.435s dev-loop29.device
17.384s dev-loop48.device
17.350s dev-loop31.device
17.231s dev-loop2.device
17.218s dev-loop39.device
17.185s dev-loop40.device
17.168s dev-loop44.device
17.071s dev-loop46.device
16.724s dev-loop19.device
15.978s dev-loop51.device
15.836s dev-loop43.device
15.791s dev-loop47.device
15.764s dev-loop41.device
15.762s dev-loop50.device
15.707s dev-loop42.device
15.638s dev-loop37.device
15.587s dev-loop38.device
15.524s dev-loop54.device
15.377s dev-loop35.device
15.185s dev-loop33.device
15.090s dev-loop24.device
15.049s dev-loop7.device
15.014s dev-loop14.device
14.889s dev-loop13.device
14.560s dev-loop53.device
14.519s dev-loop52.device
14.087s dev-loop15.device
14.077s dev-loop32.device
14.000s dev-loop20.device
13.948s dev-loop27.device
13.832s dev-loop3.device
13.830s dev-loop8.device
13.824s dev-loop11.device
13.708s dev-loop6.device
13.614s dev-loop25.device
13.574s dev-loop36.device
13.518s dev-loop16.device
13.424s dev-loop23.device
13.375s dev-loop10.device
13.346s dev-loop28.device
13.168s dev-loop21.device
12.864s grub-common.service
12.737s dev-loop17.device
12.667s systemd-resolved.service
12.616s avahi-daemon.service
12.473s dev-loop18.device
12.407s sddm.service
12.358s rsyslog.service
12.342s apport.service
12.142s wpa_supplicant.service
12.134s NetworkManager.service
12.130s systemd-logind.service
12.124s dev-loop9.device
12.122s dev-loop12.device
12.120s dev-loop22.device
11.944s gpu-manager.service
11.733s lm-sensors.service
11.645s apparmor.service
11.362s thermald.service
11.075s [email protected]
10.956s switcheroo-control.service
10.822s dev-loop0.device
10.702s dev-loop4.device
10.488s dev-loop1.device
10.442s dev-loop5.device
9.189s systemd-udevd.service
9.112s NetworkManager-wait-online.service
8.930s nginx.service
8.629s snap.ufw.srv.service
7.295s ufw.service
6.514s networking.service
6.239s fwupd.service
5.406s gdm.service
4.896s systemd-sysctl.service
4.688s snap-gnome\x2d3\x2d26\x2d1604-90.mount
4.641s [email protected]
4.472s snap-gtk\x2dcommon\x2dthemes-1313.mount
4.304s snap-polar\x2dbookshelf-69.mount
4.181s snap-chromium-821.mount
4.023s snap-core18-1074.mount
3.946s snap-webcatalog-10.mount
3.872s snap-easy\x2dopenvpn-5.mount
3.697s apt-daily-upgrade.service
3.691s snap-code-13.mount
3.680s virtualbox.service
3.598s snap-gnome\x2dlogs-45.mount
3.556s snap-ao-20.mount
3.456s snap-riseup\x2dvpn-152.mount
3.424s snap-gnome\x2d3\x2d26\x2d1604-70.mount
3.375s snap-gnome\x2dcalculator-406.mount
3.348s snap-hexchat-42.mount
3.317s snap-core-5662.mount
3.242s snap-odrive\x2dunofficial-2.mount
3.157s snap-translatium-6.mount
3.084s uwsgi.service
3.010s snap-ufw-296.mount
2.931s polkit.service
2.925s snap-tinc\x2dvpn-2.mount
2.825s snap-tusk-29.mount
2.784s snap-ubuntu\x2dapp\x2dplatform-34.mount
2.718s snap-gtk\x2dcommon\x2dthemes-701.mount
2.693s snap-gnome\x2dlogs-61.mount
2.643s snap-ubuntu\x2dcloud\x2dimage-63.mount
2.582s snap-zaproxy-4.mount
2.550s snap-nmap-564.mount
2.511s snap-opera-47.mount
2.369s snap-midori-550.mount
2.278s snap-tor-2.mount
2.278s lvm2-monitor.service
2.264s systemd-modules-load.service
2.194s snap-gnome\x2d3\x2d28\x2d1804-71.mount
2.168s snap-deja\x2ddup-190.mount
2.142s systemd-tmpfiles-setup.service
2.135s snap-usdxworldparty-30.mount
1.936s snap-xmr\x2dminer\x2dgui-9.mount
1.753s snap-google\x2dplay\x2dmusic\x2ddesktop\x2dplayer-70.mount
1.645s snap-webcatalog-4.mount
1.525s lvm2-pvscan@8:1.service
1.519s snap-john\x2dthe\x2dripper-297.mount
1.470s privoxy.service
1.402s snap-google\x2dwebapp-4.mount
1.338s snap-chromium\x2dffmpeg-13.mount
1.320s snap-gnome\x2dcharacters-124.mount
1.253s snap-communitheme-1768.mount
1.131s snap-canonical\x2dlivepatch-81.mount
1.117s systemd-tmpfiles-setup-dev.service
1.094s keyboard-setup.service
1.044s plymouth-start.service
988ms dns-clean.service
916ms systemd-sysusers.service
896ms snap-firefox-253.mount
895ms snap-opera-46.mount
833ms pppd-dns.service
829ms snap-i2pd-25.mount
828ms snap-gnome\x2dcalculator-238.mount
796ms snap-gnome\x2dsystem\x2dmonitor-100.mount
796ms snap-gnome\x2dcharacters-296.mount
785ms tor.service
772ms snap-google\x2dcloud\x2dsdk-95.mount
740ms colord.service
688ms snap-wonderwall-13.mount
687ms snap-gnome\x2dsystem\x2dmonitor-57.mount
575ms systemd-timesyncd.service
557ms plymouth-read-write.service
522ms snap-googletools\x2ddesktop-1.mount
520ms snap-vlc-1049.mount
497ms snap-gtk2\x2dcommon\x2dthemes-5.mount
448ms grub-initrd-fallback.service
429ms upower.service
397ms ifupdown-pre.service
387ms kerneloops.service
320ms snapd.seeded.service
311ms systemd-tmpfiles-clean.service
311ms systemd-journald.service
296ms dev-mqueue.mount
295ms dev-hugepages.mount
290ms dev-mapper-ubuntu\x2d\x2dvg\x2dswap_1.swap
274ms systemd-udev-trigger.service
265ms [email protected]
265ms snap-qshodan-196.mount
261ms systemd-backlight@backlight:acpi_video0.service
219ms bolt.service
217ms console-setup.service
207ms setvtrgb.service
203ms blk-availability.service
201ms systemd-remount-fs.service
178ms snap.canonical-livepatch.canonical-livepatchd.service
173ms systemd-user-sessions.service
168ms snap.easy-openvpn.easy-openvpn.service
163ms hddtemp.service
163ms sys-kernel-debug.mount
161ms kmod-static-nodes.service
152ms systemd-random-seed.service
144ms snap.tor.tor.service
124ms snap-hello\x2dworld-29.mount
116ms snap-core-7396.mount
115ms rtkit-daemon.service
102ms proc-sys-fs-binfmt_misc.mount
89ms systemd-update-utmp.service
84ms systemd-update-utmp-runlevel.service
59ms snapd.socket
14ms openvpn.service
4ms sys-fs-fuse-connections.mount
3ms sys-kernel-config.mount
如您所见,有些地方不对劲。如果有人能帮我解决这个问题,我将不胜感激。
Ubuntu 19.04 是一个相对较新的安装。但我可以说,我在全新安装时遇到了性能问题。我希望有人能帮我纠正这个问题。我期待着学习如何做到这一点。
答案1
你有适用于 Linux 的 Sophos 防病毒软件已安装:
sav-protect.service
属于 Sophos。请阅读这里。也是sav-rms.service
。
sav-protect.service
是 Sophos 实时(按访问)扫描服务。
sav-rms.service
是 Sophos 远程管理系统服务。
延迟是由于启动时病毒扫描造成的。而整体性能低下是由于实时(访问时)扫描造成的。请阅读类似问题这里,这里和这里。
值得注意的是,这不是 Sophos 特有的问题。这通常是防病毒软件的工作方式。它们需要系统资源来完成工作,工作量越大,情况就越糟。您使用系统越多 --> 触发的系统和文件访问进程越多 --> 常规进程和扫描它们的防病毒软件占用的系统资源越多 --> 您的系统变得越迟缓和无响应,直到达到瓶颈,有时甚至会停止运行。
如果启动时和访问时病毒扫描对于您的系统来说并不重要,您可以禁用该服务并恢复启动速度和系统响应能力。为此,请在终端中运行以下命令并重新启动系统:
sudo systemctl disable sav-protect.service
如果重启后再次出现,您可以按照上述命令操作:
sudo systemctl mask sav-protect.service
如果您在启动时收到有关实时保护被禁用的警报,你可以使用以下命令执行上述命令:
sudo systemctl disable sav-rms.service
如果重启后再次出现,您可以按照上述命令操作:
sudo systemctl mask sav-rms.service
随时回滚上述更改,请运行:
sudo systemctl unmask sav-protect.service
然后按照这个:
sudo systemctl enable sav-protect.service
然后按照这个:
sudo systemctl unmask sav-rms.service
然后按照这个:
sudo systemctl enable sav-rms.service
注意:
以上所有操作均无需卸载适用于 Linux 的 Sophos 防病毒软件。它将保留在您的系统中,以便您可以使用防病毒软件的其他功能,或者您可以稍后回滚上述所做的更改并根据需要返回到完整的软件包。
答案2
大约 1 年前,我在 Debian 9 上遇到 gcc 编译性能下降 50% 的情况。页表隔离导致了这种情况,这与 Spectra/Meltdown 有关。您可以在启动时从 grub 添加 -no-pti。请注意,这是在 Haswell i7 上,并且仅在使用 32 位 Linux 时,在 64 位上不会出现如此大的性能下降。
您使用的是 32 位还是 64 位?