Enabling a USB Serial Console on Linux

submited by
Style Pass
2024-06-08 13:30:06

Serial consoles have been used to communicate with headless networking and datacenter gear for decades. It works without requiring a screen, keyboard or networking which makes it helpful for debugging embedded devices and clusters of broken laptops and headless Arm boxes (which is my home lab). Most devices stopped shipping with serial ports years ago and USB to RS-232 serial adapters became common, but I picked up a USB to USB crossover serial adapter eliminating the need for separate cables. I purchased mine from Alibaba.com, which was cheaper than the name-brand alternatives (about $25 with shipping to Australia).

On Linux the serial console is usually available as ttyS0, and if it’s enabled you can connect to it with tools like screen or minicom. Physical and virtual consoles are connected to serial ports and the terminal with the application getty (“get tty”), presenting the user with a login prompt. A USB serial console would be available as ttyUSB0, so you need to connect the Linux service getty to ttyUSB0. For most recent Linux versions, this is managed by systemd so enabling and starting the service is as simple as:

This creates a symlink from /etc/systemd/system/getty.target.wants/getty@ttyUSB0.service to /lib/systemd/system/getty@.service and starts listening on the USB serial console. I ran this on Raspbian 10, Armbian 11, and Debian 11 x86 and Arm systems and it worked across the board. I added it to my Chef recipe to ensure it stayed enabled across my current and any future machines.

Leave a Comment