How do sparse bundles get corrupted and can they be fixed?

I am warming up to Mac OS X sparse disk image bundles: This is a virtual file system stored as a collection of small (up to 8MB) files in a folder. This way, you can have encrypted HFS+ volumes stored on FAT-formatted USB drives, or SMB network shares. And because the data is broken up into 8MB chunks, incremental backups work very well by just copying the updated fragments. No problem for rsync or Time Machine, even for encrypted data.

But even though this format seems to have been designed with compatibility with non-Mac tools and file systems in mind, it does not seem to work for example with Dropbox. Why is that? Is it just some meta data ("bundle flag?") that gets lost in transfer (and that I could manually put back in)?

The Internet is also full of horror stories of corrupted bundles on Apple's own Time Capsule network backup device.

How do these bundles get corrupted and what are my recovery options?


As far as I know, you can mount the .sparseimage, and run "Repair/Verify" in Disk Utility, like you could on any other disk....

And like any other disk, always try to "eject" or dismount before powering off or restarting the computer..

I have seen them get corrupted before, but not for a long time... I think it might have been a non-Snow Leopard issue. BTW, sparse "disks" are how Apple stores your "Home" folder when you use FileVault (which are gone in Lion, so don't go ecrypting your home folder, now... they just encrypt the whole disk)

My favorite command is the following, which shrinks the sparseimage down to the actual amount of data you have stored in it, no matter how large it had grown to by adding files which you have now deleted..

hdiutil compact /Macintosh\ HD/Path/to/Name\ of\ file.sparseimage

BTW, the backslashes ( \ ) are only required if you have spaces in your file pathname.