Skip to content

Instantly share code, notes, and snippets.

@jahio
Last active January 5, 2017 19:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jahio/d717d6c73e20307afaadb1eaee7710c0 to your computer and use it in GitHub Desktop.
Save jahio/d717d6c73e20307afaadb1eaee7710c0 to your computer and use it in GitHub Desktop.
What OS X's Disk Utility SHOULD Be Able to Do - But It Got Nerfed

Notes on making USB disks from the macOS Console

Since Apple destroyed the awesome tool that was Disk Utility in the pre-Capitan days, we now have to resort to this kind of lunacy to do what used to be a simple task. Way to go, Apple. You're making Microsoft look borderline useful with these kinds of fuck-ups, and I find myself gravitating toward the power, consistency and flexibility I can get with Linux with each passing day. Get your shit together.

...anyway...

tl;dr

sudo su
diskutil list # find the right disk designation, say disk2
diskutil unmountDisk /dev/disk2 # unmount the whole thing, incl. all partitions
dd if=/path/to/your/iso of=/dev/rdisk2 # note the r for "raw"
diskutil eject /dev/disk2

To zero a disk

  1. Identify the disk device according to the OS;
  2. Use dd to write zeros to the RAW version of that disk.

Identifying the Disk

Use diskutil list:

$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage WRAITH                  449.4 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:         Microsoft Reserved                         16.8 MB    disk0s4
   5:       Microsoft Basic Data BOOTCAMP                50.0 GB    disk0s5
/dev/disk1 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS WRAITH                 +449.0 GB   disk1
                                 Logical Volume on disk0s2
                                 244105AB-8769-4F86-947C-A312FFF5ED7E
                                 Unlocked Encrypted
/dev/disk2 (external, physical):                                                          <-- THIS IS MY EXT USB DRIVE
   #:                       TYPE NAME                    SIZE       IDENTIFIER            <--
   0:      GUID_partition_scheme                        *15.5 GB    disk2                 <-- HERE'S A PARTITION
   1:                        EFI EFI                     209.7 MB   disk2s1               <-- AND ANOTHER
   2:                  Apple_HFS ESXi                    15.2 GB    disk2s2               <-- AND ANOTHER...?

Unmount the partitions and the disk

Since /dev/disk2 has three partitions mounted (/dev/disk2s1, /dev/disk2s2), we should unmount those first:

$ sudo umount /dev/disk2s1
$ sudo umount /dev/disk2s2
$ sudo umount /dev/disk2

Write zeros to the drive

Now we can zero the drive, but we should use the raw disk interface to do this as it'll go faster. Prefix the disk device name with the letter r to get that functionality:

$ sudo dd if=/dev/zero of=/dev/rdisk2 bs=1m

if -- input file of -- output file bs -- block size (in this case, 1 megabyte)

"Burning" an ISO

You used to be able to do this with a practical snap of the fingers before Yosemite, but noooooo, Apple had to break its legs. You guys suck.

Use dd to put the ISO on the device

Same thing here - dd to the rescue.

$ sudo dd if=/Users/you/Downloads/YourISO.iso of=/dev/rdisk2 bs=1m
# ... output ...

If all goes well you should be able to see an exit status of zero:

$ echo $?
0

Eject the disk from the operating system

Pullin' the plug now, here we go!

$ diskutil eject /dev/disk2
Disk /dev/disk2 ejected

Now pull that thing out, cross your fingers, swear fealty to the lords of hell, and maybe if you're lucky that damn thing'll actually boot! 😃

Tips & Tricks

How to convert a macOS DMG to a more useful ISO

Use hdiutil:

hdiutil makehybrid -iso -o Where-To-Put-The-Final-Output.iso /path/to/the/source.dmg
  • makehybrid -- a "hybrid" filesystem for read-only disk images. Should be readable most anywhere.
  • -iso -- yeah we want an actual ISO image here
  • -o -- think of it as the argument saying where to put the output...

Damn, dd is taking for-evar! How can I check its progress?

In the same terminal window in which the process is running, hit CTRL+T. No, I don't mean CMD instead of CTRL, I actually, quite literally mean the CTRL key here. This feature may be specific to macOS's version of dd; Linux or other *nix users may need to use a different method or key combination.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment