Serial-Port

主機上的串列在引導期間停止工作

  • May 19, 2021

我正在使用核心 5.4.103-1-pve 執行 Proxmox 6.4(我已經在他們的論壇中問過這個問題,但沒有運氣)。我的主機板有一個 COM 頭,所以我最近得到了連接它並通過串口進行管理所需的設備。但是,系統啟動後我無法使用串列。港口位於ttyS0。我在 GRUB 中進行了設置(請注意,在 SSH 啟動之前,我的設置是僅串列的,系統中唯一的 GPU 實際上並未被 GRUB 或 Linux 使用,僅用於直通):

GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"

console=ttyS0,115200然後我通過添加到核心命令行來為 Linux 設置它。現在,當我啟動主機時,我首先看到 GRUB 菜單,並且可以與它完全互動,然後看到正常載入的 initramfs 消息,然後是大部分正常的 Linux 啟動過程。但是,一旦它到達“登錄服務”,就不再有任何輸出,我無法與終端互動:

...
        Starting Proxmox VE Login Banner...
        Starting Enable support fo…l executable binary formats...
[  OK  ] Reached target ZFS volumes are ready.
[  OK  ] Started Preprocess NFS configuration.
[  OK  ] Started Set console font and keymap.
[  OK  ] Started Create Volatile Files and Directories.
[  OK  ] Started Load AppArmor profiles.
[  OK  ] Started Proxmox VE firewall logger.
        Mounting Arbitrary Executable File Formats File System...
        Starting Raise network interfaces...
[   17.623601] Generic FE-GE Realtek PHY r8169-800:00: attached PHY driver [Generic FE-GE Realtek PHY] (mii_bus:phy_addr=r8169-800:00, irq=IGNORE)
        Starting Network Time Synchronization...
        Starting Update UTMP about System Boot/Shutdown...
        Starting RPC bind portmap service...
[  OK  ] Reached target NFS client services.
[  OK  ] Started Proxmox VE Login Banner.
[  OK  ] Started Commit Proxmox VE network changes.
[  OK     17.739718] r8169 0000:08:00.0 enp8s0: Link is Down
0m] Mounted Arbitrary Executable File Formats File System.
[  OK  ] Started    17.760897] 8021q: 802.1Q VLAN Support v1.8
1;39mRPC bind portmap service.
[  OK  ] Started Network Time Synchronization.
[  OK  ] Started Enable support for…nal executable binary formats.
[  OK  ] Reached target System Time Synchronized.
[  OK  ] Reached target RPC Port Mapper.
[  OK  ] Started Update UTMP about System Boot/Shutdown.
[  OK  ] Reached target System Initialization.
[  OK  ] Listening on D-Bus System Message Bus Socket.
[  OK  ] Reached target Sockets.
[  OK  ] Reached target Basic System.
        Starting Proxmox VE LXC Syscall Daemon...
[  OK  ] Started D-Bus System Message Bus.
        Starting PVE Qemu Event Daemon...
[  OK  ] Started ZFS Event Daemon (zed).
        Starting System Logging Service...
[  OK  ] Started Daily apt download activities.
[  OK  ] Started Daily apt upgrade and clean activities.
        Starting LSB: The monitor UPS software....
[  OK  ] Started Daily rotation of log files.
[  OK  ] Started Daily man-db regeneration.
        Starting Login Service...
[  OK  ] Started Proxmox VE [   18.118065] softdog: initialized. soft_noboot=0 soft_margin=60 sec soft_panic=0 (nowayout=0)
watchdog multiplexer.
        Starting Kernel Samepage Merging (KSM) Tuning Daemon...
[  OK  ] Started Daily Cleanup of Temporary Directories.
[  OK  ] Started Daily PVE download activities.
        Starting Self Monitoring a…g Technology (SMART) Daemon...
        Starting ZFS file system shares...
[  OK  ] Started Proxmox VE replication runner.
[  OK  ] Reached target Timers.
[  OK  ] Started FUSE filesy[   18.258047] new mount options do not match the existing superblock, will be ignored
stem for LXC.
        Starting Initialize hardware monitoring sensors...
[  OK  ] Started Proxmox VE LXC Syscall Daemon.
[  OK  ] Started System Logging Service.
[  OK  ] Started PVE Qemu Event Daemon.
[  OK  ] Started Kernel Samepage Merging (KSM) Tuning Daemon.
[  OK  ] Started ZFS file system shares.
[  OK  ] Reached target ZFS startup target.
[  OK  ] Started Initialize hardware monitoring sensors.
[  OK  ] Started Login Service.

如果我通過 SSH 登錄,我可以看到該serial-getty@ttyS0服務正在執行,並且它的日誌顯示零錯誤或警告。同樣,dmesg系統日誌對此沒有錯誤。即使我重新啟動服務,串列終端仍然無法工作。如果我執行stty -a -F /dev/ttyS0,我可以看到由於某種原因波特率設置為 2400,即使它在引導期間是正確的。我可以手動將其設置回 115200 波特,但如果我這樣做,然後在終端的客戶端輸入任何內容,它會在顯示該字元後立即恢復為 2400。但是,如果我手動重置它然後重新啟動serial-getty@ttyS0,它會保持 115200 波特並保持互動。

我一直無法在網際網路上的任何地方找到解決方案,也許我的 Google-fu 不夠強大,但很難找到一個類似的問題,它部分有效,不像大多數人所經歷的那樣,它根本不起作用.

編輯

多虧了 telcoM,這個問題現在已經解決了。作為參考,預設ExecStart行是:

ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,38400,9600 %I $TERM

所以執行systemctl edit serial-getty@ttyS0並添加以下行修復它:

[Service]
ExecStart=
ExecStart=-/sbin/agetty -o '-p -- \\u' 115200 %I $TERM

您需要找出您的serial-getty@ttyS0服務定義為實際agetty流程指定的選項。請執行systemctl cat serial-getty@ttyS0並將輸出編輯到您的問題中。

如果該ExecStart行包含(簡稱為)的--keep-baud選項,那麼您可能需要創建一個覆蓋文件來調整選項,因為您的目標似乎是固定波特率 115200。agetty``-s``agetty

我必須做一些非常相似的事情,因為我的 Debian 10 的串列埠預設ExecStart行是:agetty

ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,38400,9600 %I $TERM

在那種特定情況下,我希望選項是/sbin/agetty -o '-p -- \\u' 57600 %I vt-utf8.

(硬體有一個遠端控制台處理器,其韌體僅以 57600 bps 的速率工作。使用這個模組,我可以 SSH 到遠端控制台處理器,啟動虛擬串列控制台模式,並訪問串列控制台,而不會出現鍵盤佈局問題基於 Java 的虛擬 KVM 控制台。)

由於一個服務可以有多行,如果要替換現有行而不是添加第二行,則ExecStart必須首先在覆蓋文件中指定一個空白選項。所以我製作了一個包含以下內容的文件:ExecStart=``/etc/systemd/system/serial-getty@ttyS0.service.d/override.conf

[Service]
ExecStart=
ExecStart=-/sbin/agetty -o '-p -- \\u' 57600 %I vt-utf8

您可能需要做類似的事情,儘管在您的情況下顯然波特率為 115200。

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