Fixing Disk Utility image restore

by Pat Skinner on 10/10/2009

For some reason, restoring a DMG image to a block device has been an atypically frustrating experience under Leopard and Snow Leopard. Apple Disk Utility comes back with user unfriendly errors citing an ‘invalid argument’. It insists on doing some silly ‘image scan’ which never actually works, thereby blocking any successful image restore. Delving deeper I thought it was likely some other component utilized by Disk Utility was failing and I found what it was.

It turns out that Disk Utility employs Apple’s ASR utility, stored at

/usr/sbin/asr

To learn more you can run ‘asr’ by itself in Terminal. While

man asr

shows a lot more, I’ll save you from reading that (this man page has even got a History section).

Simply restore without an image scan:

$ sudo asr -noverify -source source -target target

{ 35 comments… read them below or add one }

Bob December 15, 2011 at 5:22 pm

I think I’m missing something. Perhaps it works different on Lion?

Here’s what command I used:
=========
sudo asr restore –noverify –source /Users/user1/Documents/disk1.dmg –target /dev/disk2s1 –erase
=========

Here’s the output:
=========
Validating target…done
Validating source…
Could not detect format of volume on device “”
Could not validate source – Invalid argument
=========

Any idea? Thanks.

Reply

Bob December 15, 2011 at 7:46 pm

Um… Never mind. I was able to use dd to write the image back to my flash drive.

Reply

Pat Skinner November 11, 2011 at 2:12 pm

@Drake: Glad you got it sorted out.

Reply

Drake November 11, 2011 at 2:10 pm

What do I do?
I entered:
sudo asr -noverify -source /Volumes/UBUNTU -target /Users/DrakeAustinRehfeld/Desktop/ubuntu-11.04-desktop-i386.iso

