Create a bootable CentOS USB drive with a Mac (OS X) for a PC

apple_osx_centos

1. Visit Centos’ web page, https://www.centos.org/download/, and download the iso image you’d like to boot from.
2. When the download has completed, open up terminal and use ‘hditutil’ to convert the *.iso to an *.img file (specifically, a UDIF read/write image).

$hdiutil convert -format UDRW -o target.img CentOS-7.0-1406-x86_64-Everything.iso
Reading Master Boot Record (MBR : 0)…
Reading CentOS 7 x86_64 (Apple_ISO : 1)…
Reading (Type EF : 2)…
Reading CentOS 7 x86_64 (Apple_ISO : 3)…
…………………………………………………………………….
Elapsed Time: 33.590s
Speed: 200.5Mbytes/sec
Savings: 0.0%
created: /tmp/target.img.dmg

3. Use the ‘dd’ utility to copy the iso to your USB drive:

$ diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *121.3 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 120.5 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *31.9 GB disk1
1: DOS_FAT_32 NO NAME 31.9 GB disk1s1
/dev/disk2
#: TYPE NAME SIZE IDENTIFIER
0: CentOS_7.0_Final *4.5 GB disk2
$ diskutil unmountDisk /dev/disk1
Unmount of all volumes on disk1 was successful
$ diskutil unmountDisk /dev/disk2
Unmount of all volumes on disk2 was successful
$ time sudo dd if=target.img.dmg of=/dev/disk1 bs=1m
Password:
4261+0 records in
4261+0 records out
4467982336 bytes transferred in 1215.483272 secs (3675890 bytes/sec)

4. You should be done! Boot from the USB drive on your target machine.

