Dual Serial Consoles with one serial port

So you have two servers in some “remote” configuration, and they each have a serial serial port, and you’d like to put a single null modem cable between them so that you can manage them.

But, there is only one cable and one port, and so how can you manage them in both directions? In the olden days of UUCP, this was a common problem as one wanted both dial in and dialout on the same modem. The answer was originally dial-in/dial-out ttySx and cuaX ports which the kernel interlocked for one, but once we got control of source code, then it was easier to just have a lock file. cua ports were obsoleted in Linux 2.2 anyway: https://www.tldp.org/HOWTO/Serial-HOWTO-10.html

So install mgetty (“apt-get install mgetty”), and fix your /etc/inittab to say something like:

T0:23:respawn:/sbin/mgetty -r -s 115200 ttyS0

On both machines, assuming you have /etc/inittab.

(If you have systemd, then I’m sorry for you. The https://help.ubuntu.com/community/SerialConsoleHowto has instructions for you.)

Before you restart init, install your favorite terminal program. I use minicom for lack of imagination. You probably don’t want to use rtty or screen for this, because a) I’m not sure it does the right locking, and b) as long as it’s running you can’t login to the system running as console server.

So start minicom:

sudo minicom -s

Pick “Serial Port setup”, and fix the serial port to /dev/ttyS0, and turn off the hardware flow control. Set the baud rate to 115200 if it isn’t set to that already.

Then “Save setup as…” and type “ttyS0”. You’ll want to make sure that your mortal account is in the “dialout” group with vipw -g, and then login again on each system.

Start “minicom ttyS0” on each system and confirm that you can type in each window and see it in the other. Exit minicom on each system.

Restart init with “sudo kill -1 1” (be careful, “sudo kill 1” will probably toast your system back to single user mode). You should see “mgetty” running in the process listing.

Start “minicom ttyS0” and hit return. You should see a login prompt. Try to login: probably as root, as that’s the whole point of this rescue. If it doesn’t work, you might check /etc/securetty.

Now, it would be nice to set up the BIOS redirection and the kernel boot messages to go to the serial port. But, that will cause a lot of noise, as the CRs in the output will tweak the other system to think it’s trying to login. Probably, it won’t manage to login with a valid password, so it’s probably gonna be okay, but I’d test it first.