I got:
asr: unrecognized option `-source /Volumes/UBUNTU’
Usage: asr
is one of the following:
asr help | version
asr restore –source –target []
asr restore –source asr:/// –file []
asr server –source –config []
asr imagescan –source [--filechecksum] [--nostream] [--SHA1]

Reply

Drake November 11, 2011 at 2:11 pm

I got it… same as @Grac. I didn’t read the other comments…

Reply

Matthew Drake October 15, 2011 at 12:30 pm

Can I use this to restore Windows on my bootcamp partition?
Disk Utility worked fine for the Mac side, but it won’t even scan the Windows .dmg or .cdr (cannot find source: invalid argument).
I’ve tried using the Windows native Recovery option, but it doesn’t see the .dmg or the .cdr either.
If anyone has any help, please!

thanks

Reply

Pat Skinner October 13, 2011 at 6:06 pm

Glad you got it sorted out @Grac.

Reply

Grac October 13, 2011 at 5:03 pm

Ok. Got t working. I was pasting examples from the comments but it looks like “-restore” parameter was missing (at least in my case). So the path should be:

sudo asr –restore –noverify –source /Volumes/xxx/osx_leopard_snow.dmg –target /Volumes/osxleopardsnow

Copying files as I write this. Fingers crossed. I’m a Terminal novice btw so I might be talking nonsense.

Reply

Grac October 13, 2011 at 4:40 pm

So..I get this error:

asr: Unrecognized verb “–noverify”
Usage: asr
is one of the following:
asr help | version
asr restore –source –target []
asr restore –source asr:/// –file []
asr server –source –config []
asr imagescan –source [--filechecksum] [--nostream] [--SHA1]

What am I doing wrong? Thanks.

Reply

Lancelot_dt August 19, 2011 at 3:50 pm

This solution worked perfectly, many thanks!!!

Reply

Adriaan August 11, 2011 at 10:23 am

good one, tnx!

Reply

Pat Skinner July 18, 2011 at 6:22 pm

@Kristin: The ‘$’ is shorthand for the Terminal prompt. Just remove the ‘$’ – on most installs you’ll already see it in the prompt anyway.

Reply

Pat Skinner July 18, 2011 at 6:21 pm

@John: it’s possible. if its a public file, find an MD5/SHA1 hash and compare yours.

Reply

Kristin July 17, 2011 at 1:56 pm

This article is old but it looks so useful… any help? I think I’m typing it right, but I keep getting this: -bash: $: command not found
Anyone know what this means?

Reply

John July 16, 2011 at 9:33 am

I got an error saying my image can not be mounted….does that mean I have a corrupted image file?

Reply

James Kurtz III June 27, 2011 at 2:05 pm

Thank you, thank you, thank you.

Reply

spiinl June 3, 2011 at 9:31 pm

Live saver!

Reply

Pat Skinner May 8, 2011 at 12:15 am

@TNanek: The ability to drag and drop files into Terminal has been around for ages and is a definite time saver, especially for mouse-inclined folks.

(I wonder if Windows or KDE/GNOME support this kind of drag and drop by now; they definitely haven’t historically.)

Reply

TNanek May 8, 2011 at 12:07 am

You don’t even have to know the paths.

Lets say you are putting a dmg onto a flash drive (or any external drive, AFAIK will work the same, but I only have flash to test with).

Put the .dmg either on your desktop, or have a finder open in the background with it there.

Open terminal and begin typing the command. When you need the path, then you can click and drag the appropriate device to the terminal window and its path will be determined and put in the command you’re entering. So, for example, type:

sudo asr –noverify –source

Now (after a space from the last e) drag the source .dmg file to the window. The path entered will look similar to the example in the original post. Continue by entering ” -target ” (note the spaces before and after the text; and don’t use the quotes). Now drag the external drive from your desktop to the terminal. Again, this should be looking similar to the given example in the original post.

This just saves the time of figuring out paths of files, for those of you not as familiar with the command line.

Reply

Pat Skinner May 5, 2011 at 11:34 pm

@Dresden:
sudo asr –noverify –source /Volumes/xxx/osx_leopard_snow.dmg –target /Volumes/osxleopardsnow

The xxx is only an example. Replace the path wherever you have stored your DMG file. It could be /Users/Dresden/Desktop/diskimage.dmg

Reply

Dresden April 28, 2011 at 10:36 am

What goes in the space with “xxx”?

Reply

david April 19, 2011 at 4:00 pm

This site has more details (LOOK AT LAST TWO POSTS!)
https://discussions.apple.com/thread/2316898?threadID=2316898

Reply

dragon sun April 16, 2011 at 9:58 am

i first converted iso 2 dmg and then used the way 2 copy the file ,it’s not work,but when i use iso file directly,it’s worked

Reply

dej January 25, 2011 at 5:00 pm

lol dont forget the “$” or it wont work

Reply

platinumpresto January 3, 2011 at 2:55 am

i still get :

Validating target…done
Validating source…
Could not detect format of volume on device /dev/disk2
Could not validate source – error 254

Reply

Mario December 14, 2010 at 4:49 pm

Jed, you don’t have to type $ in front of the sudo. That’s just a sign that you are a regular user at the moment.
Btw, # is for root users.

Reply

Bravo Charlie November 14, 2010 at 8:45 am

While the hacky command line is a good work around, the root issue is that Apple’s hobbyware does not work. Why? And it still has not been fixed in 10.6.5.

I have my original 128K Mac and hence remember when Jobs came out and revolutionized the computer industry with the graphical operating system. (no graphical user interface against any command line junk).

Whisky Tango Foxtrot over,
BC

Reply

Roland October 24, 2010 at 12:20 pm

Saved my life….sort of, thanks a lot.

Reply

Ioannis September 28, 2010 at 5:17 pm

Great tip man. Saved me a lot of effort. Thank you!!!

Reply

b July 10, 2010 at 4:01 am

brilliant! thank you!

Reply

Hristo May 27, 2010 at 8:08 am

Great article. Help me a lot. Thank you Pat.

Reply

Jed April 14, 2010 at 7:47 pm

Also this won’t work if you forget the $ before sudo (with no space) and don’t forget the spaces after -source and after -target. Here’s the complete right syntax.

$sudo asr –noverify –source /Volumes/xxx/osx_leopard_snow.dmg –target /Volumes/osxleopardsnow

Reply

Pat Skinner February 10, 2010 at 9:47 am

I’m glad this tip was helpful.
@Yannick: Most shells in UNIX & Windows use whitespace as a delimiter. You can still use the name UNTITLED I, but you would have to use quotes, i.e.
sudo asr –noverify –source /Volumes/xxx/osx_leopard_snow.dmg –target ‘/Volumes/UNTITLED 1′

Reply

Yannick February 10, 2010 at 6:47 am

Really useful! But with valid commands. U have to read man asr!

Example:
sudo asr –noverify –source /Volumes/xxx/osx_leopard_snow.dmg –target /Volumes/osxleopardsnow

Do not use the default name like UNTITLED 1 cause it read the spaces and give for “1″ an option meaning…

Thx the post anyway! :)

Reply

Jeff Byrnes December 7, 2009 at 9:19 pm

DAMN useful. Thanks a ton!

Reply

Leave a Comment

{ 1 trackback }

Previous post:

Next post: