This is a quick fix to restore t he special behavior of a .sparsebundle directory in Finder.
While experimenting with TimeMachine’s unsupported network backup capabilities I rsync’d my
host_blah.sparsebundle from one drive to another (without using
-E, more on that later). The result was that my
.sparsebundle now appeared in the Finder just as a normal folder, instead of with a disk image icon. This also meant that I couldn’t open the image in DiskUtility any more.
The fix is to use SetFile to restore the “Bundle” attribute.
$ /Developer/Tools/SetFile -a B host_blah.sparsebundle
The first time I mounted it afterwards I had to wait for fsck_hfs to complete, since the “com.apple.diskimages.fsck” attribute had been cleared, but otherwise it’s back to it’s old self.
I also learned that in order to avoid this (and many other much nastier problems) you should use the
-E flag for rsync under Mac OS. This correctly copies over the resource forks, extended attributes and meta-data also.
(This item is probably old-hat to many Mac users, since Bundles have been in the Finder since OS 9. But it took me a couple of days of searching and experimentation, so I figure it could use some better visibility.)