The widespread adoption of systemd and the systemd way of doing things has obsoleted huge swaths of documentation (and disordered opinion in user forums) about how to set up a serial console on a Linux machine. Read on for my own recipe for success with a Fedora 20 system.
First of all I want to acknowledge, and thank, Lennart Poettering, one of the systemd developers, for his continuing efforts to explain it to the rest of us. Part XVI of his multi-part “systemd for Administrators” (begun in 2010) was the key to my deciphering how serial console services are generated under systemd.
The most important thing I learned from that article is that if the kernel is loaded with the correct parameters, systemd will automatically set up the service necessary to establish a serial console.
My main problem was that I was unable to find a coherent, or complete, description of what those parameters need to be. Serial console short HowTo came close enough for me to come up with the answer (after spending some quality time with the Fedora Project’s documentation for grub2).
It all begins with /etc/default/grub. Start by adding the following lines to the end of that file:
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyUSB0" GRUB_TERMINAL=serial GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --partiy=no --stop=1"
Then regenerate grub’s configuration:
grub2-mkconfig -o /boot/grub2/grub.cfg
The system in question did not have a “real” serial port. To make up for this shortcoming I attached a usb to RS-232 serial port adapter from which a standard null modem cable was ran to a separate workstation that did have the once ubiquitous DB9 connector connected to an honest-to-God serial port header (labelled “COM1”) on its motherboard (this is the Lenovo ThinkCentre Edge 72 I picked up early last year — the mainboard is an MSI socket 1155 with both serial and parallel port headers like the MSI H61M-P31/W8).
After a reboot, systemd created and started the requisite target (“serial-getty@ttyUSB0.service”) automatically, without my needing to copy files or symlinks.
Connecting over the serial port was then as easy as firing up minicom on my “remote” machine (invoke initially as root with the “-s” switch, i.e. “minicom -s”), setting it to use /dev/ttyS0 as the local Serial Device at a Bps of 115200 8N1. I left the Screen and Keyboard settings at their defaults, except to change the Backspace key from BS to DEL.
A Note on RS-232 Hardware:
For RS-232 (DB9) to usb adapters stick with those employing FTDI chips. Steer clear of any using a Prolific chipset.
When you want a fixed port rather than an adapter the same advice holds true for the DB-9 to usb header kit. Look for FTDI. I didn’t have any luck with add-in cards, so if you want “real” RS-232, look for a motherboard that supports it (MSI’s H61M-P31/W8, for example).