19 comments on “Create a bootable CentOS USB drive with a Mac (OS X) for a PC

  1. I get a strange result. I am on Yosemite (10.10). All works fine, up until I boot holding down ‘option’. My mac disk comes up along with a disk named ‘Windows’.
    If I select that disk, I get a prompt saying there is no bootable disk.
    When I boot into Mac OS the USB disk is labeled ‘CentOS_6.6_Final’.
    Is this a ‘feature’ of Yosemite?

  2. This is exactly what I’ve been looking for – except, I can’t make it work…

    I’m well versed in the commands and concepts being used here, but
    when I attempt to boot my mac from the usb thumb drive with CentOS 6.5
    the machine just hangs..

    steps tried:

    convert CentOS distribution from .iso to .dmg using hdiutil

    move CentOS .dmg file to usb thumb drive using dd

    insert thumb drive into mac and reboot (no other drives currently connected)

    result: after about 20 seconds, monitor goes black.

    machine is a 2008 xserve
    system is CentOS 6.5

    any help would be greatly appreciated.

    oscar.

  3. Worked like a charm for a newbie on a first go. Now I’m running CentOS 7 on my CD-less server I built from spare parts. Thanks!

  4. the $hdiutil convert -format UDRW -o has a problem in Yosemite 10.10.3 does NOT appear to work as the convert command does not appear in the help see below..

    PLEASE advise on a work-around

    Brians-iMac:CentOS brianbetts$ $hdiutil help
    GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)
    These shell commands are defined internally. Type `help’ to see this list.
    Type `help name’ to find out more about the function `name’.
    Use `info bash’ to find out more about the shell in general.
    Use `man -k’ or `info’ to find out more about commands not in this list.

    A star (*) next to a name means that the command is disabled.

    JOB_SPEC [&] (( expression ))
    . filename [arguments] :
    [ arg… ] [[ expression ]]
    alias [-p] [name[=value] … ] bg [job_spec …]
    bind [-lpvsPVS] [-m keymap] [-f fi break [n]
    builtin [shell-builtin [arg …]] caller [EXPR]
    case WORD in [PATTERN [| PATTERN]. cd [-L|-P] [dir]
    command [-pVv] command [arg …] compgen [-abcdefgjksuv] [-o option
    complete [-abcdefgjksuv] [-pr] [-o continue [n]
    declare [-afFirtx] [-p] [name[=val dirs [-clpv] [+N] [-N]
    disown [-h] [-ar] [jobspec …] echo [-neE] [arg …]
    enable [-pnds] [-a] [-f filename] eval [arg …]
    exec [-cl] [-a name] file [redirec exit [n]
    export [-nf] [name[=value] …] or false
    fc [-e ename] [-nlr] [first] [last fg [job_spec]
    for NAME [in WORDS … ;] do COMMA for (( exp1; exp2; exp3 )); do COM
    function NAME { COMMANDS ; } or NA getopts optstring name [arg]
    hash [-lr] [-p pathname] [-dt] [na help [-s] [pattern …]
    history [-c] [-d offset] [n] or hi if COMMANDS; then COMMANDS; [ elif
    jobs [-lnprs] [jobspec …] or job kill [-s sigspec | -n signum | -si
    let arg [arg …] local name[=value] …
    logout popd [+N | -N] [-n]
    printf [-v var] format [arguments] pushd [dir | +N | -N] [-n]
    pwd [-LP] read [-ers] [-u fd] [-t timeout] [
    readonly [-af] [name[=value] …] return [n]
    select NAME [in WORDS … ;] do CO set [–abefhkmnptuvxBCHP] [-o opti
    shift [n] shopt [-pqsu] [-o long-option] opt
    source filename [arguments] suspend [-f]
    test [expr] time [-p] PIPELINE
    times trap [-lp] [arg signal_spec …]
    true type [-afptP] name [name …]
    typeset [-afFirtx] [-p] name[=valu ulimit [-SHacdfilmnpqstuvx] [limit
    umask [-p] [-S] [mode] unalias [-a] name [name …]
    unset [-f] [-v] [name …] until COMMANDS; do COMMANDS; done
    variables – Some variable names an wait [n]
    while COMMANDS; do COMMANDS; done { COMMANDS ; }

  5. Not sure what to tell you. I’m running 10.10.3 and the ‘convert’ command appears in the ‘help’ output for hdiutil.

    jp@Air:/Users$ sw_vers -productVersion
    10.10.3
    jp@Air:/Users$ hdiutil help
    Usage: hdiutil
    is one of the following:
    help flatten
    attach imageinfo
    detach internet-enable
    eject isencrypted
    verify makehybrid
    create mount
    compact mountvol
    convert unmount
    burn plugins
    info resize
    checksum segment
    chpass pmap
    erasekeys udifderez
    unflatten udifrez
    help display more detailed help

    Usage: hdiutil attach [options]
    hdiutil attach -help

    Usage: hdiutil detach [options]
    hdiutil detach -help

    eject is a synonym for detach…
    Usage: hdiutil detach [options]
    hdiutil detach -help

    Usage: hdiutil verify [options]
    hdiutil verify -help

    Usage: hdiutil create [options]
    hdiutil create -help

    Usage: hdiutil compact [options]
    hdiutil compact -help

    Usage: hdiutil convert -format -o [options]
    hdiutil convert -help

    Usage: hdiutil burn [options]
    hdiutil burn -help

    Usage: hdiutil info [options]
    hdiutil info -help

    Usage: hdiutil checksum -type [options]
    hdiutil checksum -help

    Usage: hdiutil chpass [options]
    hdiutil chpass -help

    Usage: hdiutil erasekeys
    hdiutil erasekeys -help

    Usage: hdiutil unflatten [options]
    hdiutil unflatten -help

    Usage: hdiutil flatten [options]
    hdiutil flatten -help

    Usage: hdiutil imageinfo [options]
    hdiutil imageinfo -help

    Usage: hdiutil internet-enable [options]
    hdiutil internet-enable -help

    Usage: hdiutil isencrypted
    hdiutil isencrypted -help

    Usage: hdiutil makehybrid -o [options]hdiutil makehybrid -help

    Usage: hdiutil attach [options]
    hdiutil attach -help

    Usage: hdiutil mountvol [options]
    hdiutil mountvol -help

    Usage: hdiutil unmount [options]
    hdiutil unmount -help

    Usage: hdiutil plugins [options]
    hdiutil plugins -help

    Usage: hdiutil resize [options]
    hdiutil resize -help

    Usage: hdiutil segment -o -segmentCount [options]
    hdiutil segment -o -segmentSize [options]
    hdiutil segment -help

    Usage: hdiutil pmap [options]
    hdiutil pmap -help

    Usage: hdiutil udifderez [options]
    hdiutil udifderez -help

    Usage: hdiutil udifrez [options]
    hdiutil udifrez -help

  6. Hello James, thank you for the very helpful article.

    However, I’d like to kindly suggest you to modify the last command in your example:

    “time sudo dd if=target.img.dmg of=/dev/disk1 bs=1m”

    The point is that “/dev/disk1” is typically the users primary HDD/SSD with the default setup. The first USB stick should be usually accessible as “/dev/disk2”. So a common Mac user may overwrite his primary HDD/SSD just pasting your last command into his terminal and executing it.

    Everything else works perfectly. Thank you.

  7. @Brian: Leave the leading dollar sign ($) before using the command hdiutil! So just type the following command:

    hdiutil convert -format UDRW -o target.img CentOS-7.0-1406-x86_64-Everything.iso

  8. Hi James,
    I tried 2 days to create an USB stick on my Macbook, OSX 10.10.5
    for booting normal PC with an ubuntu image.
    I followed your article but I was not successful.
    Everytime the usb stick is not recognized in the PC.
    And on my Mac it shows the following after the hdiutil and dd:
    diskutil list

    /dev/disk2
    #: TYPE NAME SIZE IDENTIFIER
    0: Apple_partition_scheme *7.7 GB disk2
    1: Apple_partition_map 4.1 KB disk2s1
    2: Apple_HFS 2.3 MB disk2s2
    peters-mbp:~ peter$

    There is no MBR partition.
    Do you have any idea? Would be great.
    Thanks, Peter

Comments are closed.