Fixing Disk Utility image restore

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

63 thoughts on “Fixing Disk Utility image restore”

  1. 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$

  2. or : sudo asr restore -noverify -source (Source) -target (target)

    a Little HInt : You can obtain the Source with Darg n’ Drop

  3. 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 :)

  4. 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?

  5. 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”

  6. 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

  7. 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 !

  8. 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)

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

    2. 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.

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

    4. 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?

      1. 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

  9. 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

  10. 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!

  11. 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

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

    Cheers!

  13. 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.

      1. 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

        1. 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.

  14. 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]

  15. 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

  16. 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.

  17. 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.

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

  19. 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?

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

  21. @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.)

  22. 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.

  23. @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

  24. 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

  25. i still get :

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

  26. 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.

  27. 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

  28. 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

  29. 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′

  30. 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! :)

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>