View Full Version : Serial's Killer
sodface
12-31-2005, 01:16 AM
I've been messing around with accessing my home server (Linux) via the serial port from my main rig (WinXP).
The server does not have a monitor or keyboard connected, it's "headless". During normal operation it's quick and easy to access it over the network using a terminal program like Putty (http://www.chiark.greenend.org.uk/~sgtatham/putty/)
This method only works when the server is actually up on the network and the sshd daemon has been started - this is very late in the boot process. Connecting through the serial port with hyperterminal lets you see much more of the boot process and also provides a way to fix things if there are errors during the boot and not everything loads properly.
With a little tweaking of the installer .iso for your favorite distro, it's possible to do a complete OS load via a serial terminal.
1. Making the physical connection. (http://www.bleedinedge.com/forum/showpost.php?p=138848&postcount=2)
2. Configuring the software (OS already installed). (http://www.bleedinedge.com/forum/showpost.php?p=138849&postcount=3)
3. Configuring the software (Fresh install). (http://www.bleedinedge.com/forum/showpost.php?p=138850&postcount=4)
4. Extra: Connecting with an IPAQ (http://www.bleedinedge.com/forum/showpost.php?p=138853&postcount=5)
sodface
12-31-2005, 01:17 AM
Connecting two computers via the serial ports is similar to connecting two computers with a network cable, a straight through cable won't do, a crossover is required.
With RS-232 communication, this is called a null modem cable. See the pinout here. (http://www.zytrax.com/tech/layer_1/cables/tech_rs232.htm#null_db9)
I have all the stuff required to make cat5 cables (cable, crimpers, connectors) so the cheapest and most flexible way for me to make the null modem cable was to use two RJ-45 to DB-9 adapters, connected via a specially pinned cat5 cable.
The two adapters were spares that originally came with a Sun server and look like this:
http://www.bleedinedge.com/images/sod/db9_rj45.jpg
Taking a look at the pinout for the adapter itself:
http://www.bleedinedge.com/images/sod/adapter_pinout.jpg
I have no idea if this is a typical pinout for this type of adapter. Double check the one you have.
Since I had one adapter on each end of the cable I had to make sure the crossover was done in the interconnecting cable. After looking at the pinouts, I pinned one end of the cat5 cable in accordance with 568B standard for network cables:
http://www.bleedinedge.com/images/sod/cat5_color.gif (http://www.zytrax.com/tech/layer_1/cables/tech_lan.htm#color)
This is with pin 1 being on the left and the locking tab facing down. To complete the null modem connection then I just flipped the connector on the opposite end over so that the locking tab was facing up, and then used the same color code from left to right.
Before connecting, the file /etc/inittab needs to be edited - uncomment the entry for the comm port you will be using, in my case this was ttyS0
# Local serial lines:
s1:12345:respawn:/sbin/agetty -L ttyS0 9600 vt100
#s2:12345:respawn:/sbin/agetty -L ttyS1 9600 vt100
I hooked everything up, fired up hyperterminal with 9600,8,n,1,n settings, and then connected:
http://www.bleedinedge.com/images/sod/raid1_syncing_resize.jpg
sodface
12-31-2005, 01:18 AM
To get the most coverage of the boot process via the serial port, there are a couple of files that need to be edited.
The boot loader is the first piece of software that will give us a serial console, and unless you have a serial console option in the motherboard bios, it's the earliest spot we can tap into the boot process.
I use Grub as the boot loader. Edit /boot/grub/menu.lst to enable serial output for grub itself:
#setup serial terminal
serial --unit=0 --speed=9600
terminal serial
Which gives us the Grub boot menu on our next boot:
http://www.bleedinedge.com/images/sod/grub.jpg
There is an additional edit to make in /boot/grub/menu.lst or once we select the entry from the grub menu, we'll lose the serial output as grub passes control over to the linux kernel.
Pass console=tty0 and console=ttyS0,9600n8 to the kernel via the parameter list. This will give you a console on both a local monitor (tty0) and on the first serial port (ttyS0).
title Arch Linux Sodserv Raid1 LVM [/boot/vmlinuz]
kernel (hd0,0)/vmlinuz26 root=/dev/md2 console=tty0 console=ttyS0,9600n8
Which gives us the kernel messages:
http://www.bleedinedge.com/images/sod/kernel.jpg
So, the relevent entries from my /boot/grub/menu.lst file looks like this:
# general configuration:
timeout 5
default 0
color light-blue/black light-cyan/blue
serial --unit=0 --speed=9600
terminal serial
# boot sections follow
# each is implicitly numbered from 0 in the order of appearance below
#
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.
#
#-*
# (0) Arch Linux
title Arch Linux Sodserv Raid1 LVM [/boot/vmlinuz]
kernel (hd0,0)/vmlinuz26 root=/dev/md2 console=tty0 console=ttyS0,9600n8
initrd /initrd26.img
Also, don't forget to edit the file /etc/inittab - uncomment the entry for the comm port you will be using, in my case this was ttyS0, this gets you a getty listening on the serial port so that you can actually login.
# Local serial lines:
s1:12345:respawn:/sbin/agetty -L ttyS0 9600 vt100
#s2:12345:respawn:/sbin/agetty -L ttyS1 9600 vt100
sodface
12-31-2005, 01:19 AM
One method to do a fresh install via a serial console is to remaster the distro's installation cd.
I still use windows on my main rig, so this method is done from windows.
First, get the bcd utility. (http://www.nu2.nu/bcd/) Follow the installation instructions on that page.
You'll end up with a directory tree with the bcd files in the root, the utils that bcd relies on in the bin folder, and a cds folder where you'll build your cd's in.
http://www.bleedinedge.com/images/sod/bcd1.jpg
In the cds folder, you make a folder for each cd, then in that folder you make a files folder where you put all the files that cd will contain. There is also a bcd.cfg file above the files folder where you define important settings for each disk.
http://www.bleedinedge.com/images/sod/bcd2.jpg
Download the installation .iso image for the linux distro you're using.
Mount the .iso with daemon tools. (http://www.daemon-tools.cc/dtcc/download.php?mode=ViewCategory&catid=5)
Copy all the files from the mounted .iso over to the applicable files directory in your bcd directory tree.
Based on the install cd's I've looked at, you should have an isolinux directory and within that directory, one of the files should be isolinux.cfg.
http://www.bleedinedge.com/images/sod/bcd4.jpg
Edit isolinux.cfg, adding "serial 0 9600 0" and the "console=" entries to the kernel append line as seen below:
serial 0 9600 0
prompt 1
timeout 30
display boot.msg
default arch
label arch
kernel vmlinuz
append console=tty0 console=ttyS0,9600n8 initrd=initrd.img load_ramdisk=1 prompt_ramdisk=0 root=/dev/ram0 BOOTMEDIA=cd
This gives us an isolinux serial console and also a kernel serial console once control is passed to the kernel. You may want to look at the rest of the settings (http://syslinux.zytor.com/faq.php#config) in here also and change them if desired. For instance, sometimes the kernel is passed a "quiet" parameter or something similar that suppresses message output - I delete that so I've got something to watch while the boot is progressing.
Go up a directory and edit the bcd.cfg file. This file isn't there by default, just copy the bcd.cfg file from the main bcd directory and use that as a start. Most of the settings are self explanatory. Make sure you point to the boot file. isolinux.bin in the same directory as the isolinux.cfg file you edited.
# The bootfile that is used for building the CD.
# Normally not set in main bcd.cfg but in the cds\<cdname>\bcd.cfg file
# bootfile <file>
bootfile isolinux\isolinux.bin
Once your happy with that, open a command prompt, navigate to the bcd directory and execute the command bcd -b [cd name] where [cd name] is the name of the directory where the files folder and the bcd.cfg file is.
bcd will then build the new .iso:
http://www.bleedinedge.com/images/sod/bcd3.jpg
The -b option prevents bcd from burning with the built in cdrecord option. I never tried it for some reason, opting to burn the .iso with my regular burning software. Unfortunately, bcd stores the .iso in your temp directory and I never found a way to change that. You could change your temp directory environment variable so you don't have to go digging through your profile directory...
Anyway, burn the resulting .iso file and you should be good to go:
http://www.bleedinedge.com/images/sod/setup1_resize.jpg
... provided the stock kernel on the installation cd was compiled with the serial console option enabled, if it wasn't, you'll have to replace it with a kernel that was (which is a whole nother can of worms that I wasn't able to get working). If you can get the config file for the kernel you can check first or just burn and hope for the best.
sodface
12-31-2005, 01:31 AM
After doing a little research, I went to Radio Shack and dug through their basket of miscellaneous cables, looking for a cable with the 22 pin connector my Ipaq 3115 uses on it. I found a couple. I don't believe these were originally for the Ipaq - I think they were for cell phones, but the connector was the same, which is all I cared about.
One of the cables had the 22 pin connector on one end and an RJ-11 connector on the other. The cable itself only had 3 conductors in it. From using serial connections at work, I knew I really only needed a TX and RX pin to make things work.
Based on this pinout (http://pinouts.ru/data/ipaq_38+_pinout.shtml) of the Ipaq connector I determined which wire I needed where so that I could use it with the RJ-45 to DB-9 adapter I described in post 1. I cut off the RJ-11 connector and replaced it with an RJ-45 connector.
I connected the cable to the server and fired up vxHpc (http://www.cam.com/vxhpc.html) and ....
http://www.bleedinedge.com/images/sod/ipaq_serial.jpg
:rock:
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.