Debian

如何減少“networking.service”服務的時間?

  • July 22, 2020

我使用 linux 已經有一段時間了,我已經學會了適應這個新的作業系統,所以我想改進我的一些配置細節。

目前系統載入速度很快,但我看到它分七個部分停止。使用命令systemd-analyze blameob 分析我有以下資訊:

diego@computer:~$ systemd-analyze blame
   1min 13.120s networking.service
        11.960s postgresql@11-main.service
         9.792s mariadb.service
         7.845s NetworkManager-wait-online.service
         7.706s ifupdown-pre.service
         6.190s udisks2.service
         5.742s apache2.service
         5.220s ModemManager.service
         4.989s NetworkManager.service
         4.746s dev-sda6.device
         4.457s accounts-daemon.service
         3.785s bluetooth.service
         3.715s avahi-daemon.service
         3.710s wpa_supplicant.service
         3.709s sysstat.service
         3.702s alsa-restore.service
         3.700s rsyslog.service
         3.697s systemd-logind.service
         3.694s pppd-dns.service
         3.168s teamviewerd.service
         2.685s systemd-fsck@dev-disk-by\x2duuid-7add5e56\x2dd7d9\x2d4870\x2d9edf\x2d653b241363d3.service
         2.208s systemd-fsck@dev-disk-by\x2duuid-653a5644\x2d63e1\x2d4258\x2dbbb5\x2de1f1c1d2cd2f.service
         2.131s systemd-fsck@dev-disk-by\x2duuid-AAF1\x2dAC6F.service
         1.142s systemd-fsck@dev-disk-by\x2duuid-3f7a45e2\x2d6e0b\x2d4d72\x2d9e97\x2df87224e624ba.service
          861ms boot-efi.mount
          744ms systemd-tmpfiles-setup.service
          738ms systemd-udevd.service
          717ms systemd-backlight@backlight:intel_backlight.service
          712ms apparmor.service
          678ms polkit.service
          644ms systemd-backlight@leds:dell::kbd_backlight.service
          613ms upower.service
          573ms systemd-rfkill.service
          497ms keyboard-setup.service
          444ms systemd-tmpfiles-clean.service
          432ms systemd-random-seed.service
          334ms home.mount
          295ms systemd-udev-trigger.service
          294ms systemd-timesyncd.service
          287ms systemd-sysctl.service
          282ms sddm.service
          264ms systemd-journald.service
          249ms systemd-journal-flush.service
          208ms dev-disk-by\x2duuid-8c3c1e52\x2de46b\x2d496e\x2d9432\x2dc939674ae532.swap
          195ms user@1000.service
          192ms systemd-tmpfiles-setup-dev.service
          187ms phpsessionclean.service
          184ms systemd-sysusers.service
          181ms var.mount
          155ms systemd-update-utmp.service
          139ms plymouth-read-write.service
          112ms console-setup.service
           95ms systemd-remount-fs.service
           94ms plymouth-quit-wait.service
           90ms plymouth-quit.service
           72ms tmp.mount
           66ms kmod-static-nodes.service
           57ms packagekit.service
           57ms rtkit-daemon.service
           55ms systemd-user-sessions.service
           55ms systemd-modules-load.service
           44ms dev-mqueue.mount
           41ms sys-kernel-debug.mount
           33ms dev-hugepages.mount
           28ms plymouth-start.service
           23ms user-runtime-dir@1000.service
           21ms systemd-update-utmp-runlevel.service
           17ms postgresql.service
           95ms systemd-remount-fs.service
           94ms plymouth-quit-wait.service
           90ms plymouth-quit.service
           72ms tmp.mount
           66ms kmod-static-nodes.service
           57ms packagekit.service
           57ms rtkit-daemon.service
           55ms systemd-user-sessions.service
           55ms systemd-modules-load.service
           44ms dev-mqueue.mount
           41ms sys-kernel-debug.mount
           33ms dev-hugepages.mount
           28ms plymouth-start.service
           23ms user-runtime-dir@1000.service
           21ms systemd-update-utmp-runlevel.service

據我了解,“networking.service”服務是最耗時的服務,根據此連結中的指示,它與我筆記型電腦的“lo”介面相關聯。

我的問題是如何改進這項服務的配置,因為據我了解,介面“lo”是與我自己的筆記型電腦內部關聯的介面。

OBS:我的筆記型電腦使用了“Debian GNU/Linux 10 (buster)”

更新 - “cat /etc/network/interfaces”的詳細資訊

diego@computer:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto enp2s0
iface enp2s0 inet dhcp

您可能會在 enp2s0 上看到 DHCP 超時。由於您仍然使用 NetworkManager,我建議您只需從 中刪除 enp2s0 介面定義/etc/network/interfaces,將 enp2s0 信任到 NetworkManager。

引用自:https://unix.stackexchange.com/questions/598825