Pimp My OpenBSD bootfloppy

General Information

This short how-to gives you some basic hints on how to customize the OpenBSD bootfloppy, and how to setup an easy accessible shellscript.


  • An OpenBSD installation on your local machine.


Okay, I toyed a bit with the OpenBSD installation process. Luckily it is an open-source OS, and the installation process fits on a single 1.44-floppy, which is kinda cool. Anyhow, the default setup is one with a ramdisk, and the filesystem is somehow linked to the kernel. That makes it a bit hard to customize it, don’t you think?

So, I want to show you a way to make changes to the bootfloppy a tiny bit easier… Not very far though… Just enough to show you how to run an easier to access shell-script after every boot.

Note: Btw: You’ll have to do everything as root… Sorry!!

Installation of your basic tools.

You need OpenBSD running on a local machine for this. The default installation comes without the stuff under /usr/src, so just grab it and unpack it:

mkdir /usr/src
cd /usr/src
ftp -o- ftp://ftp.openbsd.org/pub/OpenBSD/3.7/src.tar.gz | tar xvfz -

After that, you can install crunch:

cd /usr/src/distrib/crunch
make install

Let your computer find a shellscript

Remember your last installation of OpenBSD? The computer asked you if you wanted to (I)nstall, (U)pgrade or (S)hell. The file which does that is located under /usr/src/distrib/miniroot and called dot.profile It is the first file to be started after your computer booted. Therefore, as a quick-and-dirty hack, it is not a bad idea to edit it. My idea was to let it mount the bootdevice, copy a file from there, umount the bootdevice, and run it. Of course, I had no clue on how to find the correct boot-device. So I made my hack a bit dirtier…Just find the lines

# set up some sane defaults
echo 'erase ^?, werase ^W, kill ^U, intr ^C, status ^T'
stty newcrt werase ^W intr ^C kill ^U erase ^? status ^T

in it, and add

mkdir /mnt2
mount /dev/fd0c /mnt2 ; cp /mnt2/autoexec.ksh / ; umount /mnt2
mount /dev/fd1c /mnt2 ; cp /mnt2/autoexec.ksh / ; umount /mnt2
mount /dev/wd0c /mnt2 ; cp /mnt2/autoexec.ksh / ; umount /mnt2
mount /dev/wd1c /mnt2 ; cp /mnt2/autoexec.ksh / ; umount /mnt2
mount /dev/cd0c /mnt2 ; cp /mnt2/autoexec.ksh / ; umount /mnt2
mount /dev/cd1c /mnt2 ; cp /mnt2/autoexec.ksh / ; umount /mnt2
ksh /autoexec.ksh

beneath them.

Make your own bootfloppy

Save your /usr/src/distrib/miniroot/dot.profile. And now type in:

cd /usr/src/distrib/i386/ramdiskA
mv floppyXX.fs floppyXX_autoexec.ksh.fs     # (XX=37, 38, 39...)

As long as you don’t have any virtual filesystems mounted on svnd0, this will hopfully give you a file called floppyXX_autoexec.ksh.fs, where XX is the release-number. In my case it was 37.

Setting up your shellscript

Now you have told your computer where to find a shellscript called autoexec.ksh. All you have to do now is to write it. First of all, mount your new floppy-image

vnconfig svnd0c floppyXX_autoexec.ksh.fs
mount /dev/svnd0c /mnt
cd /mnt

and then edit a file called autoexec.ksh with your favourite editor, for example echo:

echo "ifconfig ne3 netmask up" > autoexec.ksh
echo "route -n flush" >> autoexec.ksh
echo "route add default" >> autoexec.ksh

then umount your floppy-image

umount /mnt
vnconfig -u svnd0c

aaaaand done. The floppy you have now is great to test whether a computer without a monitor or serial console boots or not. (Take a root-server, for example). Theoretically, this can be used to “depenguinate” a box, because you just pimped the installation-floppy, remember? 😉

Anyway… That is something I haven’t really tried yet, but I am working on it at the moment. And because we are talking about less than 2MB here, let us just hope that Theo keeps up his good work, and those bootfloppy will never become obsolete.

I have already written a how-to on how to use an OpenBSD bootfloppy to boot up your dedicated-/root-/hosted server. Get it at http://www.dettus.net/openbsd_at_strato.txt or at http://www.bsdguides.org/guides/openbsd/misc/openbsd_at_strato.php.

Speak Your Mind