LiveCD Creation Documentation

MidnightBSD on USB Flash Drive

One of the most common requests to the MidnightBSD project is a method to create bootable flash media. I've come up with an ad hoc process to do just that.


You must be familiar with the LiveCD creation process, have a USB flash drive of at least 1GB, and patience.


Creating the image
 * Create a [[livecd|LiveCD]]. 
 * Look at the script: [[ |]]  T
his script does not work as is, but it is a rough outline of what needs to be done.
 * dd if=/dev/zero of=theimgfilename.img count=${SECTS}  where SECTS is enough to fit the OS on.  This number can be tricky to c
ome up with.  The method in the script is not large enough.  See [[
-size-linux-dd.html|Creating a file with a given size with dd]]. For example, dd if=/dev/zero of=imagefile bs=1048576 count=900
will give you a 900MB file. 
 * Make a temp directory such as /usr/flash and create two subdirectories img and iso.  This will be tmpdir
 * mdconfig -a -t vnode -f ${isoimage}  (path to iso image obviously)   note the device name   isodev
 * mdconfig -a -t vnode -f ${imgoutfile}  (path to file you dd'd above) note the device name as imgdev
 * bsdlabel -w -B ${imgdev}   (should be something like /dev/md6)
 * newfs -n /dev/${imgdev}a   (should be something like /dev/md6a)
 * mount -t cd9660 /dev/${isodev} ${tmpdir}/iso
 * mount /dev/${imgdev}a ${tmpdir}/img
 * cd ${tmpdir}/iso && find . -print -depth | cpio -dump ${tmpdir}/img    (i had better luck with gcpio from mports, one could u
se pax or cpdup too)
 * Fix the etc/fstab in ${tmpdir}:  /dev/da0a    /        ufs    rw        1    1
 * umount ${tmpdir}/iso
 * mdconfig -d -u ${isodev}
 * umount ${tmpdir}/img
 * mdconfig -d -u ${imgdev}
Putting it on flash media

(assumes flash is /dev/da0) dd if=${imgoutfile} of=/dev/da0 bs=1m

Test Environment

This setup was tested on 0.3-CURRENT (Jan 4, 2009) i386 with an Intel DP965LT motherboard. It worked well.

I also attempted to use it on a Mac Pro (Quad 2.0Ghz), and while holding option showed an EFI boot option, nothing would work with the flash. I have not tried GPT yet. Suggestions welcome.

A similar process should work with newer releases (e.g. 0.8.5 release) but the memstick image file is already built for installation purposes. It might be wise to look at modifying the make release process there.

Possible Uses

Aside from using the Live CD image, one could copy the disc1 iso (install) and use that instead of CD-ROM media for installation . In that case, you would need to pick a few different options in sysinstall. This has not been tested to date; if you have su ccess, please update the wiki or send us an email.

It would be nice to modify make release to create a flash boot image for install and live cd like use.

Related Topics

Creating a Live CD
blog comments powered by Disqus