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 }
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.
@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.
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!
{ 1 trackback }