Serial console login broken: /etc/ttys uses ttyU (uppercase) but devices are ttyu (lowercase)
support
**Important notices**
- [x] I have read the contributing guidelines at https://github.com/opnsense/core/blob/master/CONTRIBUTING.md
- [x] I am convinced that my issue is new after having checked both open and closed issues at https://github.com/opnsense/core/issues?q=is%3Aissue
**Describe the bug**
When USB serial console mode is enabled (System → Settings → Administration → Primary Console: Serial), OPNsense generates `/etc/ttys` entries for `ttyU0`/`ttyU1` (uppercase U). However the actual FreeBSD device nodes are `ttyu0`/`ttyu1` (lowercase u). Getty is configured for devices that don't exist, so no login prompt ever appears on the serial console.
Last known working version: unknown — we came to OPNsense fresh on this hardware. The same root cause was reported in #5216 (2021, OPNsense 21.x) suggesting this has been present for some time.
**To Reproduce**
1. Install OPNsense on hardware where the serial port is an internal USB-to-serial chip that FreeBSD enumerates as native UARTs (`ttyu0`/`ttyu1`) rather than ucom devices
2. Enable serial console: System → Settings → Administration → Primary Console: Serial (this sets `serialusb=1` in config.xml)
3. Reboot
4. Observe: no login prompt on serial console
**Expected behavior**
A `login:` prompt should appear on the serial console after boot.
**Describe alternatives you considered**
This issue was previously closed (#5216) with the suggestion to disable USB serial mode. Disabling it causes OPNsense to generate `ttyu` entries but with `onifconsole` status, which only activates getty if the kernel marks the device as a console at boot. On hardware where the serial chip presents as native UARTs this flag never triggers, so there is still no login prompt. Neither option produces a working serial console login on this class of hardware.
The suggested fix (below) is to detect at runtime which device node actually exists and generate `/etc/ttys` accordingly. Alternatively, a workaround via syshook is documented below.
**Suggested fix**
In `system.inc`, `system_login_configure()` currently generates `/etc/ttys` as either `ttyU` (uppercase, USB serial via ucom) or `ttyu` with `onifconsole` (native UART, only active if kernel marks as console). Neither works for hardware where the chip is internal USB-to-serial but presents as native UARTs.
Option 1 — runtime detection: before writing `/etc/ttys`, check whether `/dev/ttyu0` or `/dev/ttyU0` exists and generate the entry accordingly. This would handle both device types automatically.
Option 2 — add a third mode: add an option to generate `ttyu` entries with `on secure` status (always-on getty, native UART naming) as a distinct choice from the current `serialusb` flag.
**Workaround**
Keep `serialusb=1` (for always-on gettys) and create symlinks via an OPNsense syshook that runs after `system_login_configure()` regenerates `/etc/ttys`:
```sh
cat > /usr/local/etc/rc.syshook.d/start/99-serial-console << 'EOF'
#!/bin/sh
ln -sf /dev/ttyu0 /dev/ttyU0
ln -sf /dev/ttyu0.init /dev/ttyU0.init
ln -sf /dev/ttyu0.lock /dev/ttyU0.lock
ln -sf /dev/ttyu1 /dev/ttyU1
ln -sf /dev/ttyu1.init /dev/ttyU1.init
ln -sf /dev/ttyu1.lock /dev/ttyU1.lock
kill -HUP 1
EOF
chmod +x /usr/local/etc/rc.syshook.d/start/99-serial-console
```
**Relevant log files**
Syslog shows getty failing on the non-existent uppercase device:
```
getty repeating too quickly on port /dev/ttyU0, sleeping 30 secs
open /dev/ttyU0: No such file or directory
```
**Additional context**
Previously reported as #5216 (closed without fix).
**Environment**
OPNsense 26.1.6_2 (amd64)
VeloCloud Edge 510 (x86, internal USB-to-serial chip presenting as ISA UARTs uart0/uart1)
1 条评论