How to Copy a USB disk using dd for MAC or Linux

I was asked to create a new USB installer for Mountain Lion for one of our techs. I could have gone through the usual procedure from Apple for creating a USB installer but I wanted something easier since I already had a USB installer for Mountain Lion. So I was going to use dd to copy the disk. This process will work in both MAC and Linux.

So launch a terminal and start by listing the disks with the command ‘diskutil list’:

mac1:~ rootuser$ diskutil list
/dev/disk0
   #:                   TYPE NAME               SIZE       IDENTIFIER
   0:  GUID_partition_scheme                   *160.0 GB   disk0
   1:                    EFI                    209.7 MB   disk0s1
   2:              Apple_HFS Macintosh HD       159.2 GB   disk0s2
   3:             Apple_Boot Recovery HD        650.0 MB   disk0s3
/dev/disk1
   #:                   TYPE NAME               SIZE       IDENTIFIER
   0:  GUID_partition_scheme                   *16.0 GB    disk1
   1:                    EFI                    209.7 MB   disk1s1
   2:              Apple_HFS Untitled           15.7 GB    disk1s2
/dev/disk2
   #:                   TYPE NAME               SIZE       IDENTIFIER
   0:  GUID_partition_scheme                   *8.0 GB     disk2
   1:                    EFI                    209.7 MB   disk2s1
   2:              Apple_HFS Mac OS X Install   7.7 GB     disk2s2

Here you see my hard drive as disk0, and the 2 usbs as disk1 and disk2. I know which is which by the sizes. The original is 8Gb and the new, blank one is 16Gb. You could also plug in 1 usb, run the command, then the 2nd and run it again to be sure you identify the disks correctly.

*** MAKE SURE you know which disk is the original ***

Double check it too, because if you don’t specify the correct source and target, you can easily wipe your data disk.

Next you run the command ‘dd if=source of=target conv=notrunc’

mac1:~ rootuser$ dd if=/dev/disk2 of=/dev/disk1 conv=notrunc

... after a long wait ....

15646720+0 records in
15646720+0 records out
8011120640 bytes transferred in 5378.573464 secs (1489451 bytes/sec) 

And that’s it. You should now have an exact copy of the original USB.

Notes:
If you get an error about ‘Resource Busy’, then you need to unmount the usb volume without ejecting the disk. You can do this in MAC’s Disk utility by selecting the volume and clicking unmount.

Also, in case it’s not obvious, you usually need a destination disk of equal or greater size.