I have a CentOS 7 headless system with no serial ports. I sometimes want to access the server using a serial cable, so I plug in a USB serial cable (to my laptop's serial port) but I can't get a console/BASH from the connection.
Is there something I have to do to tell the kernel to always create a serial console on appearance of a USB serial port?
Best Answer
EDIT: This won't work if you have a recent
udev
version, becauseudev
prevents you from starting long-lived background processes inRUN
scripts. You may or may not be able to get around this by prefixing thegetty
command withsetsid
but in any case it's discouraged if not outright disallowed. If you have a system which usessystemd
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 thisudev
rule:Put that in a rules file in
/etc/udev/rules.d
and then create this executable script/usr/local/sbin/usbrungetty
: