The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
Serial Consoles can be very useful 20 September 2002
Need more help on this topic? Click here
This article has 15 comments
Show me similar articles

This article isn't fully complete yet. I wanted to have two serial cables going from one box to the other. But what's here and in Adding a new drive via the serial console using dump/restore should be enough to get you going.

Serial consoles have their uses. Unfortunately, this seems to be a hard learned lesson. Especially when you have locked yourself out of the box during a firewall rule change, or a /etc/hosts.allow modification, or even when you accidentally or inadvertently kill sshd.

During a recent -STABLE upgrade of two remote boxes, I managed to lock myself out of the box (see my post to the mailing list. Luckily, the solution was rather simple, and I recovered both boxes. The elapsed time between problem discovery and problem resolution was about four days (I found the problem on a Sunday, and fixed it on Thursday morning). If a serial console had been available, the problem would have been fixed within 30 minutes. The fact that I was in Ottawa and the machines were in New Zealand didn't help the situation. Luckily, the staff at CityLink have been very helpful and kind to me over the years...

The handbook

Have you heard about the FreeBSD Handbook? If not, where have you been? I count over 200 references to the handbook from within my website. If you've never read this document, you need to. In fact, as I type this, I'm about to start reading the section on serial communications which deals with Setting Up the Serial Console. You will need to read that document first. If you don't, you won't find my article any use at all.

I think you should I will not be going into detail about what I did to get the serial console running. I will only be providing points which I had to deal with for my situation. Your needs will vary and that necessitates that you read that document.

My particular situation

In my situation, I have two computers, over which I have exclusive access, and which are the same location. They have two serial cables between them. Each has com1 [also known as sio0] configured to be a serial console and is listening on com2 to the other computer. That is, each computer has a null modem cable from going from its own COM1 to the other computer's COM2. My objective is the ability to access the broken box from the other box. The assumption is that at one box will be running fine whenever the other box breaks.

What it looks like during the boot

The following is what the reboot looked like after my first attempt. I was using -D in /boot.config:

cvsup reboot:Waiting (max 60 seconds) for system process vnlru' to stop...stopped
Waiting (max 60 seconds) for system process bufdaemon' to stop...stopped
Waiting (max 60 seconds) for system process syncer' to stop...stopped

syncing disks... 3 2 2
done
Uptime: 16m38s
Rebooting...
Copyright (c) 1992-2002 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD 4.6-STABLE #0: Sat Aug 10 04:35:41 NZST 2002
    dan@cvsup.example.org:/usr/home/ncvs/usr-obj/usr/src/sys/ZEKE
That wasn't good enough. I also wanted the boot sequence. So I changed the options to -Dh. Then I saw this:
cvsup reboot:
Waiting (max 60 seconds) for system process vnlru' to stop...stopped
Waiting (max 60 seconds) for system process bufdaemon' to stop...stopped
Waiting (max 60 seconds) for system process syncer' to stop...stopped
syncing disks...
done
Uptime: 26m44s
Rebooting...
Console: serial port
BIOS drive A: is disk0
BIOS drive C: is disk1
BIOS drive D: is disk2
BIOS 639kB/64512kB available memory

FreeBSD/i386 bootstrap loader, Revision 0.8
(dan@cvsup.example.org, Fri Aug 2 20:21:34 NZST 2002)
Loading /boot/defaults/loader.conf
/kernel text=0x2e3775 data=0x3b4a0+0x345f4 syms=[0x4+0x3e450+0x4+0x44e15]
-
Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [kernel]...
Copyright (c) 1992-2002 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD 4.6-STABLE #0: Sat Aug 10 04:35:41 NZST 2002
    dan@cvsup.example.org:/usr/home/ncvs/usr-obj/usr/src/sys/ZEKE
Connecting to the serial console

On the other box (i.e. the one which is working and does not have the problem), enter this command:

# tip com1 connected FreeBSD/i386 (cvsup.example.org) (ttyd0) login:

To disconnect the serial session, type ~. (that's a tilde followed by a period). WARNING: you should be aware of the possible consequences of not logging out before you disconnect. If the first machine is compromised, it is trivial to connect via the serial link. If you have not logged out, then the second machine will be compromised as well.

This article brought to you by the letter A...

Coincidentally, my copy of Absolute BSD: The Ultimate Guide to FreeBSD by Michael W. Lucas arrived today. Just in time for me to use Chapter 20 which contains a section on the serial console.


Need more help on this topic? Click here
This article has 15 comments
Show me similar articles