Wednesday, April 11, 2007

Creating and Using a Serial Console

Sometimes we end up with a lot of headless computers. I find that I have a lot of headless computers less due to lack of monitors--I'm thinking of that pile of CRTs in the closet--and more due to lack of keyboards. In either case, I have multiple machines in racks that don't have monitors and keyboards attached to them all the time. I usually just use SSH to interact with these systems but sometimes I want a little more, such as when the network is down.

This is where serial consoles come in. When Linux starts it spawns ttys, basically terminals, that you can access to do text-mode logins. It usually spawns 6 of them, but it varies from distribution to distribution. Most people are familiar with these terminals but many don't know that you can spawn them on all sorts of devices as well. All it takes is a little modification of your /etc/inittab file.

You may want to read your man pages a little to get a feel for what getty is doing, but the gist of it is that you add a like like the following to your inittab:

# Serial terminals.
s0:2345:respawn:/sbin/agetty -L -f /etc/issue 9600 ttyS0 vt100

This tells the system that when it goes into runlevels 2, 3, 4, or 5 it should launch agetty and relaunch it whenever it terminates. The arguments aftewards tell it to bind to the device ttyS0 at 9600 baud and output for a vt100 emulator. When a user connects they will see the contents of /etc/issue and also we told it that this is a hard line and so there is no need to do modem initialization.

You can read a more detailed explanation at http://www.vanemery.com/Linux/Serial/serial-console.html

No comments: