When a 'corrupt' disk image file really isn't corrupt

Dec 12, '06 07:30:00AM

Contributed by: rdm

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

Comments (6)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20061209133451185