Clone Windows HD on Apple OSX machine

The guy at the PC repair shop warned my dad that “we may need to wipe the HD, do you have a backup”? Ofcourse, all data was backed up daily and “off-site” at my house so all important data was safe. But just in case, we wanted to make an exact disk image of the drive, so that we could easily restore it when the PC returns from the store

I wanted to have a future proof process, run on a Mac, something as follows:

Make an image file of the complete source harddisk including all partitions (in our case there were 3 NTFS partitions on the disk). The image file includes any boot records or loaders if they exist, and is an Apple DMG file so it can be mounted on OSX.

Store the image file on a server disk (so it in turn gets backed up)

When there’s trouble, we now have 2 options, which are
a) mount the image and restore 1 or 2 important files
b) write/restore the image to a new disk

So we bought a second 500GB drive to play around with, and try the restores on.

With the Mac Disk Utility, I made an “MBR” disk image of a drive. Mounting this image gave me the access to all 3 NTFS partitions and data on them. However, for some strange reason, Disk Utility could not restore it’s own disk image to the drive, because it does not allow me to drag the target disk into the target disk field (use google to find more people having this problem). Mucking around with the command line tool “dd”, I actually managed to restore the DMG back onto a physical drive, but for some reason, the primary partition was damaged.

Digging around on the internet, I found that the following method may be the only reliable way to do this and meet all my requirements. It’s relatively simple, although it does take a trip to the command line (which is really not very Apple like).

Backup the DRIVE, not a PARTITION

What Apple calls a “drive” or “disk” is actually often just a partition on a physical disk. A physical disk can have multiple partitions, which appear as multiple “disks” in the Finder or Disk Utility. Because we want to make an image of the physical disk, we need to find out where that disk is. In the Terminal, use to following command:

diskutil list

You’ll get a list of all the physical drives, and the partitions which are on there. For example, our testdisk shows up as follows:

The physical disk is known to the system as /dev/disk3, and the first (and only) pastition on there is a FAT32 partition, and the name of the partition is TESTDISK. To make a DMG of the complete disk with all it’s partitions, the following command is enough:

dd if=/dev/disk3 of=/Users/rolf/MyCompleteDisk100GB.dmg

The command will take a (long, long) while to complete. I’ve read some posts where people were waiting for days for dd to complete their image. There’s also no progress bar. Terrible, but for now I can’t help you with this without getting into rediculous trickery as found on some l33tsp34k hippie h4xor blogs out there.

The fun thing about this trick is, that OSX is able to mount that DMG file. You just double-click it, and “boom“. There are your partitions. A big problem is that these images are uncompressed. So you’ll need 500GB free space to backup a 500GB drive. That’s not funny. You can circumvent that by having the data zipped before writing it to disk but that means you’ll not be able to mount it.

Writing it in compressed form (which is even slower) can be done like so:

dd if=/dev/disk3 | gzip -9 > /Users/rolf/MyCompleteDisk100GB.dmg.gz

Restore the DRIVE (not the partition)

To restore a dmg onto a physical disk, get a disk which is at least the size as the original disk. Having the original disk’s size in the filename like in the example above helps you to remember that in a few months.

After checking which disk you need to write to with the diskutil (as shown abve), restoring an uncompressed disk image merely requires you to swap input and output parameters, like so:

dd if=/Users/rolf/MyCompleteDisk100GB.dmg of=/dev/disk3

Please note that this works because in my case I haven’t rebooted or reconnected drives, so the drive I need to write to is still /dev/disk3.

If you did the gzip compression trick mentioned above, you need to get a bit more fancy:

Post navigation

18 Responses to Clone Windows HD on Apple OSX machine

[…] that you forget to move stuff. So keep your old PC for another month or so, or even better: Make a disk image from the harddisk. You can now safely trash your PC (wipe that harddisk first) without having to […]

Big thanks to the author (bedankt!) for helping me upgrade disks on several of my Linux based devices. I started with NAS disk from LaCie (compression trick worked nice to get a few 10’s of MB image instead of 320GB of mostly empty space), then encouraged I went to upgrade internal hard disk (for TV recording) on my LOEWE Individual TV and soon I plan to do the same hard disk upgrade on my Apple TV (40GB -> 320GB).

I could not finish the process in OSX alone – I also used UBUNTU live CD (works great on my iMac) to resize some of those partitions in order to use new larger drives.

This was a first crucial step to get those exact structures from one disk to another. Thank you!

easy way to get this done in a GUI from apple is to open up disk utility from the Utilities. Then click on the Drive (not the partition) and click New Image). After you’ve saved it somewhere on your computer you can restore it to another drive by clicking on that drive and clicking restore. Select the image and the destination will be the new drive. This does have a progress bar and seems to move a lot faster than using dd by itself. The other nice thing is you don’t have to guess at the disks or using diskutil list to find what drive /dev device you have.

Very helpful!!! Going to repost this with a link back to
your page. Thanks also to “velvetandsilk” that was nice to see
progress. My Testing: Mac OS X 10.6.5 250GB sata to USB connected
(the problem drive) 320GB usb WD passport (backup
location)

You can easily resize partitions before cloning, even from within Windows 7 I believe. Just do this before the copy, and you’ll probably be fine. There are a few tutotials and forums out there on how to do this, just do some Googling. I came up with these two, you might be able to find better ones.

Thanks for the helpful tips. I use dd-gui as a gui front end for the dd utility. It can duplicate a whole drive to another. It gives a progress indicator which is helpful. As you noted, the process can take a very long time. http://www.gingerbeardman.com/dd-gui/

I’ve had good luck with cloning an entire HD containing multiple partitions.

My next project is to clone a drive containing a Windows XP bootcamp partition to a new drive. Not sure how that will work as far as creating a bootable XP partition.

Everytime I double click on the dmg my computer reboots.
I am using mountain lion & cloned a windows drive that I took out of a laptop & placed it into a usb enclosure.
Cloning to another external hfs drive.
Size of dmg & hard drive are the same.