If you have a GUI and are able to perform two command-line calls in parallel, you can use
/System/Library/CoreServices/DiskImageMounter.app/Contents/MacOS/DiskImageMounter /path/to/file.dmg
and
osascript accept.scpt
the latter of which executes the following AppleScript:
tell application "System Events"
delay 5 # wait 5 seconds -- I tested it using two terminal tabs and needed the time
key code 48 # press tab 4 times in the license window
key code 48
key code 48
key code 48
keystroke " " # press space to click "accept"
end tell
In bash
, I'm able to write
/System/Library/CoreServices/DiskImageMounter.app/Contents/MacOS/DiskImageMounter file.dmg & osascript accept.scpt
Thanks to @slhck, I was able to see that actually my disk image was not mounted. His assistance helped me confirm that.
Initially I carried out these commands to overcome a no mountable files error:
hdiutil attach -noverify -nomount name.dmg
diskutil list
diskutil mountDisk /dev/disk4
then received the following message:
Volume(s) mounted successfully
This apparently did not work. So there were no files for me to browse through. Here is what I did to solve my main and 1st problem.
I see that in other posts in this site some suggested that we should convert name.dmg
to writable file to overcome a no mountable files error in a name.dmg
file.
I used the command from Terminal to convert but was not successful. Instead, I used Disk Utility, attached the Volume (yes I got the same message again, "no mountable system files") however, Disk Utility nevertheless attached the image, which I was able to do before anyways.
This time, I selected it and then clicked New image, and then selected Image Format » Read/Write, not the compressed option.
I created a new image. This time this image was writable however, it still would not mount using -noverify -nomount
. However, this time I was able to scan it with Disk Drill with exact file locations and folder hierarchy as I had. Recovering all from thereon was a breeze.
Just remember: when you create new image of an attached volume and don't choose Compressed but Read/Write, you need to have a disk with exact amount of space that totals the total space allocated within that name.dmg
file – not the amount of space the data takes.
Mine was huge, and luckily I had an external disk with enough space to do that and it took about 5 hours for about 400 GB of disk allocation. I have all my files now. Thank you all.
Best Answer
In Mountain Lion (10.8.3), none of the
-noautoopen
options worked. The-nobrowse
option does, though: