As we mentioned in the Remote Power Console article, we have a lab of 16 servers that we are using to test various configurations we will use in articles for NetAdminTools.com. We needed a way to access the consoles of the servers via a serial port, but we didn’t want to plunk down $500 or so for a multiport card.
A bit of a tangent here. In addition to being able to reconfigure the network without losing your connection and the ability to respond to fsck and other tasks/monitoring that take place before you get past run level 1, we like having a remote serial console so that tcpdump doesn’t include the traffic from the network session. That is, we can just run a tcpdump without any options and see a clean view of all traffic going in and out of the box without seeing telnet or ssh traffic. We do know there are ways around this, but it is nice.
Our solution uses a BASIC Stamp microcontroller, a 74150, a 74ls154, and a handful of 2n2222 transistors. What we *really* should have used if we wanted to be proper were some LT1181ACN chips to convert TTL logic signals to genuine RS-232 signals. Further, there are a lot of nasty implications to driving a serial cable with TTL outputs directly. Noise, inductance, and voltage ssrv-4s can damage the TTL chips. Also, the voltage levels may not work with all serial ports, since the RS-232 spec uses +/- 12 volts, but our circuit uses 0/5 volts. This circuit was good enough for our purposes, though. Your mileage may vary. This is appropriate for a lab environment; however, be careful about using this in production. You may be safer buying a commercial solution. We don’t call this section “Roll your own” for nothin’. 🙂 One good commercial product is the TS1000/2000 by Cyclades.
Since we are only using 6 i/o pins on the BASIC Stamp, we intend to keep this breadboarded for awhile until we use the other pins. There are only three serial ports actually hooked up in this picture, but all the parts are there.
I drew this using xfig.
Here is the program that is loaded into the BASIC Stamp. I use P14 on the BASIC Stamp to transmit data to the remote power console, so I can use a consolidated application.
Just like with the Power Console, I wrote up a little TCL/TK app using Visual TCL to control it.
I used /dev/modem as the comm port. Jameco has all of the parts I used in this project.
OK. Now, there are some technical issues regarding Linux/serial ports that I’ll discuss. Do check out our Hardware section for some good links on serial ports. Of course, sharing a serial port on anything besides *NIX is of little value. With *NIX though, and specifically Linux, it is possible to even install the OS via the serial port. We’ll use Red Hat 7.1 as an example, and we will keep the install as generic as possible. First, create a boot.img diskette from the 7.1 distribution CD. If you have mtools installed, you can then:
mcopy a:SYSLINUX.CFG ./
edit SYSLINUX.CFG so that the default is install, then add an entry:
label install
kernel vmlinuz
append initrd=initrd.img local console=ttyS0 (assuming serial port is ttyS0)
Then, copy the new version of SYSLINUX.CFG back to your diskette:
mcopy SYSLINUX.CFG a:
You can now install Red Hat via the serial port. See Mini HowTo: Successful Serial Installation of Redhat 6.2 / i86 for more info.
If you want to switch the console output so it goes to the serial port, then you need to make some changes to lilo.conf and the device files. This is right out of the kernel docs with the 2.4 kernel, which is what we are using. Be very careful here, so you don’t screw up your console device!! Here is the serial-console document for your pleasure. As long as you install ssh (default on most Red Hat installs), you can simply ssh in after the reboot to tweak the remote machine further, until you get the console working correctly on the serial port.
To summarize, here is what we have to do:
Make the correct device files:
cd /dev
rm -f console tty0
mknod -m 622 console c 5 1
mknod -m 622 tty0 c 4 0
We also need to edit lilo.conf, and stick:
serial = 0,9600n8
in the global section.
We also need to put:
append = "console=ttyS0,9600"
in the kernel section. Run /sbin/lilo when you are done. Make sure you have a backup kernel section to boot from if things get messed up.
We need to edit inittab, and add a line:
S0:2345:respawn:/sbin/getty ttyS0 DT9600 vt100
We’ve had better luck with getty, rather than agetty. We will need getty to actually exist:
scp getty_ps-2.0.7j-12.i386.rpm root@10.50.100.52:/usr/local/
and on the target machine:
rpm -i getty*.rpm
Finally, you need to add the serial port to /etc/securetty, and delete /etc/ioctl.save.
Whew!!
Sure, we could have used a terminal program, but isn’t it so pleasurable to see the Wyse? [2/2002 update: Sigh… our Wyse terminal bit it, so we are now using minicom. One thing to remember is that you have to switch pins 2 and 3 if you go from a real terminal to a PC, or use a null modem adapter.]
As we mentioned earlier, this project probably isn’t appropriate for a production environment; however, if you are like us and need a cheap way to bring up a lab, this is a good way to do it. By all means, *don’t blame sendmail*!!!!
Serial Mux revisited. Since all control for this is done with four lines from the Basic Stamp. We simply built a keypad from a 74C923, put 2.2 k pulldown resistors on the outputs, ran the lines through a 74126 buffer, and then into the circuit in the same place as the Basic Stamp. We then just mounted the keypad on top of the Wyse terminal, and it works just swell.
For some insane Z-80 hacking and an opto-isolated parallel port interface, check out , my Z-80 homebrew computer construction site. To put my homebrew to good use, I actually did port both this and the remote power control project to my homebrew computer. Details here.