How to: Create bootable USB stick on Mac from ISO, dmg or img file

Problem / Outcome Summary

  • This article will enable you to convert an iso, dmg or img file to a bootable usb stick or SD Card on mac OSX using the command line.
  • Please see the ‘Summary Overview’ tab below for a high level view of the objectives this ‘howto’ will achieve.

Why might I want to do this?

  • To create bootable installation media on a USB stick such as:
    • A rescue USB stick for OSX
    • Installation media for Windows 10, 7 or any other version
    • Installation media for a Linux operating system such as Ubuntu, Sabayon, Redhat, SuSe or any other flavour
    • Micro SD installation media for a Raspberry Pi
  • You may also want to convert apple’s native dmg format to iso or vice-versa

Foreword

To be clear, what exactly is an img, dmg or iso file?

Simply put, these are called ‘container’ files, which typically emulate traditional CD or DVD optical media, which have files contained within.  A container file is useful because it is not constrained to the size limitations of current generally available optical media and most crucially remains the simplest way to create a ‘boot disk’ to perform installation and recovery options for the target system.

For example, when a new version of Mac OSX or Windows comes out (i.e. Windows 10), you’ll typically have two choices:

  1. A dmg file to download in the case of mac or
  2. An iso file to download in the case of windows.  (Windows is now offering a USB stick download, but if you have a mac, it’s actually easier to use this process anyway).

What’s the difference between are each of these file formats?

  • img file – Essentially img and dmg are the same thing, it’s a throw back from earlier mac days, but basically both img and dmg are used on mac.
  • iso file – An iso file is a long standing format designed to be  a complete copy of an optical disk.  It’s name comes from ISO9660 referring to a CDROM standard.  The main thing to know is it’s what you generally use on Windows, though mac can read this as well.

Pre-Requisites

Software Dependencies

  • Mac OS
  • An img, dmg or iso file to convert

Hardware Dependencies

  • A USB stick or SD card (doesn’t matter which)
  • A USB port in your mac

Tools Required

  • All required tools come standard with Mac OS

Other Dependencies

  • None

High Level Summary Steps

The below lists the high level summary of steps we’re about to take during this howto.

  • Convert your file to img
  • Copy your img file to your USB stick or SD Card

Implementation

Convert your file to img

Open up the Mac OS terminal app, located in Applications, Utilities

Change directory to where your iso file is and type the following:

  • hdiutil convert -format UDRW -o targetfile.img inputfile.iso

Note – in most cases OSX will create your .img file with the extension .dmg, just rename it like this:

mv yourfile.dmg yourfile.img

Copy your img file to your USB stick or SD card

You’re going to use the same console to see what current devices are in the list, then you’ll insert your USB stick or SD card and check what has changed.

  • diskutil list
  • Insert your USB stick or SD Card and wait for 5 seconds for things to settle
  • diskutil list (again)

You should see your USB stick or SD card device in the list (look also at naming, but generally there should be a new device somewhere in the list)

  • Take note of the name of this device (it will be something like /dev/disk3
  • diskutil unmountDisk /dev/diskx (where x is the disk number you memorised earlier)

Next we will write our newly created image file to this new USB Stick or SD card.  Note however that because we’ve unmounted the disk we need to convert the terminology, in my case /dev/disk3 becomes /dev/rdisk3.  Also note, you must have root access to do this.

  • sudo dd if=inputfile.img of=/dev/rdiskx bs=1m
  • Enter your password for sudo if prompted
  • sync
  • diskutil eject /dev/diskx (just to be really safe)

Depending on the size of your image file and the speed of your USB port, this may take 5 or even 10 minutes to complete.  Once done you have installation media that you can plug into the USB port or SD slot of another computer and perform your new Windows 10, Mac or linux installation.

Final Word

I got frustrated with having to download third party applications to do this for me.  This solution has a number of advantages over other solutions, in particular, once you know the commands, it’s fast and easy, there’s nothing to download and it’s a completely free solution.  Enjoy.

Marshalleq

Popular Articles

Raspberry Pi 3

Raspberry Pi Disk Images – Definitive List

2
This page attempts to list all the Raspberry Pi disk images known to currently exist from around the web, providing direct links to download...
Port Scan Test

How to check port forwarding is working

1
Problem-Outcome Summary This guide applies to:Any router or firewall you may have such as:DLink, Asus, TP Link, Linksys, Synology, Apple, Belkin, Buffalo, Cisco,...
Raspberry Pi Audio Hardware

Raspberry Pi audio HAT’s (Hardware Attached on Top) – Definitive List

0
Summary Back in July 2014, Raspberry Pi announced the then new, Raspberry Pi 2 followed soon after by the announcement of HaTs (Hardware Attached on...
How to set Plex permissions on Linux / NAS devices

How to set Plex permissions on linux or NAS devices

9
Problem / Outcome SummaryThis how to guide will show you how to properly set up Linux file permissions for Plex Media Server Please...
How To Install Logitech Media Server on Ubuntu Linux

How to install Logitech Media Server on Ubuntu Linux

0
Problem / Outcome SummaryThis how to guide will enable you to install Logitech Media Server on Ubuntu Linux For how to install Logitech...
spot_img

Related Stories

Stay on op - Ge the daily news in your inbox