EDIT: This won't work if you have a recent udev
version, because udev
prevents you from starting long-lived background processes in RUN
scripts. You may or may not be able to get around this by prefixing the getty
command with setsid
but in any case it's discouraged if not outright disallowed. If you have a system which uses systemd
then there is another way to achieve this, which I hope someone will supply with another answer. In the meantime, I'm leaving this answer here in case it works for you.
You cannot use a USB serial port as a console because USB is initialized too late in the boot sequence, long after the console needs to be working.
You can run getty
on a USB serial port to allow you to log in and get a shell session on that port, but it will not be the system's console.
To get getty
to start automatically, try this udev
rule:
ACTION=="add", SUBSYSTEM=="tty", ENV{ID_BUS}=="usb", RUN+="/usr/local/sbin/usbrungetty"
Put that in a rules file in /etc/udev/rules.d
and then create this executable script /usr/local/sbin/usbrungetty
:
#!/bin/sh
/sbin/getty -L "$DEVNAME" 115200 vt102 &