提高性能和减少启动时间的技巧 - Ubuntu 21.04

提高性能和减少启动时间的技巧 - Ubuntu 21.04

我安装完成了 Ubuntu 21.04。我选择它而不是 20.04 LTS,因为它本身不支持我的 wifi 适配器。我尝试了不同的发行版,试图找到启动时间最快的那个。到目前为止,Xubuntu 21.04 是启动速度最快的,但有缺陷,我不喜欢 Xfce。我试图减少启动时间,不是为了挑剔或“灵活变通”,而是因为我经营一家在线业务,每一分钟都很重要。如果这有帮助,以下是我的计算机规格:

  • 2TB 5400 rpm 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 L2 缓存,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 不匹配,因此无法获得内存交错的速度优势。将 4G RAM 替换为 8G RAM 可以改善这种情况。

AMD 处理器对 RAM 的要求非常严格。建议运行内存测试。转到https://www.memtest86.com/并免费下载/运行它们memtest来测试你的记忆力。至少完成一次所有 4/4 测试以确认记忆力良好。这可能需要几个小时才能完成。

交换

2G 的 /swapfile 太小了。我们将它增加到 4G...

笔记:错误使用rmdd命令可能会导致数据丢失。建议复制/粘贴。

在里面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

相关内容