Menu

Debian Jessie, PC-Engines Alix, and the serial console.

Being close to my 40th year on Earth, and having had my first computer as I was 10 years old, I'm still very reluctant to drop some old school things such as RS-232 serial consoles to get system console.
I love how easy and unchanged over time is CISCO's usage of serial consoles... no matter what happens... if you have a serial cable you have the certainty you'll always be able to recover your crap.
Being used to get Linux appliances manageable through COM port as a last resource, the advent of systemd in Debian Jessie has rendered most of my former knowledge obsolete... so it was time to get my serial console up and ready again!

inittab is dead

Everything evolves, and does it always with goodness in mind (that's the theory) and the fact is, once you take your time to read what's new and how things do work now, you'll discover that in effect, things are lot easier now.

Formerly, we used to play with /etc/inittab file in order to let sysvinit to spawn serial consoles during the boot process... now, with systemd in scene, things are less rigid, more fluid, and automagically set as needed, so now, we do not have to care on setting one, two, three consoles and rigidly configure them, now serial consoles are managed like any other system service, and, once the service is enabled, consoles and their hardware resources are served as needed.

So, in order to start a console for your system on COM1 (/dev/ttyS0) you simply need to:

systemctl start serial-getty@ttyS0.service

 
It works! but not only it works, it supports several baudrates... great!.
So, accordingly, if you want the console to be set automatically after booting, you'll do:

systemctl enable serial-getty@ttyS0.service

 
You can test your agetty process is running ps aux command:

ps aux | grep getty

root       857  0.0  0.6   3948  1708 tty1     Ss+  16:38   0:00 /sbin/agetty --noclear tty1 linux
root      8943  0.0  0.8   4324  2052 pts/0    S+   17:11   0:00 grep getty

 

Booting from the serial console

Having a serial console after system boot is iseful, but, in the absence of video output, the ability to get early booting, grub handling, and boot output messages into screen can be not only useful, but a true necessity.
So, to get our boot process redirected to serial, we have to make certain changes to our booting options in grub2 config... so here we go:

Using your favorite editor, open and edit /etc/default/grub file, and modify it following the following info.
I suggest to do not delete or overwrite original lines, but instead, comment them, so it is easy to return to original config if needed.
Here is what the mine looks like (I have removed 'irqpoll' option, take a look at my blog article about it if you find IRQ problems):

#GRUB_CMDLINE_LINUX_DEFAULT="quiet"
#This line disables quiet output to have a more verbose console.
#In alix computers, if you experience IRQ troubles, add the irqpoll option if needed
GRUB_CMDLINE_LINUX_DEFAULT=""

#GRUB_CMDLINE_LINUX=""
#Alternate setup for serial console whith CISCOish classical 9600 8N1 setting
GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0,9600n8"


#Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# Uncomment to enable serial console boot
GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1"

 
That's it... now, attach your RS-232 cable to the COM port, and use your favorite client: putty, screen, minicom to connect to it, reboot, and voila! you'll got grub2 menu right on your serial console!!!!

comments powered by Disqus