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.

Tagged , , . Bookmark the permalink.

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

  1. Tim Reed says:

    Thanks for that great writeup. Trying to clone a bootable USB stick myself.

    I did have to use the “sudo” command and unmount the destination disk in disk utility to get it to work though.

    Thanks

  2. Rudi says:

    You can also unmount the destination disk via the command line.
    Assuming /dev/disk1 is the destination disk use the following:

    diskutil unmountDisk /dev/disk1

  3. Mikhail says:

    Why notrunc?

    dd man:
    notrunc Do not truncate the output file. This will preserve any blocks in the output file not explicitly written by dd. The notrunc value is not supported for tapes.

    Why don’t you use bs=512 (or other integer of the destination disk)

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
17 − 1 =