How To Boot From CD W/ No Human Interaction And Have A System Run Solely In RAM
by francisco roque last modified 08/29/2002
Table Of Contents
1. Introduction
2. Necessary Equipment
3. Instructions
3.1 Patching
3.2 Compiling
3.3 Creating CD
3.4 Booting
4. Possible Uses
5. Conclusion
6. References
7. Author, Copyright, License
1. Introduction
This document will walk you through the steps necessary to create a cd that
will install a very basic OpenBSD into memory filesystems. No human
intervention is necessary throughout the install. Once installed, the cd
is ejected and no physical drive is needed again.
This method has been developed so as to minimize the changes to the default
cd ramdisk and kernel; upgrading to new versions of OpenBSD should be
relatively easy.
2. Necessary Equipment
An x86 computer with at least 128 megs RAM, cd drive
An OpenBSD install on which you can compile an openbsd release and burn the
release sets to disk.
It is assumed that you know how to read man pages, compile kernels, patch
files, and other simple unix tasks.
3. Instructions
3.1 Patching
Get the latest -stable source. Throughout this document, i refer to
3.1-stable as of 8-20-2002.
We need to edit 2 files: the RAMDISK_CD kernel config file and the
dot.profile file. The kernel config file needs to have more
functionality for our purposes and dot.profile is run after the kernel
has loaded and the ramdisk has been mounted.
sys/arch/i386/conf/RAMDISK_CD needs to have MFS support added.
Additionally, we need more bpfilters for our net devices, pf and pflog
to be secure, a couple bridge devices for even more use, and some
pseudo-terminals so we can ssh into the final server. Go edit the file
or apply my patch:
RAMDISK_CD.patch
src/distrib/i386/floppies/common/dot.profile is run right after boot.
Editing this file is really the key to your bootable system. We need
ours to perform the following steps: mount mfs filesystems, remove old
binaries, install new binaries, remove cd.
Here is a walk-through of the script i wrote to do this.
#the OpenBSD version to be matched for our release sets.
VERSION="31"
#very important: mount the ramdisk read-write.
mount -rw /dev/rd0a /
#mount the cd to copy the install script from
mount -t cd9660 /dev/cd0c /mnt2/
cd /tmp
#the main install script is on the cd, that way we can edit it without
#having to recreate the ramdisk. We do the following steps:
# 1- check for a install script on the cd
# 2- try to get mount_mfs onto the ramdisk
# 3- mount mfs to copy script to
# 4- exec script
#if one part doesn't work, then we exec sh instead.
if [ ! -f /mnt2/install.local ]; then
echo No local file, execing sh
exec /bin/sh
fi
if [ -f /mnt2/mount_mfs ]; then
mkdir ./sbin/
cp /mnt2/mount_mfs ./sbin/
elif [ -f /mnt2/base$VERSION.tgz ]; then
tar zxvf /mnt2/base$VERSION.tgz ./sbin/mount_mfs
fi
if [ ! -f ./sbin/mount_mfs ]; then
echo mount_mfs not found, execing sh
exec /bin/sh
fi
/tmp/sbin/mount_mfs -s 5000 swap /mnt
sleep 1
cp /mnt2/install.local /mnt/install.local
exec sh /mnt/install.local
As you can see, the bulk of the work is done by the install.local script.
You can easily modify this script to do what you prefer.
You can either create your own dot.profile, or apply this patch:
dot.profile.patch
The install.local script i use is here:
install.local
3.2 Compiling
make build and make relase as you normally would to get the release sets.
refer to the release man page for more info.
3.3 Creating CD
Create a directory to hold our stuff:
mkdir /tmp/openbsd
Copy over our release sets to this directory:
cp $RELEASEDIR/base31.tgz $RELEASEDIR/etc31.tgz $RELEASEDIR/cdrom31.fs\
/tmp/openbsd
Create a release set of any other data you want in your system (you may
want to include special ssh host keys, rc.conf, rc.local, pf.conf, etc):
tar -zcpf /tmp/openbsd/site31.tgz ./etc/ ./var/
Create the iso image:
mkisofs -V"OpenBSD 3.1 MFS" -b cdrom31.fs -c boot.catalog -r -v \
-o /tmp/openbsd.iso /tmp/openbsd/
Burn it to cd:
cdrecord -v -eject speed=40 dev=/dev/cd0c:0,0,0 -data /tmp/openbsd.iso
3.4 Booting
Boot off the cd. Wait about 15 minutes. You will notice various error
messages from certain devices not existing. If there is access to a
dhcp server, you will have net access. Congrats.
3.5 Pre-Made ISO Images
Here are some pre-made iso images. I give no guarantees whatsoever
concerning these images. They may destroy your computer and/or help you
reach nirvana and/or just plain not work. Don't bug me, don't bug the
maillists, don't bug anyone if they don't work; instead, fix it.
Version A - standard install plus web server; requires 128mb RAM
4. Possible Uses
Somtimes people say "hrmm, that's interesting, but where would you ever
use such a sytem?". Here are some examples.
- You are addicted to OpenBSD. When you go to your friend's house you
would rather boot off this cd than use their OS
- Set up distant servers. Send your clients this cd to boot off of, then
you can ssh in and configure the disk, install the OS onto that system.
adding something like:
lynx -dump http://www.example.com/?hey%20boss%20im%20up > /dev/null
to /etc/rc.local will inform you of the ip of the server.
- Set up temporary servers in hostile locations. Create a cd that will
act as a gnutella or other p2p node, boot, remove cd, you've lost
nothing but time. This could be used to set up temporary proxies as
well, or temporary communications nodes, electronic meeting grounds,
etc. Due to the volatility of the server, standard "keep the
harddrive for later analysis" would not work.
- Along the same lines as the last example, hijack a computer to run
dsniff and email the output to an account every ten minutes. Again,
the volatility of the system works to your benefit.
- Secure laptops. Boot from cd at headquarters and leave that cd there.
No hard drive in the laptop. If the laptop is stolen, once it is
rebooted, all secret data is lost. You'll need great battery life,
which will be helped by the lack of drive.
- Install cd's. A cd like this could be used to install any other OS.
Boot from cd and edit script to download packages to intall OS. Since
cd isn't used after boot, this could save you from having to burn a
number of cd's when installing labs.
5. Conclusion
You can now make a cd release that will install itself into the computer's
memory. Image A that i provide contains some default packages in it. You
can customize it by adding commands to install.local or editing the contents
of site31.tgz, but keep in mind that you may need to increase the sizes of
the mfs's if you add too much.
6. References
7. Author, Copyright, License
The author of this document is francisco roque, who can be found at
http://www.blackant.net/
This document is copyright francisco roque 2002.
This document is released under BSD style license and may be used in whole or
part for anything so long as this section remains intact.
The author takes no responsibility for damages incurred by following the
steps in this document, including but not limited to the loss of data or
damage to hardware. Good Luck.