MC's journal

Setting Orange, the 43 day of The Aftermath in the YOLD 3179

FreeBSD serial console on another port

On many of my FreeBSD servers I use a serial console. It's pretty straightforward to set up as the Handbook illustrates.

Combined with a serial port server with SSH access (thanks XS4all!) or, say, HP's iLO which can also provides SSH access to the serial port it's a very nice way to be able to access your server even if you need to boot to single-user or if you locked yourself out. Even better, combine this with a firmware that knows something about console redirection and you also get at the BIOS setup over the same port.

I recently found myself in a situation where I couldn't use COM1 as the serial console port on a new server. The Handbook says:

If there is no COM1 (sio0), get one. At this time, there is no way to select a port other than COM1 for the boot blocks without recompiling the boot blocks.

[…]

25.6.4.2. Using a Serial Port Other Than sio0 for the Console

Using a port other than sio0 as the console requires the boot blocks, the boot loader, and the kernel to be recompiled as follows.

which sounds a bit scary. I'm not foreign to the notion of running a customized kernel. However, on a stock x86 server in co-lo which I hope to be able to update with freebsd-update(8), I don't really want to run a custom kernel. Thinking it through a little and looking at the uart(4) manual page I got an idea.

There is an alternative to compile your own kernel, and I admit it might fall under the tip "get one" above: Change your COM3 (or whatever) to COM1! Here's how I did it:

Normal /boot/device.hints lists the first serial port as:

hint.uart.0.at="isa"
hint.uart.0.port="0x3F8"
hint.uart.0.flags="0x10"
hint.uart.0.irq="4"

Note that sio(4) as mentioned in the Handbook is not listed in device.hints anymore.

The serial port I want to use as console is on the PCI bus, so I changed uart.0 to:

hint.uart.0.at="pci"
hint.uart.0.port="0xEC00"
hint.uart.0.flags="0x10"
hint.uart.0.irq="B"

and it just works! The details were taken from what the BIOS setup told me about what it called "COM3". The AMI BIOS of a Supermicro C7X58 motherboard can see at least a 16C550 compatible PCI serial cards just fine.

If you later want to enter the BIOS setup over the serial port, use ESC 4 when it tells you to press F4. Move around by pressing arrow keys and TAB after each arrow key.


Written by MC using Emacs and friends.