Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

When a 'corrupt' disk image file really isn't corrupt System
I recently ran into a problem trying to open a downloaded .dmg (disk image) file: I kept getting a corrupt dmg file message when trying to open it. I downloaded it from several other locations, but the file still refused to open. I checked with a friend of mine on another Mac OS X system, and he downloaded and opened the dmg file with no problem. We compared md5sums of the file, and they were identical.

When I tried dragging the file into Disk Utility's left section, and then doing a verify on the dmg file, I'd get a Verify volume failed with error Invalid request (-9998) message. If I did a hdutil attach filename.dmg, it would give the following error:
Initializing...
Verifying...
...[trimmed]...
Verification completed...
calculated CRC32 $ABCDEF12, expected   CRC32 $00000000
Finishing...
hdiutil: attach failed - corrupt image
Note the expected CRC32 checksum was zero (the calculated value was an eight-digit hex, represented here by the simple ABCDEF12 string), which is certainly unlikely. We found the problem when both my friend and I ran hdutil imageinfo filename.dmg | grep Format. On my machine, I saw:
Format Description: UDIF read-only compressed
Format: UDCO
On my friend's Mac, he saw:
Format: UDBZ
Format Description: UDIF read-only compressed (bzip2)
It turns out the DMG file was compressed with bzip2 encoding, which can only be seen/decoded by Mac OS X 10.4+ machines -- like my friend's 10.4.8 system. Mine, being 10.3.9, could only detect that the DMG file was compressed, tried decoding it using ADC decompression, and failed. The moral of the story is twofold:
  1. Developers: Don't use bzip2 encoded dmg files for software intended for systems that include ones prior to 10.4.
  2. Non-10.4 users: Realize there is a DMG file encoding out there that may be incompatible with your system.
If someone can think of a nice way for a non-10.4 user to detect a bzip2 compressed dmg file vs. a corrupt dmg file, I'd certainly appreciate hearing about it!

[robg adds: If you have Fink or MacPorts installed, both have bzip2 as an available install.]
    •    
  • Currently 2.67 / 5
  You rated: 2 / 5 (6 votes cast)
 
[41,912 views]  

When a 'corrupt' disk image file really isn't corrupt | 6 comments | Create New Account
Click here to return to the 'When a 'corrupt' disk image file really isn't corrupt' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
When a 'corrupt' disk image file really isn't corrupt
Authored by: mantrid on Dec 12, '06 09:02:52AM

I'll definitely keep this information in mind...

btw, it's 'hdiutil', not 'hdutil' (obviously just a typo, otherwise there wouldn't have been any output from the "attach" or "imageinfo" subcommands).



[ Reply to This | # ]
When a 'corrupt' disk image file really isn't corrupt
Authored by: rspress on Dec 12, '06 09:32:45AM

Not the same problem but this may help a few users out there. Once in a blue moon I will download a file which should be an installer, it could be any kind of file however, and when I click on it it usually opens in script editor.

Often this files are named like "Worlds Greatest program 1" Changing them to "Worlds Greatest program 1.0" will usually make the program work. Sometimes just adding any dot and number will work. You will be asked if you want to add the extension, just say yes. I don't know why this happens but the fix is easy.



[ Reply to This | # ]
When a 'corrupt' disk image file really isn't corrupt
Authored by: mantrid on Dec 12, '06 09:51:57AM
I just checked on a computer running Panther, and it has 'bunzip2' installed as a part of the BSD.pkg - I think the BSD subsystem was included in the standard install and would normally have been installed unless explicitly excluded. So if attempting to open a disk image in 10.3 gives a corrupt image error, use
file filename.dmg
and if the output indicates "bzip2 compressed data", then try something like
bunzip2 -k filename.dmg -c > bunzip2edfilename.dmg
to see if it can be converted to something that can be opened normally. I get some "trailing garbage" error during the process, but the output file seems to work ok.

[ Reply to This | # ]
Doesn't work
Authored by: boredzo on Dec 12, '06 01:57:09PM
hdiutil create -format UDBZ -srcdir Interfaces\ for\ Programmers -volname Interfaces\ for\ Programmers Interfaces\ for\ Programmers.dmg
..........
created: /Volumes/RAM Disk/Interfaces for Programmers.dmg
___
bunzip2 < Interfaces\ for\ Programmers.dmg > Interfaces\ for\ Programmers-bunzippped.dmg
bunzip2: (stdin) is not a bzip2 file.


[ Reply to This | # ]
Doesn't (always) work
Authored by: mantrid on Dec 12, '06 03:41:29PM

Some preliminary observations:
Disk images created directly using hdiutil create -format UDBZ don't bunzip properly.
Those converted to UDBZ (originally created using "Disk Utility" or hdiutil without specifying a format) seem to work after bunzip2, but only using Panther's bunzip2 - Tiger's bunzip2 doesn't unzip them properly.

Anyone have any ideas to account for the differences in the UDBZ images created by the two methods, and the different behaviours of bunzip2 under 10.3 and 10.4?



[ Reply to This | # ]
Third bit of advice
Authored by: boredzo on Dec 12, '06 02:00:30PM

Developers: When you do make a UDBZ image, put "Requires OS X 10.4 or later" immediately under your download link/button. Leave no doubt as to the minimum requirement of your app.



[ Reply to This | # ]