OpenBSD Journal

How to create a USB flash installer for OpenBSD

Contributed by phessler on from the installs in a flash, baby! dept.

Chris Cappuccio wrote in with a procedure to create USB thumbdrive install media:

Luke Tymowski said on Twitter that if you search the Google for instructions on how to create a bootable USB flash OpenBSD installer, you get lots of conflicting instructions. So I thought I'd set the record straight, at least for i386/amd64. It's easy if you already have OpenBSD installed.

1. Download install55.iso from http://ftp.openbsd.org/pub/OpenBSD/snapshots/amd64/ and mount the ISO as a disk:

vnconfig vnd0 install55.iso
mount /dev/vnd0a /mnt

2. Setup your new disk image. Right now the amd64 install55.iso is almost 250MB, so we'll make our disk.img 250MB. (This is the simplest way, although perhaps not the most efficient as you have to write 250MB of zeros!)

dd if=/dev/zero of=disk.img bs=1m count=250
vnconfig vnd1 disk.img
fdisk -i vnd1
echo "a\n\n\n\n\nw\nq\n" | disklabel -E vnd1 
newfs /dev/rvnd1a
mkdir /mnt2
mount /dev/vnd1a /mnt2

3. Copy the installer. Ready? Go.

cp -r /mnt/* /mnt2/

4. Make it bootable!

Host OpenBSD 5.5-beta or later:

installboot -r /mnt2 vnd1 /usr/mdec/biosboot /usr/mdec/boot

Host OpenBSD 5.4 or earlier:

cp /usr/mdec/boot /mnt2/boot
/usr/mdec/installboot /mnt2/boot /usr/mdec/biosboot vnd1

5. Clean up

umount /mnt
umount /mnt2
vnconfig -u vnd1
vnconfig -u vnd0

Go ahead and use disk.img! You are now a ninja USB image creator.

You might ask, how do some systems create a single ISO image that works on CD/DVD and on USB/disk? They use mkhybrid/mkisofs to create a hybrid ISO+MBR+partition image booting with isolinux boot blocks. How to do something like this under OpenBSD? That's a future story.

(Comments are closed)


Comments
  1. By jcp (217.110.62.222) on

    Been looking for simple and comprehensive instructions like these for a long time. Thanks!

  2. By sthen (2001:8b0:648e:cc01:f2de:f1ff:fef9:a752) on

    The isolinux method is quite interesting, they provide an HD-compatible MBR and post-process the ISO with a program which searches for the location of the actual isolinux boot loader and patches it in. More at http://git.kernel.org/cgit/boot/syslinux/syslinux.git/tree/utils/isohybrid.c (or there's an older Perl version at http://git.kernel.org/cgit/boot/syslinux/syslinux.git/tree/utils/isohybrid.in, but that doesn't deal with GPTs).

    I wish I'd thought of this when the call for gsoc projects went out :)

  3. By grazzolini (177.220.181.200) on

    I've been using the images from liveusb-openbsd for some time now: http://liveusb-openbsd.sourceforge.net/ and they work beautifully. They can come handy, specially when you do not have an OpenBSD working system around do manually generate your usb image.

    Comments
    1. By Chris Cappuccio (chriscappuccio) on http://www.nmedia.net/chris/

      > I've been using the images from liveusb-openbsd for some time now: http://liveusb-openbsd.sourceforge.net/ and they work beautifully. They can come handy, specially when you do not have an OpenBSD working system around do manually generate your usb image.

      One nice thing about using the official install.iso is that you get full signed image verification.

  4. By Travis Paul (173.165.20.18) on

    Wow, that is so much easier than what I have been doing. I had posted my janky instructions on my blog (that I had cobbled together from various sources). I'll update the post and point it here!

  5. By Breen Ouellette (207.47.253.253) on www.breeno.net

    I've whipped together an alternative way to create an OpenBSD installer using a USB flash disk. It has some additional utility beyond the method described above. See:

    http://blog.breeno.net/2014/02/creating-flexible-openbsd-usb-installer.html

    -Breeno

  6. By Darren Tucker (67.244.100.93) on

    dd if=/dev/zero of=disk.img seek=249 bs=1m count=1

    will create the equivalent (mostly) sparse file and will be much quicker/

Latest Articles

Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]