2016-05-24 - grub over a serial console

GRUB logo in my setup i have a small server in a closet. its a convenient place to keep it, but it is incredibly inconvenient to access… 99.999% of the time SSH is just perfect here. however sometimes you need to have a console access to fix stuff (“unfortunate” iptables entry, booting with custom args, etc… you get the point). due to lack of space, there is no way to put any screen there. serial cable is perfect solution – its small and just enough for doing occasional recovery actions.

there are many tutorials on how to bring grub to serial console. on debian all the fan boils down to editing /etc/default/grub. you need to add something like:

GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"

now what if you need to have a console on both serial cable and the “regular” console? this is the case when server is moved out of the closet and gets LCD monitor connected. trivial:

GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"

…but with a caveat. since that very moment i was no longer able to auto-boot. each time after a reset, console hung and waited for user input. connecting to serial cable was just enough to make automatically it boot again! it turned out that in such cases it's best to enable “hidden” mode. it basically sends “press any key to continue” type of message on both serial port and console, until either one is enabled, or timeout occurs. the magic key to enable full-blown menu is ESC. if nothing happens in a specified timeout, grub auto-boots default entry.

in addition i've also added kernel output to a console and enabled the serial console in systemd, so that machine can be fully operated via serial port, if needed. whole setup looks like this:


GRUB_CMDLINE_LINUX_DEFAULT="quiet cgroup_enable=memory swapaccount=1"
GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0,115200n8"

GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"

perfectly what i've needed, though it took me a while to dig it out (+an extra 2 resets for each trial :P).

btw: for systemd to enable serial port automatically just type:

systemctl status serial-getty@ttyS0.service
blog/2016/05/24/grub_over_a_serial_console.txt · Last modified: 2021/06/15 20:09 (external edit)
Back to top
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0