提高效能和減少啟動時間的技巧 - Ubuntu 21.04

提高效能和減少啟動時間的技巧 - Ubuntu 21.04

我完成了 Ubuntu 21.04 的安裝。我選擇這個而不是 20.04 LTS,因為它本身不支援我的 wifi 適配器。我瀏覽了不同的發行版,試圖找出啟動時間最快的發行版。到目前為止,Xubuntu 21.04 是啟動速度最快的,但有 bug,而且我不喜歡 Xfce。我試圖減少開機時間,不是為了挑剔或“靈活”,而是因為我經營在線業務,每一分鐘都很重要。如果這有幫助,這是我的計算機規格:

  • 2TB 5400 轉 SATA
  • 12GB DDR4-2400 SDRAM
  • 802.11b/g/n/ac Wifi 和藍牙 4.2 組合 (Realtek RTL8821ce)
  • Ubuntu 21.04 與 Windows 10 雙啟動
  • AMD Athlon Gold 3150U(2.4GHz,高達 3.3 Ghz,1 MB 二級緩存,2 核心),配備 AMD Radeon 顯示卡

輸出來自systemd-analyze blame

1min 27.453s snapd.seeded.service
1min 17.267s plymouth-quit-wait.service
     16.950s networkd-dispatcher.service
     14.426s snapd.service
     10.870s NetworkManager-wait-online.service
     10.163s dev-sda6.device
      8.543s udisks2.service
      7.301s apparmor.service
      6.341s NetworkManager.service
      6.310s ModemManager.service
      6.216s accounts-daemon.service
      4.649s polkit.service
      4.227s thermald.service
      3.986s bluetooth.service
      3.986s avahi-daemon.service
      3.898s wpa_supplicant.service
      3.878s power-profiles-daemon.service
      3.734s apport.service
      3.699s switcheroo-control.service
      3.689s systemd-logind.service
      3.435s cups.service
      3.431s e2scrub_reap.service
      3.323s dev-loop2.device

輸出來自systemd-analyze critical-chain

graphical.target @2min 8.160s
└─multi-user.target @2min 8.160s
  └─snapd.seeded.service @40.705s +1min 27.453s
    └─snapd.service @26.271s +14.426s
      └─basic.target @25.806s
        └─sockets.target @25.805s
          └─snapd.socket @25.804s +1ms
            └─sysinit.target @25.558s
              └─snapd.apparmor.service @22.981s +2.577s
                └─apparmor.service @15.678s +7.301s
                  └─local-fs.target @15.676s
                    └─run-snapd-ns-snap\x2dstore.mnt.mount @1min 7.986s
                      └─run-snapd-ns.mount @1min 6.169s
                        └─local-fs-pre.target @6.251s
                          └─systemd-tmpfiles-setup-dev.service @6.201s +50ms
                            └─systemd-sysusers.service @4.618s +1.581s
                              └─systemd-remount-fs.service @4.243s +289ms
                                └─systemd-journald.socket @4.071s
                                  └─-.mount @4.063s
                                    └─-.slice @4.063s

輸出來自systemd-analyze

Startup finished in 5.921s (firmware) + 6.908s (loader) + 7.139s (kernel) + 2min 8.173s (userspace) = 2min 28.143s 
graphical.target reached after 2min 8.160s in userspace

對於@heynnema:

輸出snap list

Name                Version             Rev    Tracking         Publisher   Notes
core18              20210309            1997   latest/stable    canonical✓  base
core20              20210319            975    latest/stable    canonical✓  base
gnome-3-34-1804     0+git.3556cb3       66     latest/stable/…  canonical✓  -
gtk-common-themes   0.1-52-gb92ac40     1515   latest/stable/…  canonical✓  -
snap-store          3.38.0-59-g494f078  518    latest/stable/…  canonical✓  -
snapd               2.50                11841  latest/stable    canonical✓  snapd
whitesur-gtk-theme  3.4                 74     latest/stable    spider623   -

輸出free -h

 total        used        free      shared  buff/cache   available
