How to copy a CentOS ISO to USB on Mac OS X

- by

CentOS-LogoWindows users have a great free tool called ISO2USB which efficiently transfers ISO images to a USB stick. Mac users don’t have such a luxury – at least I haven’t found one yet.

Instead we can make use of a command line tool named dd which can do this for us. It needs a few parameters though, and in this article we’ll look at what those are. The following will work in both Mavericks and Yosemite, with ISOs from CentOS 6.5 and above. Our operation will result in a bootable USB stick.

First, head over to a CentOS Mirror and download your favourite ISO image. Next, have a USB stick handy and insert it into your Mac. Now open Terminal – it’s under Applications – Utilities, or do a Spotlight search to find it.

For this example I’m assuming that the image file is called centos.iso and that it’s in your Downloads directory. Let’s enter that directory by issuing the following command:

cd ~/Downloads
ls

The second command lists all files, and your ISO image should be one of them.

Find out what device your USB stick is

So far so good, we’re in the right location. The dd command needs to know which file you want to copy (see above), and the device corresponding to your USB stick. It’s easy to get confused at this point. Let me explain this:

Devices are things attached to the system, such as hard disk, memory cards and USB sticks. Each device can hold a number of partitions which is where your data is stored. Depending on how many storage devices are attached to your system, you’ll get a specific address for each device. For example, /dev/disk0 is your internal Mac hard disk in which you’ll find three partitions.

Since our ISO image will overwrite all partitions on the USB stick, we need to know what the system knows our USB stick as. Type the following to get a list of what’s attached where:

diskutil list

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            999.3 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *512.1 GB   disk1
   1:                        EFI EFI                     209.7 MB   disk1s1
   2:                  Apple_HFS Macintosh SSD           511.3 GB   disk1s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk1s3
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *1.0 TB     disk2
   1:                  Apple_HFS VM Drive               1.0 TB     disk2s1
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.5 TB     disk3
   1:                        EFI EFI                     209.7 MB   disk3s1
   2:                  Apple_HFS Black Time Machine      1.5 TB     disk3s2
/dev/disk4
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *4.0 GB     disk4
   1:                 DOS_FAT_32 C64

Looks like I’ve got 5 storage devices on my system. The one at the bottom is my USB stick, an old 4GB model currently formatted with FAT32. Your layout will be different, so keep an eye on the SIZE parameter. If your currently formatted stick is named you can identify it that way too (mine is called C64).

The device I want to use here is /dev/disk4. Note that when we get to work, everything on your USB stick will be erased when we copy the ISO over. The dd command will not warn you before this happens.

Unmount your USB stick

Before we can continue we need to make sure your USB stick isn’t mounted to OS X. If it was formatted with a filesystem that your Mac can read, then you’ll see your stick as an orange icon on the desktop. But since the dd command will do a low level format with a different filesystem, OS X needs to let go of our stick. If we don’t do this, you’ll get a “Resource busy” message in the next step.

To unmount your stick, type the following:

diskutil unmountDisk /dev/disk4

Unmount of all volumes on disk4 was successful

That orange icon should disappear from the desktop, and you will no longer see your USB stick in the Finder either. Leave it attached though – do not eject it.

Copy the ISO image over

Now let’s give the dd command something to do. Since we’re in the correct directory already, type the following (you will be prompted for your password):

sudo dd if=centos.iso of=/dev/disk4

// time passes...

694272+0 records in
694272+0 records out
355467264 bytes transferred in 249.100402 secs (1427004 bytes/sec)

Amend /dev/disk4 with your own device. Feel free to specify the direct path to your image file in place of centos.iso (no wildcards I’m afraid).

This step can take a long time, during which you won’t get any feedback whatsoever. That’s normal, even though it looks like your session hangs. It’s all good. As long as you leave the Terminal window open, feel free to do other things with your Mac and leave it running.

In the above example I was copying a 190MB image and it took just over four minutes. I had an abysmally slow USB stick mind you – something to keep in mind when you want to transfer a large “everything ISO” image onto a stick from 10 years ago: you’re not doing yourself a favour, it’ll take hours to copy, and just as long to boot from later.

Should you want to terminate your dd session during this time (and use a faster USB stick for example), simply hit CTRL+C and you’ll be returned to the command line.

If all went well you’ll receive a summary message at the end. Now you’re ready to boot from your stick into the wonderful world of CentOS.



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

13 thoughts on “How to copy a CentOS ISO to USB on Mac OS X”

  1. Use a larger block size with dd to significantly increase your transfer rate.

    Even older, slow USB devices have a much higher supported transfer rate than the default dd block size 1byte. Reading and writing 1byte at a time has enormous OS overhead. change the block size to something around 1 megabyte and you’ll get the same task accomplished much more quickly.

    In your example:

    sudo dd bs=1m if=centos.iso of=/dev/disk4

  2. This is not working for me to create a bootable Centos 6.7 to install on a new Dell R730xd. I get a “boot failure : make sure you have a compatible media device installed” .. when I insert the USB Stick and choose it as the boot device. Going nuts here! 🙁

  3. Hi Steve, if it would be easy, everybody would be running CentOS 🙂

    I never had that problem myself. Here’s what I can suggest:

    • Did you try a different stick?
    • Did you try booting from the stick on different hardware (that’s safe, just make sure you don’t go through with the full installation of course…).
    • Last resort: if you have access to a Windows machine you can use ISO2USB: http://iso2usb.sourceforge.net
  4. I have tried 3 different sticks — same issue. No other Dell type H/W available.

    However, I just made a break through — if I change the BIOS from “UEFI” to “BIOS” — it DOES boot .. but I need UEFI because I have 12TB of disk. So not sure what that means.. or what to do

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.