The best way to clone a disk between two Macs

disk-utilityexternal-diskhard drivemigration

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?

Best Answer

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 (disk0) is the source and Clone (disk2) is the target for our dd operation. Start the clone with:

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

When dd finishes you may see an error like this:

dd: /dev/rdisk2: short write on character device
dd: /dev/rdisk2: 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 1MB 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!