Mem:          9.7Gi       1.8Gi       785Mi        70Mi       7.1Gi       7.5Gi
Swap:         2.0Gi       1.0Mi       2.0Gi

輸出sysctl vm.swappiness

vm.swappiness = 60

輸出sudo lshw -C memory

  *-firmware                
       description: BIOS
       vendor: AMI
       physical id: 0
       version: F.57
       date: 09/28/2020
       size: 64KiB
       capacity: 16MiB
       capabilities: pci upgrade shadowing cdboot bootselect edd int13floppy1200 int13floppy720 int13floppy2880 int5printscreen int9keyboard int14serial int17printer acpi usb smartbattery biosbootspecification netboot uefi
  *-memory
       description: System Memory
       physical id: 9
       slot: System board or motherboard
       size: 12GiB
     *-bank:0
          description: SODIMM DDR4 Synchronous Unbuffered (Unregistered) 3200 MHz (0.3 ns)
          product: HMA851S6DJR6N-XN
          vendor: Hynix
          physical id: 0
          serial: 22691E37
          slot: Bottom - Slot 1 (left)
          size: 4GiB
          width: 64 bits
          clock: 3200MHz (0.3ns)
     *-bank:1
          description: SODIMM DDR4 Synchronous Unbuffered (Unregistered) 2667 MHz (0.4 ns)
          product: AO1P26KC8T1-BXPS
          vendor: A-DATA Technology
          physical id: 1
          serial: 4FB00000
          slot: Bottom - Slot 2 (right)
          size: 8GiB
          width: 64 bits
          clock: 2667MHz (0.4ns)
  *-cache:0
       description: L1 cache
       physical id: b
       slot: L1 - Cache
       size: 192KiB
       capacity: 192KiB
       clock: 1GHz (1.0ns)
       capabilities: pipeline-burst internal write-back unified
       configuration: level=1
  *-cache:1
       description: L2 cache
       physical id: c
       slot: L2 - Cache
       size: 1MiB
       capacity: 1MiB
       clock: 1GHz (1.0ns)
       capabilities: pipeline-burst internal write-back unified
       configuration: level=2
  *-cache:2
       description: L3 cache
       physical id: d
       slot: L3 - Cache
       size: 4MiB
       capacity: 4MiB
       clock: 1GHz (1.0ns)
       capabilities: pipeline-burst internal write-back unified
       configuration: level=3

如果您需要更多輸出,我將在下面進行編輯。任何幫助都會很棒。謝謝大家,祝大家有美好的一天!

答案1

啟動建議...

磁碟

如前所述,SSD 會對您的啟動時間產生重大影響。 1TB SSD 現在不到 100 美元。

記憶體

由於您擁有無與倫比的 RAM SODIMM/DIMM,因此您無法獲得記憶體交錯的速度優勢。用 8G RAM 替換 4G RAM 會有所改善。

AMD 處理器對 RAM 非常挑剔。建議運行內存測試。去https://www.memtest86.com/並免費下載/運行它們memtest來測試您的記憶力。至少完成一次所有 4/4 測試,以確認良好的記憶力。這可能需要幾個小時才能完成。

交換

2G /swapfile 太小了。我們會把它增加到4G...

筆記rm:和命令使用不當dd可能會導致資料遺失。建議複製/貼上。

在裡面terminal...

sudo swapoff -a           # turn off swap
sudo rm -i /swapfile      # remove old /swapfile

sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

sudo chmod 600 /swapfile  # set proper file protections
sudo mkswap /swapfile     # init /swapfile
sudo swapon /swapfile     # turn on swap
free -h                   # confirm 12G RAM and 4G swap

sudo -H gedit /etc/fstab使用或編輯 /etc/fstab sudo pico /etc/fstab

確認 /etc/fstab 中的此 /swapfile 行...並確認沒有其他「交換」行...在此行中使用空格...確認沒有製表符...

/swapfile  none  swap  sw  0  0

reboot                    # reboot and verify operation

相關內容