This web page is a simple note on how to set up a serial console for the amd64 (and i386) version of OpenBSD. The complete procedure for all architectures is described in excellent fashion by the OpenBSD FAQ on configuring a serial console. The present page is merely a place-holder for the author's convenience and consists only of the most basic instructions for amd64.
It is assumed that the hardware does, in fact, include a serial port and that it is connected. If one does not exist, then these instructions will have no effect.
The following command, adapted from the OpenBSD install scripts, should identify any existing serial ports:
dmesg | sed -n 'H;/^OpenBSD/h;${g;p;}' | grep '^com[0-9] '
In OpenBSD, serial port comN is associated with /dev/tty0N for N = 0,1,2,3.
In the remaining discussion, it will be assumed that the first serial port: usually com0, will be set as the new console and that will operate at 115200 baud as opposed to the default 9600 baud. Make appropriate changes to any commands should the local requirements be different.
There are two parts to the configuration process:
The serial port must be configured in /etc/ttys as a terminal in order to establish a login session. Otherwise, the console will be an output-only device. This is grequently a forgotten part of the process, thereby resulting in the most confusion.
It is important to disable initialization of /dev/console in /etc/ttys. Failure to do this will result in an attempt by the system to open two connections on the same physical line at boot time.
sed -i'' '/^console/s/on /off /' /etc/ttys
Now configure the terminal using the following commands:
sed -i'' '/^tty00/s/off.*$/on secure/' /etc/ttys sed -i'' '/^tty00/s/unknown/vt220 /' /etc/ttys sed -i'' '/^tty00/s/9600/115200/' /etc/ttys
If the line speed is not being changed, omit the last command.
These could, of course, be merged into a single command but it's likely less confusing when kept separate.
The new console is set in /etc/boot.conf, as follows:
echo 'stty com0 115200\nset tty com0' > /etc/bootconf
Again: if the line speed is not being changed, omit the first part of the echo content so that the command becomes:
echo 'set tty com0' > /etc/bootconf
The new console is now set. Time to reboot.
Make sure to start the terminal session on the machine to which the other end of the serial line is connected.