Restoring images without the futility of Disk Utility

I was trying to put a Mac OS X 10.6 image onto a USB stick to install on another system. To do this, I attempted to do it from a Mac running 13.6 and failed with a message like this when restoring the image to the partition:

Could not validate source - Invalid argument
The operation couldn't be completed. (OSStatus error 22.)

It turns out that Disk Utility is pretty broken at this. What you’re better off doing is using asr. This utility is what Disk Utility does under the covers anyways.

First, make sure your image is actually HFS+. You can do so with the file utility, and make sure it has output like this:

% file 10.6.7-10J3250-MBP8X-OSX.dmg
10.6.7-10J3250-MBP8X-OSX.dmg: Apple HFS Plus version 4 data (mounted) last mounted by: '10.0', created: Wed Mar 16 21:06:25 2011, last modified: Thu Mar 17 08:37:51 2011, last checked: Thu Mar 17 07:06:25 2011, block size: 4096, number of blocks: 1926522, free blocks: 12346

Then use imagescan – this step munges some headers, and is required:

% asr imagescan --source 10.6.7-10J3250-MBP8X-OSX.dmg                                 
Block checksum: ....10....20....30....40....50....60....70....80....90....100
successfully scanned image "/Users/calvin/Downloads/10.6/10.6.7-10J3250-MBP8X-OSX.dmg"

Then you can actually restore. Note that you want to restore to an HFS+ partition on a GPT filesystem disk – not the whole disk.

% sudo asr restore --source 10.6.7-10J3250-MBP8X-OSX.dmg --target /dev/disk6s2 --erase
	Validating target...done
	Validating source...done
	Erase contents of /dev/disk6s2 ()? [ny]: y
	Retrieving scan information...done
	Validating sizes...done
	Restoring  ....10....20....30....40....50....60....70....80....90....100
	Verifying  ....10....20....30....40....50....60....70....80....90....100
	Restored target device is /dev/disk6s2.
Restore completed successfully.

Leave a Reply

Your email address will not be published. Required fields are marked *