2024

Kernel and Linux console to ttyUSB0

Recently, I needed to access a Linux device without a serial port via a serial console. One way to set this up is by adding console=ttyUSB0,115200 (assuming 115200 bps) to the kernel parameters. If you are using an ostree based system you can do:

rpm-ostree kargs --append=console=ttyUSB0,115200

Then, once the Linux kernel discovers ttyUSB0 during the boot process, the buffer will be drained down through the virtual serial port.

In addition, you can enable the serial-getty@ttyUSB0 virtual service. i.e., by running:

systemctl enable --now serial-getty@ttyUSB0

For this I am still hitting an issue where SELinux is unhappy about agetty accessing ttyUSB0

[   10.191665] audit: type=1400 audit(1705425829.003:104): avc:  denied  { watch watch_reads } for  pid=778 comm="(agetty)" path="/dev/ttyUSB0" dev="devtmpfs" ino=549 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:usbtty_device_t:s0 tclass=chr_file permissive=0

Hopefully, there is a way to fix this in a more sane way than setting SELinux to permissive.