主机上的串行在启动期间停止工作

主机上的串行在启动期间停止工作

我正在运行带有内核 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

答案1

您需要找出您的serial-getty@ttyS0服务定义为实际agetty流程指定了哪些选项。请运行systemctl cat serial-getty@ttyS0并将输出编辑到您的问题中。

如果该ExecStart行包含一个--keep-baud选项agetty(缩写形式为-s),那么您可能需要创建一个覆盖文件来调整选项agetty,因为您似乎将 115200 的固定波特率作为您的目标。

我必须做一些非常类似的事情,因为我的 Debian 10 的串行端口默认行ExecStartagetty

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

在这种特定情况下,我希望选项是/sbin/agetty -o '-p -- \\u' 57600 %I vt-utf8.

(硬件有一个远程控制台处理器,其固件只能以 57600 bps 的速率工作。使用此 mod,我可以通过 SSH 进入远程控制台处理器,激活虚拟串行控制台模式,并访问串行控制台,而不会出现键盘布局问题基于 Java 的虚拟 KVM 控制台。)

由于服务可以有多ExecStart行,因此ExecStart=如果您想要代替现有线路而不是添加第二个。所以我制作了一个包含以下内容的文件:/etc/systemd/system/[email protected]/override.conf

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

您可能需要做类似的事情,尽管在您的情况下显然波特率为 115200。

相关内容