Cool command of the week

I’ve been using sparse disk images under Mac OS X for a while, as they can expand to only occupy the necessary space as you copy information into them. For the first time this week I needed to erase some of the contents of one and then shrink the image. The magic command for doing this is

hdiutil compact blah.sparseimage

According to the man page it’s not guaranteed to shrink the image, and it may only work for disk images containing HFS+ filesystems. but it worked ok for me.

Leave a Reply

Your email address will not be published. Required fields are marked *