October 21, 2016

OpenBSD: Live USB stick

We will be using QEMU, and I will assume you have a 1G flash drive.

For this, first create an image with QEMU:

qemu-img create openbsd.img 950M

Do not take the whole 1G, because we will need some little extra space later.

Download an install iso image from the OpenBSD mirrors and install it on the image you just created (note that I am on 64bits) :

qemu-system-x86_64 -hda openbsd.img -cdrom install53.iso

Follow the usual installation path.

The only important thing is that, after you have finished the installation, do not reboot the virtual machine, mount the cd and copy the contents over to /mnt, which is the only bit of magic here to have a live USB drive:

mount /dev/cd0a /mnt2 ; cp -r /mnt2/5.3 /mnt ; reboot

Of course, replace the 5.3 for whatever you have. Mine is /dev/sdb, check yours with dmesg or so.

Now copy the image to a flash drive

dd if=openbsd.img of=/dev/sdb

Now you have a bootable USB drive.

Insert it into the laptop, boot from it (F12 on a Thinkpad) and, when prompted on OpenBSD, do not forget to choose

boot> bsd.rd

Otherwise you will be booting into the system installed on the flash, and not the live session.