Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Restore a full-disk .dmg file to a raw block device Storage Devices
Like many others, I used Disk Utility to create a disk image (.dmg) from my full disk, with the expectation that I could restore this backup at a later date. Said date came all too soon, and I found myself accused by Disk Utility of offering it a corrupted image. Much investigation and much research followed: the image was not corrupt, but the graphical tools did not allow a multi-partition .dmg file to be restored, nor did they allow a full-disk .dmg file to be written to a raw disk or a block device.

Luckily for us all, this task is possible! I hope to spare you much of the suffering I experienced with this hint. For this occasional task, the hdid utility is your friend. You must use Terminal, as Disk Utility does not support this use.

First, mount the .dmg file as a block device only:
hdid -nomount "/Volumes/Diotallevi/Clean Checkpoints/WDC Image.dmg"
Second, determine the block device of the image and destination:
diskutil list
Third, use dd with an appropriate buffer size to copy over the whole block image, including partition table and boot sector. Note that it is extremely important on some hardware to use a large block size; you can expect a 20x speedup over the case without blocksize parameter.
dd if=/dev/disk3 of=/dev/disk2 bs=131072
Fourth, unmount everything and enjoy your copied disk. I get around two terabytes a day of transfer rate; I know of no way to skip sparse areas of the disk image, but could approximate it by dding the first few megabytes of the image, then using Apple System Restore to copy each volume individually.

Expect large speedups for sparse disks with this method. (This hint originally appeared on my site.)
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (11 votes cast)
 
[27,965 views]  

Restore a full-disk .dmg file to a raw block device | 4 comments | Create New Account
Click here to return to the 'Restore a full-disk .dmg file to a raw block device' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Restore a full-disk .dmg file to a raw block device
Authored by: Aaron Wyatt on Apr 14, '09 09:21:50AM

Wow, great hint. This is going to go to good use. Thanks!



[ Reply to This | # ]
Restore a full-disk .dmg file to a raw block device
Authored by: gabester on Apr 14, '09 10:52:32AM

Somehow I thought that was what the menu item Images -> Scan Image for Restore always did... but I suppose there has been at least one occasion where this may have actually been what I needed.
g=



[ Reply to This | # ]
Unnecessary for Single Partition Disk Image?
Authored by: chucky23 on Apr 15, '09 04:48:37AM

Happily, I've never found myself in a position where I needed to restore my backup image files, (made with Carbon Copy Cloner.) But I'd like to know the routine if I ever need to use it.

My question: since I back up separate partitions into separate disk image files, is this hint inapplicable to me? Does this hint only apply to backing up multiple partitions into a single disk image?

(I had no idea it was even possible to backup multiple partitions to a single disk image...)



[ Reply to This | # ]
Restore a full-disk .dmg file to a raw block device
Authored by: caminham on Jun 02, '10 02:59:26PM

This is great. I was getting real frustrated with Disk Utility's non-specific error messages. This worked just like you said it would.



[ Reply to This | # ]