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
66 replies on “Fixing Disk Utility image restore”
Thanks for that! A one-liner to copy the sparsebundle on the Time Capsule disk to a disk
sudo asr -erase -noverify -source source -target target
File copy is not supported anymore. Use the –erase flag.
OSX 10.9.3 on a MacBook Air late 2011.
matthijss-air:~ matthijs$ sudo asr restore -noverify -source /Users/matthijs/freenas.dmg -target /dev/disk1 -erase
Password:
Validating target…done
Validating source…
Could not validate source – Invalid argument
matthijss-air:~ matthijs$
or : sudo asr restore -noverify -source (Source) -target (target)
a Little HInt : You can obtain the Source with Darg n’ Drop
you can hook an : -erase at the End
Do a Imagescan with :
sudo asr -imagescan -source (your Source)
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 :)
You’re on Snow Leo 0.6.8?
What happens when you run
file /Volumes/Untitled/000_DISKIMGS/RPI_webiopi_052013.dmg
in Terminal?
try to Format the Volume which is your Target
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?
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”
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
Thanks Pat, I somehow missed the -erase part when reading the man page.
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 !
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)
your solution was simple and worked for me perfectly; didn’t even have to resort to term hijinks… thanks!
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.
Thanks a lot.
It works
thank you very much,. mounted the iso and the restore to usb worked with no problems,.
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?
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
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
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!
Happy it helped Paulo!
@Matt,
Drop the ‘-‘ from -restore. i.e.
$ sudo asr restore –noverify –source /Volumes/MyBook/Hassan.dmg –target /Volumes/21
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
Thanks so much for this – after many frustrating hours of being unable to restore using Disk Utility, your Terminal method provided the answer.
Cheers!
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.
Um… Never mind. I was able to use dd to write the image back to my flash drive.
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
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.
@Drake: Glad you got it sorted out.
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]
I got it… same as @Grac. I didn’t read the other comments…
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
Glad you got it sorted out @Grac.
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.
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.
This solution worked perfectly, many thanks!!!
good one, tnx!
@Kristin: The ‘$’ is shorthand for the Terminal prompt. Just remove the ‘$’ – on most installs you’ll already see it in the prompt anyway.
@John: it’s possible. if its a public file, find an MD5/SHA1 hash and compare yours.
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?
I got an error saying my image can not be mounted….does that mean I have a corrupted image file?
Thank you, thank you, thank you.
Live saver!
@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.)
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.
@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
What goes in the space with “xxx”?
This site has more details (LOOK AT LAST TWO POSTS!)
https://discussions.apple.com/thread/2316898?threadID=2316898
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
lol dont forget the “$” or it wont work
i still get :
Validating target…done
Validating source…
Could not detect format of volume on device /dev/disk2
Could not validate source – error 254
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.
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
Saved my life….sort of, thanks a lot.
Great tip man. Saved me a lot of effort. Thank you!!!
brilliant! thank you!
Great article. Help me a lot. Thank you Pat.
[…] auch das wollte nicht klappen. Nach einer weiteren Google-Suche fand ich dann heraus, wie man das Image wiederherstellt ohne Imagescan. Ja doll. Endlich schien mal was zu funktionieren. Doch ich hatte ein mulmiges Gefühl, da ich […]
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
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’
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! :)
DAMN useful. Thanks a ton!