Subject: Re: Creating bootable USB disks
To: None <>
From: David Young <>
List: current-users
Date: 04/30/2007 16:54:47
On Mon, Apr 30, 2007 at 10:16:52AM +0100, Alan Barrett wrote:
> On Sun, 29 Apr 2007, Blair Sadewitz wrote:
> > I think it would be convenient for a lot of people if there were
> > images available for booting from USB keys.  [...] mount the ISO image
> > as a vnd [...] grub [...] FAT partition [...]
> You don't need grub; the NetBSD/i386 /usr/mdec/mbr_bootsel works just
> fine on a USB flash drive.  You can also partition the drive with an FFS
> partition, so you don't need a FAT partition.  You don't even need to
> mount the ISO image as a vnd, but it might be convenient to do so.
> I have a strong preference for doing it using tools that are in the base
> system (and that are already part of the cross-build tools, or that can
> easily be added to the tools).  So no grub.  Apart from that, there are
> many ways to do it, and I think it would be useful if you put something
> together.

I have put a lot of this together already.  The build system for CUWiN
uses NetBSD's cross-build tools to build a bootable i386 image with
FFS root.  You can also build a bootable CD-ROM with an ISO9660 root,
and other targets.  To try it out, check out the CUWiN sources,

$ cd $HOME
$ svn co

Check out NetBSD sources:

$ cvs -d co -P src

Create a directory for the build products, and create a .mkstabootrc
that tells the location of both your NetBSD sources and your build
products directory:

$ mkdir build
$ cat > .mkstabootrc<<EOF
> SRC=$HOME/src 

Build a boot image for, say, a Soekris net45xx with 128MB Sandisk
CompactFlash card---I suggest that target because it is closest to a
USB key:

$ cd trunk/src/boot-image
$ ./buildelan128 2>&1 | tee $HOME/build.log

This will create a elan128-30-Apr-2007.img file that you can dd to a
CF card.

For a USB key, you should override both the kernel configuration and the
disk geometry.  The script trunk/src/boot-image/regcfcard will extract
the geometry from your USB key by zeroing the disklabel (!!!) and running
disklabel -r on it.  Name the geometry you have extracted, and put it
into boot-image/disktab.d/native.  Build the USB key like so:

$ ./buildelan128 -k [[path to your kernel configuration]] \
> -t disktab.d/native -T [[name of your geometry]] -u 2>&1 | \
> tee $HOME/build.log.2

(buildelan128 passes -u to so that it skips the 'make clean'

Note well: that script is going to build the CUWiN daemons & utilities,
install some of our scripts and configuration files, install some default
users (with crummy passwords!), and patch a few files from the NetBSD
distribution.  What you get is a wireless router.  You can override a
lot of those operations with changes to command-line options, in order
to build a more "pure" NetBSD system.

Someday, I would like to add a lot of the functions of this script


David Young             OJC Technologies      Urbana, IL * (217) 278-3933