Debian
加速 Debian 伺服器上的啟動過程
我使用 SATA Samsung SSD 860 PRO 執行 Dell 的 Xeon 伺服器。
我正在尋找一種方法來加快其啟動時間。
有沒有辦法讓我加快啟動時間(
ssh
準確地說是可達時間)?我可以看到一個怪物時間問題
NetworkManager-wait-online.service
,是這樣嗎?我使用無限循環進行了第一次測量:
$ date; while ! ssh-s -t date; do :; done Wed 16 Mar 2022 08:50:54 AM CET ssh: connect to host 192.168.0.102 port 22: Connection timed out ssh: connect to host 192.168.0.102 port 22: Connection timed out ssh: connect to host 192.168.0.102 port 22: Connection timed out ssh: connect to host 192.168.0.102 port 22: Connection timed out Wed 16 Mar 2022 08:51:14 AM CET Connection to 192.168.0.102 closed.
這是硬體:
# inxi --verbosity 8 --filter System: Kernel: 5.10.0-12-amd64 x86_64 bits: 64 compiler: gcc v: 10.2.1 parameters: BOOT_IMAGE=/boot/vmlinuz-5.10.0-12-amd64 root=UUID=6eda9fbf-c86e-4e23-8587-427a06bae033 ro fsck.mode=auto fsck.repair=yes ipv6.disable=1 Desktop: Cinnamon 4.8.6 tk: GTK 3.24.24 wm: Muffin 4.8.1 dm: LightDM 1.26.0 Distro: Debian GNU/Linux 11 (bullseye) Machine: Type: Desktop System: Dell product: PowerEdge T20 v: 00 serial: <filter> Chassis: type: 6 serial: <filter> Mobo: Dell model: 0VD5HY v: A04 serial: <filter> UEFI: Dell v: A20 date: 08/20/2019 Memory: RAM: total: 31.27 GiB used: 700.2 MiB (2.2%) Array-1: capacity: 32 GiB slots: 4 EC: Single-bit ECC max module size: 8 GiB note: est. Device-1: DIMM3 size: 8 GiB speed: 1600 MT/s type: DDR3 detail: synchronous bus width: 64 bits total: 72 bits manufacturer: Micron part-no: 18KSF1G72AZ-1G6E1 serial: <filter> Device-2: DIMM1 size: 8 GiB speed: 1600 MT/s type: DDR3 detail: synchronous bus width: 64 bits total: 72 bits manufacturer: Micron part-no: 18KSF1G72AZ-1G6E1 serial: <filter> Device-3: DIMM4 size: 8 GiB speed: 1600 MT/s type: DDR3 detail: synchronous bus width: 64 bits total: 72 bits manufacturer: Micron part-no: 18KSF1G72AZ-1G6E1 serial: <filter> Device-4: DIMM2 size: 8 GiB speed: 1600 MT/s type: DDR3 detail: synchronous bus width: 64 bits total: 72 bits manufacturer: Micron part-no: 18KSF1G72AZ-1G6E1 serial: <filter> PCI Slots: Slot: 1 type: x16 PCI Express 3 x16 X16 status: Available length: Long Slot: 2 type: x1 PCI Express 2 x1 X1 status: In Use length: Short Slot: 3 type: 32-bit PCI PCI status: Available length: Short Slot: 4 type: x4 PCI Express 2 x4 X4 status: Available length: Short CPU: Info: Quad Core model: Intel Xeon E3-1225 v3 bits: 64 type: MCP arch: Haswell family: 6 model-id: 3C (60) stepping: 3 microcode: 28 L1 cache: 256 KiB L2 cache: 8 MiB L3 cache: 7.8 MiB bogomips: 25539 Speed: 866 MHz min/max: 800/3600 MHz base/boost: 3200/3800 volts: 1.2 V ext-clock: 100 MHz Core speeds (MHz): 1: 866 2: 832 3: 851 4: 846 Flags: abm acpi aes aperfmperf apic arat arch_perfmon avx avx2 bmi1 bmi2 bts clflush cmov constant_tsc cpuid cpuid_fault cx16 cx8 de ds_cpl dtes64 dtherm dts epb ept ept_ad erms est f16c flexpriority flush_l1d fma fpu fsgsbase fxsr ht ibpb ibrs ida invpcid invpcid_single lahf_lm lm mca mce md_clear mmx monitor movbe msr mtrr nonstop_tsc nopl nx pae pat pbe pcid pclmulqdq pdcm pdpe1gb pebs pge pln pni popcnt pse pse36 pti pts rdrand rdtscp rep_good sdbg sep smep smx ss ssbd sse sse2 sse4_1 sse4_2 ssse3 stibp syscall tm tm2 tpr_shadow tsc tsc_adjust tsc_deadline_timer vme vmx vnmi vpid x2apic xsave xsaveopt xtopology xtpr Vulnerabilities: Type: itlb_multihit status: KVM: VMX disabled Type: l1tf mitigation: PTE Inversion; VMX: conditional cache flushes, SMT disabled Type: mds mitigation: Clear CPU buffers; SMT disabled Type: meltdown mitigation: PTI Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via prctl and seccomp Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer sanitization Type: spectre_v2 mitigation: Retpolines, IBPB: conditional, IBRS_FW, STIBP: disabled, RSB filling Type: srbds mitigation: Microcode Type: tsx_async_abort status: Not affected Graphics: Device-1: Intel Xeon E3-1200 v3 Processor Integrated Graphics vendor: Dell driver: i915 v: kernel bus ID: 00:02.0 chip ID: 8086:041a class ID: 0300 Display: server: X.Org 1.20.13 driver: loaded: modesetting unloaded: fbdev,vesa display ID: localhost:10.0 screens: 1 Screen-1: 0 s-res: 3840x2160 s-dpi: 48 s-size: 2032x1143mm (80.0x45.0") s-diag: 2331mm (91.8") Monitor-1: eDP-1-1 res: 3840x2160 hz: 60 dpi: 283 size: 345x194mm (13.6x7.6") diag: 396mm (15.6") OpenGL: renderer: N/A v: N/A direct render: N/A Audio: Message: No Device data found. Network: Device-1: Intel Ethernet I217-LM vendor: Dell driver: e1000e v: kernel port: f080 bus ID: 00:19.0 chip ID: 8086:153a class ID: 0200 IF: eth0 state: up speed: 1000 Mbps duplex: full mac: <filter> IP v4: <filter> type: noprefixroute scope: global broadcast: <filter> WAN IP: <filter> Bluetooth: Message: No Bluetooth data was found. Logical: Message: No LVM data was found. RAID: Message: No RAID data was found. Drives: Local Storage: total: 238.47 GiB used: 9.23 GiB (3.9%) ID-1: /dev/sda maj-min: 8:0 vendor: Samsung model: SSD 860 PRO 256GB family: based SSDs size: 238.47 GiB block size: physical: 512 B logical: 512 B sata: 3.1 speed: 6.0 Gb/s rotation: SSD serial: <filter> rev: 2B6Q temp: 23 C scheme: GPT SMART: yes state: enabled health: PASSED on: 1y 25d 1h cycles: 1044 written: 3.77 TiB Message: No Optical or Floppy data was found. Partition: ID-1: / raw size: 237.97 GiB size: 234.11 GiB (98.38%) used: 9.22 GiB (3.9%) fs: ext4 block size: 4096 B dev: /dev/sda2 maj-min: 8:2 label: N/A uuid: 6eda9fbf-c86e-4e23-8587-427a06bae033 ID-2: /boot/efi raw size: 512 MiB size: 511 MiB (99.80%) used: 3.4 MiB (0.7%) fs: vfat block size: 512 B dev: /dev/sda1 maj-min: 8:1 label: N/A uuid: 22B0-57B9 Swap: Alert: No Swap data was found. Unmounted: Message: No Unmounted partitions found. USB: Hub-1: 1-0:1 info: Full speed (or root) Hub ports: 3 rev: 2.0 speed: 480 Mb/s chip ID: 1d6b:0002 class ID: 0900 Hub-2: 1-1:2 info: Intel Integrated Rate Matching Hub ports: 6 rev: 2.0 speed: 480 Mb/s chip ID: 8087:8008 class ID: 0900 Hub-3: 2-0:1 info: Full speed (or root) Hub ports: 15 rev: 2.0 speed: 480 Mb/s chip ID: 1d6b:0002 class ID: 0900 Hub-4: 3-0:1 info: Full speed (or root) Hub ports: 3 rev: 2.0 speed: 480 Mb/s chip ID: 1d6b:0002 class ID: 0900 Hub-5: 3-1:2 info: Intel Integrated Rate Matching Hub ports: 8 rev: 2.0 speed: 480 Mb/s chip ID: 8087:8000 class ID: 0900 Hub-6: 4-0:1 info: Full speed (or root) Hub ports: 6 rev: 3.0 speed: 5 Gb/s chip ID: 1d6b:0003 class ID: 0900 Sensors: System Temperatures: cpu: 29.8 C mobo: 27.8 C Fan Speeds (RPM): N/A Repos: Packages: 2134 apt: 2131 lib: 1242 flatpak: 3 Active apt repos in: /etc/apt/sources.list 1: deb http://deb.debian.org/debian bullseye main contrib non-free 2: deb http://deb.debian.org/debian bullseye-updates main contrib non-free 3: deb http://security.debian.org/debian-security bullseye-security main contrib non-free 4: deb http://ftp.debian.org/debian bullseye-backports main contrib non-free Active apt repos in: /etc/apt/sources.list.d/sublime-text.list 1: deb [arch=amd64] https://download.sublimetext.com/ apt/stable/ No active apt repos in: /etc/apt/sources.list.d/virtualbox.list Processes: CPU top: 5 of 153 1: cpu: 0.3% command: init pid: 1 mem: 10.3 MiB (0.0%) 2: cpu: 0.1% command: lightdm-gtk-greeter pid: 606 mem: 68.9 MiB (0.2%) 3: cpu: 0.0% command: [kthreadd] pid: 2 mem: 0.00 MiB (0.0%) 4: cpu: 0.0% command: [rcu_gp] pid: 3 mem: 0.00 MiB (0.0%) 5: cpu: 0.0% command: [rcu_par_gp] pid: 4 mem: 0.00 MiB (0.0%) Memory top: 5 of 153 1: mem: 68.9 MiB (0.2%) command: lightdm-gtk-greeter pid: 606 cpu: 0.1% 2: mem: 44.2 MiB (0.1%) command: xorg pid: 556 cpu: 0.0% 3: mem: 37.3 MiB (0.1%) command: goa-daemon pid: 669 cpu: 0.0% 4: mem: 26.2 MiB (0.0%) command: tracker-miner-fs pid: 605 cpu: 0.0% 5: mem: 17.4 MiB (0.0%) command: systemd-journald pid: 253 cpu: 0.0% Info: Processes: 153 Uptime: 6m wakeups: 0 Init: systemd v: 247 runlevel: 5 Compilers: gcc: 10.2.1 alt: 10/4.9/6/8 Shell: Bash v: 5.1.4 running in: sshd (SSH) inxi: 3.3.01
**
dmesg
**第一行+最後一行:[Wed Mar 16 08:51:06 2022] microcode: microcode updated early to revision 0x28, date = 2019-11-12 ... [Wed Mar 16 08:51:12 2022] e1000e 0000:00:19.0 eth0: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx
systemd-analyze
:# systemd-analyze blame 3.163s NetworkManager-wait-online.service 406ms netfilter-persistent.service 240ms dev-sda2.device 176ms systemd-journal-flush.service 115ms udisks2.service 103ms exim4.service 102ms user@117.service 101ms accounts-daemon.service 93ms apparmor.service 85ms e2scrub_reap.service 83ms systemd-udev-trigger.service 82ms boot-efi.mount 80ms keyboard-setup.service 76ms plymouth-start.service 75ms upower.service 70ms user@0.service 66ms smartmontools.service 61ms systemd-journald.service 52ms avahi-daemon.service 51ms systemd-logind.service 49ms ifupdown-pre.service 45ms systemd-timesyncd.service 41ms wpa_supplicant.service 38ms lightdm.service 34ms NetworkManager.service 32ms networking.service 32ms systemd-udevd.service 31ms run-rpc_pipefs.mount 29ms ssh.service 21ms systemd-remount-fs.service 21ms systemd-fsck@dev-disk-by\x2duuid-22B0\x2d57B9.service 21ms lm-sensors.service 19ms systemd-tmpfiles-setup.service 16ms systemd-modules-load.service 15ms systemd-tmpfiles-clean.service 15ms rsyslog.service 12ms polkit.service 12ms atd.service 11ms modprobe@configfs.service 11ms rpcbind.service 11ms dev-hugepages.mount 11ms plymouth-read-write.service 11ms dev-mqueue.mount 11ms systemd-sysusers.service 10ms modprobe@fuse.service 10ms sys-kernel-debug.mount 9ms systemd-tmpfiles-setup-dev.service 9ms sys-kernel-tracing.mount 9ms systemd-random-seed.service 9ms gdomap.service 8ms kmod-static-nodes.service 8ms systemd-sysctl.service 7ms modprobe@drm.service 7ms user-runtime-dir@0.service 7ms user-runtime-dir@117.service 6ms systemd-update-utmp.service 5ms nfs-config.service 5ms systemd-update-utmp-runlevel.service 5ms systemd-user-sessions.service 4ms console-setup.service 4ms sys-fs-fuse-connections.mount 3ms sys-kernel-config.mount 1ms rc-local.service 1ms plymouth-quit-wait.service
# 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 @4.307s └─multi-user.target @4.307s └─exim4.service @4.204s +103ms └─network-online.target @4.203s └─NetworkManager-wait-online.service @1.040s +3.163s └─NetworkManager.service @1.004s +34ms └─network-pre.target @1.004s └─netfilter-persistent.service @597ms +406ms └─local-fs.target @595ms └─run-user-117-gvfs.mount @1.544s └─run-user-117.mount @1.373s └─local-fs-pre.target @314ms └─keyboard-setup.service @234ms +80ms └─systemd-journald.socket @230ms └─system.slice @181ms └─-.slice @181ms
因此,總啟動時間大約為 20 秒,其中大約 6 秒是在 NIC 啟動之前啟動核心/OS,另外還有 2 秒用於在 NIC 啟動後啟動網路服務。
這使得韌體和引導載入程序成為最大的單個組件,總共需要 12 秒。您可能需要檢查韌體設置(BIOS/UEFI 設置)以確保跳過或盡快執行任何記憶體測試等。
您的“怪物時間問題
NetworkManager-wait-online.service
”只有大約 3 或 4 秒。您可能希望在它之後添加並以 root
e1000e
身份/etc/initramfs-tools/modules
執行update-initramfs -u
,以確保儘早載入 NIC 驅動程序模組。如果可能,您還需要關閉系統的網路交換機埠中的任何節能乙太網 (EEE) 或其他省電功能:這應該可以簡化和加速物理網路連接的啟動。