Thu, 19 Jun 2008
Serial Console (with Xen)
Because I found it a tad non-obvious here a little tutorial. First we enable serial access to grub. For this add the following to your /boot/grub/menu.lst (tested with Grub legacy):
serial --unit=0 --speed=19200 terminal --timeout=5 serial console
I chose such a low baud rate because it worked and I didn't want to spend more time on it and because the highest baud rate (115200) had some timing problems with that specific configuration.
Then we need to adjust Xen to send the hypervisor output to the serial console as well (again in /boot/grub/menu.lst, this probably applies this way to Debian only):
## Xen hypervisor options to use with the default Xen boot option # xenhopt=com1=19200,8n1 console=com1,vga sync_console
Debian's update-grub uses the comments in the file to generate appropriate menu entries, even if the kernel and hypervisor versions change. Thus editing a comment works, but you must remember to call update-grub after your changes, otherwise they won't be active!
The last thing to change is the kernel's console. You might specify multiple consoles on the kernel's command line but only the last one will be the primary where the boot messages from init and the boot scripts are sent to. Kernel messages will end up on both, however. The edited comment looks like this (without Xen you would change kopt instead):
## Xen Linux kernel options to use with the default Xen boot option # xenkopt=console=tty0 console=ttyS0,19200n8
The key change which enabled me to use the serial console was passing sync_console to Xen. Sadly it complains now on boot that this option should not be used on production systems because it ensures that all messages reach the serial console and wait if necessary. But in my humble opinion it should only hurt on output and there should not be that much kernel and hypervisor output anyway, except if there is something wrong with the machine. Serial output from Linux only was also messed up when Xen hadn't this option activated.
To access the serial console just invoke GNU screen as a user in group dialout or as root like this to get the serial console as screen's first window:
# screen /dev/ttyS0 19200
Now the only thing that's missing is an affordable remotely controllable power line to trigger power cycles...
Update: Liberie Cunha-Neto kindly pointed me to the Xen hypervisor command line, from which one could reboot the machine. It is invoked by pressing Ctrl-a three times on the serial console (it does not work on the real one I told). In screen you need Ctrl-a, a instead, as Ctrl-a is its command prefix. Then you can get help by pressing h and reboot the machine by pressing R.