How to create a bootable flash drive on OS X

On OS X, a few built-in terminal commands can be used to create a bootable flash drive from an ISO disk image (like a that of a Linux distro) instead of installing new software to get the job done.

Preparing the flash drive

diskutil is the command-line interface version of Disk After connecting a flash drive, a list of all available disk drives on the Mac can be viewed with the following command:

diskutil list

Find the identifier of the flash drive to be formatted. If one hard drive is attached (the local disk) and no other media is connected, the flash drive will most likely be disk2. Next unmount the flash drive. Prepend /dev/ to the flash drive identifier to get the mount point.

diskutil unmountDisk /dev/disk2

Preparing the disk image

hdiutil is an OS X command line utility that manipulates disk images. Most Linux distributions are shipped as ISO disk images, and the ISO will need to be converted to the UDRW format first. Note, don’t worry about giving the output file name an extension, because hdiutil will give it a .dmg extension by default.

hdiutil convert -format UDRW -o output-file-name input-file-name.iso

Loading the flash drive

dd is a UNIX utility that copies data from one file or device to another. Give dd the name of the input file name (if), which is the outputted file name from the previous command, and the output file name (of), which is the mount point of the flash drive. Note, this has to be done as root so use sudo to run the command.

sudo dd if=output-file-name.dmg of=/dev/disk2 bs=1m

After dd finishes, eject the flash drive with the diskutil command. Use the mount point of the flash drive.

diskutil eject /dev/disk2

A bootable flash drive has been ejected and can be used on any other computer.