This article is really a companion to the Setting Up FreeBSD article. Wait a minute, that one's all about setting up a headless FreeBSD system, so what's so special about this article? Glad you asked.
In the course of setting up a number of little HP eVectra PCs as FreeBSD sandboxes, I quickly grew tired of having to scrabble around to connect a monitor and keyboard to each unit so I could see what I was doing. Once FreeBSD is installed on the machine, it gets put away in a closet and I just SSH into the machine anyways.
Oh, the other little bit if information that makes things interesting is that the eVectra has no floppy drive. If it did, I could easily set up a special boot diskette that lets me use the serial console, as per the instructions in the FreeBSD Handbook.
There must be a better (or at least different) way to install FreeBSD on these small, yet useful machines.
Before doing these headless installs, it's a good idea to make sure the BIOS is actually up to date, is using the CD as the first boot device, has set the system clock to UTC time, and set the BIOS defaults to non-PNP OS and to the most conservative (if possible) optimizations. This requires a keyboard and monitor, so the entire point of the article may seem moot, but trust me, eventually you'll want to do a headless install!
It turns out there are at least two ways to do a true headless install of FreeBSD 4.10 on a machine like the eVectra. The first uses a standard 4.10 Install CD and requires only a keyboard to be plugged into the box. The second technique involves modifying the boot floppy image on the 4.10 Install CD and then making a new ISO image of the CD. Not for the faint of heart, but useful anyways.
Both methods end up using the serial console to control the intstall process. I'm assuming you have another PC that has a terminal emulator that will act as your serial console. For Windows users, that means using (blech) Hyperterminal or the much better (but not free) CRT from Van Dyke Software. Both of these terminal emulators support VT100 mode, which gives the best results when running sysinstall.
You'll also need a null modem serial cable. Look in your desk drawer for a 9-pin serial cable with holes (not pins) in the connectors on each end. If it's not in your desk drawer, then it's in the junk box under your desk. If it's not there, you'll need to go to your local computer parts guru.
Set the terminal emulator to 115K baud, 8 data, no parity, 1 stop, and no flow control on whatever com port you have the serial cable plugged into. If possible, configure the emulator to look like a VT100 terminal. If you have a loopback connector ( or a paperclip between pins 2 and 3 ) you should be able to type on the terminal emulator and see the characters on the screen. It's always a good idea to test the setup!
I'll go through both headless install methods and you can pick the one you like best.
For the simple headless install, you'll need the FreeBSD 4.10 install CD and a keyboard. Plug the keyboard into the back of the target PC and connect the serial cable between the target and the machine running hte trminal emulator.
Note that some articles on booting FreeBSD using a serial console say that the terminal emulator should be set to 9600,n,8,1 but I've found that the 4.10 Release likes the emulator set to 115000,n,8,1.
Insert the FreeBSD 4.10 Install CD and power up the system. You'll see some CD drive activity, and eventually you'll hear either two quick beeps or one longer beep. The one long beep is really the two quick beeps very close toghether. That's your cue to hit the [SPACE] bar on they keyboard attached to the target PC.
If you've already done an install of FreeBSD, you'll recall that the initial boot sequence loads up a minimal loader on your machine then tried to autoboot, which leaves you 10 seconds to figure out if you really want to boot the machine or change some boot settings.
Reading the Handbook closely, you'll find out that this simple incantation:
boot -h
Remember to hit [RETURN] after typing in boot -h. This will cause the system to boot normally, except that the console has been toggled from the internal display and keyboard to the serial port. And that's exactly what we want.
Now, you should see characters coming in on the PC running the terminal emulation, and the installation should proceed normally. After the kernel configuration step, you will get prompted for the terminal type that sysinstall should use for intaraction with you. Pick VT100 if your terminal emulator supports it.
OK, you're in! From this point on, you can follow whatever installation instructions you like.
For the less simple headless install, you'll need the FreeBSD 4.10 install CD. We're going to poke around in one of the files on the CD, make a new ISO image, and then install from that.
If you're using FreeBSD to burn CDs, I'm going to assume that you know how to rip the files from a CD into a directory and how to burn an ISO image.
Regardless of whether you are using Windows or FreeBSD, we're going to use the excelent makeisofs program to make the new ISO image. The recipie is the same regardless of which OS you use.
Windows users will want to go to Bart's Bootable CD site and download the BCD Utility Install. You'll need to get the full BCD package and the Nero ASPI library. Follow the installation instructions on the BCD install page.
We're not actually going to use BCD because it does some goofy stuff to the boot image. I'll provide a command line that calls mkisofs directly.
If you extract the BCD Utility to a folder somewhere in your directory tree and then create a place to copy the files from the FreeBSD 4.10 Install CD, you'll get an arrangement that looks something like this:
../bcd/ ../bcd/bin ../bcd/cds ../bcd/cds/freebsd410/files
Copy all of the files from the FreeBSD 4.10 Install CD to the files directory, then copy the following command line and paste it into either a batch file or a schell script. Call it something clever, like FreeBSD410Serial.bat. Note that the command has to be all on one line....
.\bin\mkisofs -v -d -D -N -R -J -T -V "FreeBSD 4.10 Serial" -o freebsd410-serial.iso -b floppies/boot.flp -c floppies/boot.catalog cds/410_mini_serial/files
Wait, don't run that command just yet! We'll need to edit one more file to tell the boot loader to use the serial console.
In the previous section, we waited until we heard the beeps indicating the autoboot had started, then pressed the [SPACE] bar to halt autoboot and entered boot -h to toggle over to the serial console.
We're going to edit the boot image in floppies/boot.flp first. You'll need an editor that can open files in binary mode - for Windows I use UltraEdit - bar none the best Windows programmer's editor on the market. In a pinch, you can get a decent freeware editor called HHD Hex Editor.
Whatever editor you end up using, open the file floppes/boot.flp. Make your way to offset 9456(hex) or look for the string "autoboot 10". You'll see something like this in the editor display:
9450: 37 5c 30 30 37 0a 61 75 74 6f 62 6f 6f 74 20 31 : 7\007.autoboot 1 9460: 30 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ...............
You want to change the text to look like this:
9450: 37 5c 30 30 37 0a 62 6f 6f 74 20 2D 68 20 20 20 : 7\007.boot -h 9460: 20 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ...............
In other words, change "autoboot 10" to "boot -h". Make sure you don't clobber the end of line character 0a!
Save the file and close the editor and fire up your command line window. Navigate to the base directory of where you installed the BCD Utility, and then run:
C:\tmp\bbie>FreeBSD410Serial
This make take a while, but when you're done, you should have a new ISO image in your current directory ready for your favorite CD burning utility.
Booting this install CD is even easier than the other one. It should automatically boot ad use the serial console right after the beeps.
OK, you're in! From this point on, you can follow whatever installation instructions you like.
Now you know at least two different ways to do a real headless intstall of FreeBSD. You may not think it's important now, but one day, the ability to administer a machine through the serial port will save the day!
If you've found this note remotely interesting, or if you find any errors or questionable practices, then drop me an email at the link on the bottom of the page.