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 Mac OS X (since Leopard – 2007). 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

{ 57 comments… read them below or add one }

freakqnc May 21, 2013 at 2:52 pm

mymac:~ username$ sudo asr restore -noverify -source /Volumes/Untitled/000_DISKIMGS/RPI_webiopi_052013.dmg -target /dev/disk7 –erase
Password:
Validating target…done
Validating source…
Could not detect format of volume on device
Could not validate source – Invalid argument
mymac:~ username$

Not much difference from using the bloody useless Disk Inutility on Snow Leo 10.6.8

using dd on Terminal got it to copy but somehow it created an unreadable volume hence didn’t work… why it’s beyond me as it did work with ISO images which Disk Inutility doesn’t create

Anyone has a clue as of why this isn’t working and how could be solved? Any help will be appreciated. Thanks :)

Reply

Pat Skinner May 21, 2013 at 3:49 pm

You’re on Snow Leo 0.6.8?

What happens when you run
file /Volumes/Untitled/000_DISKIMGS/RPI_webiopi_052013.dmg
in Terminal?

Reply

Jeff September 7, 2012 at 12:03 am

It’s been 3 weeks since I have been trying to restore a disk image and for some reason I still can’t get it to work.

Example of what I’m typing:
sudo asr -restore -noverify -source /Volumes/SBPD/disk3s4.dmg -target /Volumes/MBL -erase

Here is the error:
Validating target…done
Validating source…
Could not validate source – Invalid argument

Any ideas?

Reply

Matthew Greenwald July 31, 2012 at 11:13 pm

Mountain Lion (10.8) seems to prevent -noverify from working. I tried: “sudo asr restore -noverify -source ~/Downloads/image.iso -target /Volumes/Untitled -erase” on Mountain Lion and asr outputted this:

” Validating target…done
Validating source…
Could not validate source – Invalid argument”

Reply

Pat Skinner July 10, 2012 at 4:06 pm

Another version of Mac OS X has recently emerged.

Lion’s version of asr seems to require erasing the USB drive with the –erase parameter, i.e.
asr restore –source mtlion.dmg –target /Volumes/mtlion/ –erase

Reply

Håkan Wikström July 27, 2012 at 4:08 am

Thanks Pat, I somehow missed the -erase part when reading the man page.

Reply

d morgan July 8, 2012 at 8:48 pm

things like this are exactly why apple need a dressing down, this used to work fine, I have restored the .cdr file to my usb drive many a time, theyve now knackered this from working in disk utility ? why we’ll never know, but now the company that popularised the gui, is forcing us all back to the command line to do anything above plebian, im beginning to hate apple. apple we dont need more features, fix your damn OS !

Reply

Todd June 26, 2012 at 12:39 pm

I was having all sorts of problems with this when trying to install Lion.

I found out the root cause of the “invalid argument” came from not mounting the disk image.

To mount, just double click the .dmg file. It will automatically be verified. (Don’t simply drag and drop from the folder… rather drag and drop from the devices panel on the left) Once its mounted you will see it will appear differently in disk utility. Try your restore using this method and perhaps you will not need to use this terminal method (never worked for me)

Reply

danielsdesk August 7, 2012 at 2:44 pm

your solution was simple and worked for me perfectly; didn’t even have to resort to term hijinks… thanks!

Reply

Eric August 11, 2012 at 12:11 pm

Todd you are a lifesaver. I have been looking around all morning on how to make this work. I’m trying to restore a disk image from my server to test my backup incase of total melt down. I used a scheduled SuperDuper task. Why doesn’t anyone mention that you need to mount the image before restoring in the disk utility? Arrrg.

Reply

Saddavi September 16, 2012 at 3:43 am

Thanks a lot.

It works

Reply

mickey moused macs March 6, 2013 at 6:46 am

thank you very much,. mounted the iso and the restore to usb worked with no problems,.

Reply

NateCow April 9, 2013 at 8:09 pm

This didn’t work for me at all. Once the disk image is mounted, it can’t be added as a source. Did Apple screw this up with Mountain Lion?

Reply

NateCow April 9, 2013 at 8:46 pm

Correction: I got it to allow me to add the mounted disk image as a source. But now I either get “Invalid argument” or “Error 254″. Nights like this make me want to swear off computers all together :P

Reply

Saunders June 26, 2012 at 10:31 am

When I try to do this in the terminal I get the following message, “File copy is not supported anymore. Use the –erase flag.” What am I doing wrong?

Here is my syntax: sudo asr -noverify -source /Users/SaundersHayes/Desktop/ubcd511.dmg -target /Volumes/Ultimate

Reply

Paulo Alexandre Neves June 20, 2012 at 1:25 pm

OS X Lion 10.7.4

sudo asr -noverify -erase -source …. – target ….

You can have source and target from drag-and-drop.
-erase is needed to erase target device

Nevertheless, great post!

Reply

Pat Skinner July 10, 2012 at 4:06 pm

Happy it helped Paulo!

Reply

Pat Skinner May 11, 2012 at 3:00 pm

@Matt,
Drop the ‘-’ from -restore. i.e.
$ sudo asr restore –noverify –source /Volumes/MyBook/Hassan.dmg –target /Volumes/21

Reply

matt May 10, 2012 at 4:51 pm

Thank you, I need help please..

that is what I get…

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]

that is my path :

$sudo asr -restore –noverify –source /Volumes/MyBook/Hassan.dmg –target /Volumes/21

Reply

Phil March 15, 2012 at 12:56 pm

Thanks so much for this – after many frustrating hours of being unable to restore using Disk Utility, your Terminal method provided the answer.

Cheers!

Reply

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

Aaron January 27, 2012 at 11:49 am

How did you do that? Any idea why you’re getting the error message:

Validating target…done
Validating source…
Could not detect format of volume on device “”
Could not validate source – Invalid argument

Reply

Pat Skinner February 20, 2012 at 10:01 pm

Could not detect format of volume on device “”

just a guess, but if you’re trying to restore a .dmg file onto a USB drive, it sounds like the USB drive might need to be formatted first.

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: