Building an OpenBSD Live CD
by Kevin Lo07/14/2005
I recently taught an OpenBSD system administration course for schoolteachers who were interested in maintaining, configuring, and tuning an OpenBSD system in a networked environment. I decided to use a Live CD to teach that course, so that the students wouldn't need to install anything. They didn't even need a hard disk to run OpenBSD out of the box on their PCs! The Live CD I made focused on security, network management tools, the Firefox web browser, and so on.
This article describes the process I used to create a Live CD based on OpenBSD/i386 3.7-current. It should be no problem with 3.7-release either.
Getting Started
Before you start, you need the following:
- an i386 machine with OpenBSD installed
- a CD burner
- a CD-RW disc
- a boatload of patience
Construct the System
The first step is to fetch the -current source code. See 5.3.3--Fetching the appropriate source code in the OpenBSD FAQ.
Next, create a /livecd directory in which to keep the CD's contents. Make three backup directories in /livecd:
$ mkdir -p /livecd/backups/{var,etc,dev}
Then, tar up the whole system you want on the final system, and untar it into the /livecd directory (or copy it, directories and all, as you prefer). Copy your /var and /etc directories to /livecd/backups/{var,etc}:
# cp -pR /var /livecd/backups/var
# cp -pR /etc /livecd/backups/etc
# cp -pR /dev/MAKEDEV /livecd/backups/dev
This gives the Live CD its skeleton of files and directories. The next
step is to configure the bootable kernel. In the
/usr/src/sys/arch/i386/conf directory, move RAMDISK_CD to
RAMDISK_CD.OLD, and copy the kernel config file GENERIC to
RAMDISK_CD. Then edit the file. Comment out the line containing
config bsd swap generic and add the following lines:
option RAMDISK_HOOKS
option MINIROOTSIZE=3800
config bsd root on cd0a
You can also download an example RAMDISK_CD config file. This sets up a ramdisk and allows the root of the system to be on the CD.
With this in place, you'll receive an error message when adding DDB support and friends. To fix it, apply this Makefile.in diff to /usr/src/distrib/i386/common/Makefile.inc:
--- src/distrib/i386/common/Makefile.inc.orig Thu Mar 3 09:16:02 2005
+++ src/distrib/i386/common/Makefile.inc Thu Mar 3 09:16:32 2005
@@ -33,8 +33,7 @@
newfs -m 0 -o space -i 524288 -c 80 ${VND_RDEV}
mount ${VND_DEV} ${MOUNT_POINT}
cp ${BOOT} ${.OBJDIR}/boot
- strip ${.OBJDIR}/boot
- strip -R .comment ${.OBJDIR}/boot
+ strip -s -R .comment -K cngetc ${.OBJDIR}/boot
dd if=${.OBJDIR}/boot of=${MOUNT_POINT}/boot bs=512
dd if=bsd.gz of=${MOUNT_POINT}/bsd bs=512
/usr/mdec/installboot -v ${MOUNT_POINT}/boot \
@@ -54,8 +53,7 @@
bsd.gz: bsd.rd
cp bsd.rd bsd.strip
- strip bsd.strip
- strip -R .comment bsd.strip
+ strip -s -R .comment -K cngetc bsd.strip
gzip -c9 bsd.strip > bsd.gz
bsd.rd: ${IMAGE} bsd rdsetroot
Apply it with:
# cd /usr
# patch -p0 < patch-Makefile.in
Next, install the crunch package, which helps create crunched
binaries for use on boot, install, and fixit floppies. This allows you to fit
more on the CD:
# cd /usr/src/distrib/crunch && make && make install
Finally, build the CD by doing a make in the
/usr/src/distrib/i386/ramdisk_cd directory:
# cd /usr/src/distrib/i386/ramdisk_cd && make
In the /usr/src/distrib/i386/ramdisk_cd directory, copy the two files bsd and cdrom36.fs to the /livecd directory.
Modify /livecd/etc/{fstab,rc} and /livecd/backups/etc/{fstab,rc} to make booting work right.
Next, edit the CD version of /livecd/etc/rc and
/livecd/etc/fstab to mount the appropriate
filesystems, and include cd. Finally, edit the backup version of
/livecd/backups/etc/rc and /livecd/backups/etc/fstab to include the CD and
memory filesystems.
There are three directories (/var, /tmp, and
/etc) that need to be writable, so the CD mounts them as memory
filesystems (using mfs).
Pages: 1, 2 |