Creating a bootable USB stick from OSX

I was having some trouble getting my ML110 Proliant lab server to boot from a USB drive that I had created with UnetBootin on my Mac. Initially, I thought it was a problem with the ML110 server, but it turns out that Unetbootin does not currently make a fully bootable USB stick in OSX. The trick is that you have to set up the master boot record correctly yourself using DiskUtil, fdisk and an MBR file from the SysLinux project. In this tutorial I will show you how.

If you would like to create a bootable USB drive from OSX, you will need:

Step 1 – Format the disk in Disk Utility, with the correct MBR

Assuming you have already inserted your USB drive into your Mac…

a) Open Disk Utilty

b) Select the USB device

c) Click Partition

d) Select 1 partition in the partition layout

e) Select “Master Boot Record” in the options

f) Select MS-DOS (FAT) in the format type.

g) Click Apply, then Partition

h) Close Disk Utility

This will wipe the USB disk and set it up with the correct boot record.

Step 2  – Install the MBR binary from the SysLinux project

Open up a terminal and then

a) Use the command line diskutil to find the device name for your USB drive.

diskutil list

a) Umount the USB drive with the command line. NB: Be sure to swap the device reference (in my case it is /dev/SOMEdisk2) with the correct one for your usb key that you identified in the previous step – this will change for each machine.

diskutil unmountDisk /dev/SOMEdisk2

b) Mark the partition active, then unmount it again

sudo fdisk -e /dev/SOMEdisk2
print
f 1
write
print
exit
diskutil unmountDisk /dev/SOMEdisk2

c) Download Syslinux

mkdir -p ~/Documents/BootableUSB
cd ~/Documents/BootableUSB
curl -L -O http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-5.00.zip
unzip syslinux-5.00.zip -d syslinux-5.00
cd syslinux-5.00/mbr

d) Install the MBR – NB: Update the device name (/dev/SOMEdisk2) to the one you identified in the first step!!!

sudo dd conv=notrunc bs=440 count=1 if=mbr.bin of=/dev/SOMEdisk2

Step 3 – Use UnetBootin to install your OS install files

a) Download and install UnetBootin if you haven’t already from http://unetbootin.sourceforge.net

b) Load the application, choose your preferred distribution, and then click OK.

c) When it’s finished, eject the usb key and use it!

References

Thanks to a tip I found on http://perpetual-notion.blogspot.co.uk/2011/08/unetbootin-on-mac-os-x.html

6 thoughts on “Creating a bootable USB stick from OSX”

  1. Just FYI, there’s a copy of mbr.bin inside of UNetbootin.app, so you don’t need to bother with installing syslinux in full:

    unetbootin.app/Contents/Resources/mbr.bin

  2. There is no longer a mbr/mbr.bin, but there are mbr.bin files in other places:

    /tmp/syslinux-6.02/bios/mbr/mbr.bin
    /tmp/syslinux-6.02/efi32/mbr/mbr.bin
    /tmp/syslinux-6.02/efi64/mbr/mbr.bin

    Since I don’t have an efi boot, I chose the first one, but for some reason, it is not getting recognized as bootable. I also used the mbr.bin from the unetbootin installation itself, as suggested by Kyle and that too didn’t help. I have another flash drive that I created on windows (long ago) using HP format utility and unetbootin, and that works perfectly on this system. Since the old drive and the new one are exactly of the same size, I tried cloning it using dd and the new one boots fine, so not sure what is going wrong with a fresh install.

    The reason I want to do a fresh install is because the old one, though boots, gives me errors during the boot, so I am suspecting that the drive is failing. What could be going wrong with the above steps that I am following as is?

  3. When I’m entering “sudo fdisk -e /dev/SOMEdisk2″ I get the error: “fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory”

    I’m a bit new at this. Thoughts?

  4. Thanks man! I really appreciate it, this guide was quite a bit more thorough then others I found. Kudos!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>