Cloning a Mac disk
Because I needed to replace a HDD with a SSD in my mother’s iMac, I explored the various methods available to clone a disk drive for Mac operating systems. I ended up with the last method, copying using ddrescue (Linux).
Let’s start the overview with the easiest method. The most “geek” method will be given at the end of this document.
Method 1: restore from Time Machine
These steps were documented by Jagardn (2011):
- Do a “back up now” in Time Machine to make sure everything is backed up.
- Shut down and replace drive.
- Boot with Mac OS X DVD (hold the option key during boot to select the DVD).
- Go to utilities and run disk utility.
- Format the new disk (if new).
- Run /utilities/restore from backup and pick the latest one.
According to Jagardn, “it worked great and was bootable, reinstalling the OS was not necessary. It is faster to clone, but it can be done without a cloner.” … “It does have to re index the drive and re download emails. Things that have a database seem to have to rebuild.”
Method 2: use special utilities
- Disk Utility (included in Max OS X)
- SuperDuper (free, $$$ for special features)
- Carbon Copy Cloner ($$$ after trial period)
Note that Carbon Copy Cloner and SuperDuper are primarily designed as file-level cloners. Disk Utility does a real block-level cloning while also being flexible with partition sizes. So I recommend the free, included Disk Utility.
To find out how to use Disk Utility, see e.g. this article from Crucial: How to clone your old hard drive to your SSD (Mac).
More information about block-level cloners can be found in the Cnet article Differences between file-level and block-level cloning.
Method 3: use dd (disk dump)
If you are a techie and know dd, then you might consider this method. It is very flexible and also free, but does not offer the partition resize options from Disk Utility.
This works from Linux / *nix / BSD, and also from a Mac system when the disk being cloned is not active (not mounted read-write). But you don’t need to perform this action on a Mac, so a machine running Linux can also be used.
If you’re using Linux, consider using ddrescue. It is highly preferred over plain dd when making disk copies.
Boot your Mac into Linux and use ddrescue
One way to make a clone is to boot your Mac with an USB stick containing Linux. This is what I did:
- Downloaded and install the Mac Linux USB Loader on the iMac.
- Downloaded Kali Linux (64 bit), which is now supported by the Mac Linux USB Loader.
- Create a bootable Kali stick using the tools above.
- Power off the iMac.
- Attached a harddisk docking station to the iMac using USB.
- Boot the iMac with Kali (hold the option key while powering on the iMac).
- Expore the disks using gparted and made a note of the device names.
- Kali comes with
dd_rescue, which is not the same as
ddrescueand is in fact inferior. So issue
apt-get install gddrescue(note the g) and then go forward:
ddrescue -1 /root/diskcopy.log --force /dev/sda /dev/sdc(your device names might be different).
GPT partition troubles
After you have copied the disk, you might want to fix the GPT partition table. The backup table should be at the end of the disk, but when you copy to a bigger disk, this will not be the case. Also the GPT table now contains incorrect information about the disk size.
Or, as Jeremy Chadwick (“koitsu”) explains:
With GPT, the primary GPT is stored at the beginning of the drive (specifically LBAs 0 through 33), and the backup GPT is stored within the last 34 LBAs of the drive. The size (34 LBAs) varies too, depending on how many partitions you’ve defined. In the case src is smaller than dst (ex: 500GB src, 1TB dst), the primary GPT will be copied (assuming no read errors of course!) to the same LBA ranges (0-33), but the backup GPT will end up in the middle of the dst rather than at the very end of the drive.
Apple OS X poses additional challenges. Jeremy continues:
First thing is first: OS X is probably going to throw all sorts of nonsensical madness complaints/failures if you do this. Apple’s partitioning tools actually look at vendor strings of hardware (disks I think) and will reject you if you try to work on a “non-Apple-approved” disk. OS X also uses some very bizarre partitioning scheme that I cannot even begin to explain (it’s some weird form of like EFI plus GPT, or EFI plus MBR – I forget).
The parted program might be of help:
Afterwards, gparted showed correct information, but when booting in OS X (10.11 El Capitan), the Disk Utility partitioner showed only the size of the originating (smaller) disk, while it also showed the correct (full) size for the device information. I did not care about this as I already planned to only use half of the SSD storage, but still it feels a bit disturbing.
Maybe GPT fdisk (
gdisk) could also be
of use. Use the v (verify) option.
Copy over the network using netcat
Using netcat, you can even do a diskdump over a network connection (but this only works with plain dd and dd_rescue, not with ddrescue). You want to RTFM first before trying this, so no further information will be given here.
There is extensive documentation elsewhere on the world wide web. For example, see these pages:
- What is the best way to clone a disk between two Macs?
- Damaged Hard Disk – cgsecurity
- Cloning an OSX disk using Linux, dd, and parted
- What’s the difference between ddrescue, gddrescue, and dd_rescue?
O, why Kali Linux? Because of their cool logo, of course. Nothing beats their dragon 🙂
Deze blogpost werd in december 2022 overgezet van WordPress naar een methode gebaseerd op Markdown; het is mogelijk dat hierbij fouten of wijzigingen zijn ontstaan t.o.v. de originele blogpost.