Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

What is the best way to clone a disk between two Macs? I ask this every couple years or so and every time I get the same answer. "Use Carbon Copy Cloner", they say. But the unfortunate fact is that CCC is a file-level copy between disks. When I migrate to my new Mac, sure all the files are there but there are quirks here and there (including file dates being different etc).

So, really now, once again: how do you clone the disk over byte-for-byte?

share|improve this question

5 Answers

You can use the dd command to make a bit-perfect clone of a drive. It's a command line tool that ships with OS X. In order to make the clone perfect you'll need to ensure the source and the destination aren't actively in use.

To prepare for the clone I recommend creating a secondary boot disk that you can boot from. Your source for the clone should be an offline volume, not in use, when you're making the copy. Otherwise you risk copying things that are in incomplete states on disk.

With your machine booted to your secondary boot disk, log in and fire up a Terminal or iTerm window.

Run diskutil to get a list of your available drives. One of them will be your target drive you're trying to clone. The other will be your source drive. For example:

> diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *320.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            319.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3       
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk1
   1:                        EFI                         209.7 MB   disk1s1
   2:                  Apple_HFS Backup                  499.8 GB   disk1s2
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk2
   1:                        EFI                         209.7 MB   disk2s1
   2:                  Apple_HFS Clone                   499.8 GB   disk2s2

Let's say that Macintosh HD is the source and Clone is the target for our dd operation. Start the clone with:

> sudo dd if=/dev/disk0 of=/dev/disk2 bs=128m conv=noerror,sync

When dd finishes you may see an error like this:

dd: /dev/disk2: short write on character device
dd: /dev/disk2: Input/output error
3726+1 records in
3726+1 records out
500107862016 bytes transferred in 14584.393113 secs (34290619 bytes/sec)

That last error message is actually okay. The last block written was a short block because there wasn't a full 128MB block to copy. No worries.

Now you've got a bit-wise perfect clone of your Macintosh HD drive. Reboot your system using the Macintosh HD drive and enjoy your clone!

Edit: To address a slowness comment made by @Gordon Davisson in his answer, there's some anecdotal evidence out there that using rdisk# instead of disk# can make dd a whole lot faster. I haven't tried it though. So your dd call would be:

> sudo dd if=/dev/rdisk0 of=/dev/rdisk2 bs=128m conv=noerror,sync

in the above example.

share|improve this answer
+1 great answer – binarybob Mar 27 '12 at 19:49
+1 for the rdisk suggestion -- I thought I'd tried that before, but I just tested and it helped enormously. – Gordon Davisson Mar 28 '12 at 1:30
rdisk# bypasses a 4KB OS buffer. More info. I'd advise that you chose a smaller bs, as going above 1m actually makes it slower. (At least over USB. I can't tell if it's an external USB drive or a direct SATA connection.) – Nick ODell Dec 27 '12 at 22:18

Disk Utility can do volume-to-volume cloning with the Restore tab. Between two Mac OS Extended volumes, this'll do a block copy, i.e. it just copies the volume structures, so all the files come out identical (down to the file ID numbers). This is essentially the same thing dd does, except that Disk Utility can expand/contract the volume if the destination isn't exactly the same size as the source, and it's a lot faster (for some reason, dd is quite slow on OS X).

EDIT: After seeing @Ian's note about speed using /dev/rdiskN vs. /dev/diskN, I ran some quick&dirty benchmarks copying between two 4GB flash drives:

dd using /dev/diskN: 2737 seconds
dd using /dev/rdiskN: 907 seconds
Disk Util, full volume: 840 seconds to copy + 213 seconds to verify
Disk Util, empty volume: 4 seconds to copy + 1 second to verify

So it looks like the rdisk suggestion makes dd run about the same speed as Disk Utility; the real differences are that Disk Utility verifies its data (slower, but maybe safer) and skips blank space (faster if the disk isn't nearly full). That, and as I said above DU can resize as it copies.

share|improve this answer

How about good ol' fashioned dd. It can make a bit-by-bit copy of your drive. There are lots of guides out there on how to do this such as this one or this one

share|improve this answer

Carbon copy cloner was good, but then on my Mac Pro it no longer made bootable clones, I tried it 3 times and every clone failed to boot unlike previously. So I switched to SuperDuper! and that clone booted fine

share|improve this answer

It sounds like you want to create a disk image. OS X contains a utility to do just that: http://docs.info.apple.com/article.html?path=DiskUtility/10.5/en/duh3.html.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.