Tools/tips to recover data from a corrupt DMG disk image?
Please share, if you know any tips to salvage data from a "compressed DMG" which no longer mounts (in my case, something went wrong during "scan image for restore").
Answering my own question here with a list of things to try.
- Disk Utility > First Aid > Repair Disk
- Disk Utility, try converting the image to an ISO
- try using 3rd party utility to convert the image, such as "dmg2iso" (sometimes this has a side effect of ignoring corrupt data, and the image will mount)
- try mounting with 3rd party utility such as Toast
hdiutil attach -ignorebadchecksums /Volumes/path/to/image
-
hdiutil mount -nomount -readwrite /Volumes/path/to/image
(then try repair using DiskWarrior, etc)
I'll probably be fleshing this list out over the next week as I do more research. I want to take a look through these sites:
- http://discussions.apple.com/thread.jspa?threadID=1218394
- http://discussions.apple.com/thread.jspa?threadID=2065256
- http://lorenzo.yellowspace.net/corrupt-sparseimage.html
I found the following command to work on salvaging a corrupted dmg image. The solution started from reading your problem. I looked for a solution for three days.
hdiutil convert imac.dmg -format UDTO -o output.img
Background: I had used diskutil on OSX 10.8.2 to create an image of my iMac's internal drive. I transferred it up to my server and when I went to restore it to another disk it would not mount saying there were no valid file systems. I was devastated as I had too much confidence in the image and got rid of my timemachine images to save space. Okay I am a moron who should know better!
I googled the error and found this discussion. I tried all of the items and was not able to mount the dmg file. I knew the the image was basically good by running
hdiutil imageinfo imac.dmg which gave promising results:
Format Description: UDIF read-only compressed (zlib)
Class Name: CUDIFDiskImage
Checksum Type: CRC32
From a link provided in this thread http://discussions.apple.com/thread.jspa?threadID=1218394
I found a reference to http://vu1tur.eu.org/tools/ for dmg2img which DMG2IMG is an Apple's compressed dmg to standard (hfsplus) image disk file convert tool. I went to the read me file for the tool which had this note:
1. An equivalent command under Mac OS X would be:
hdiutil convert <input.dmg> -format UDTO -o <output.img>
And that turned out to be the solution. I was able to mount the output file, which was the right size, 200GB, and extract the files I needed!
SUCCESS!
I had to use the -noverify
and -mount
suppressed flags to get my disk to mount. Without those flags, the errors kept causing the mount to abort. After mounting in this way, I was able to select a blank entry in the Disk Warrior drop-down and recover the majority of my files.
hdiutil attach -noverify -mount suppressed /Volumes/path/to/image
DiskWarrior can be used to rebuild some corrupt disk images, depending on the nature of the corruption. Might be worth a shot if you have a copy.