All Articles

Shrinking sparse bundle images

A sparse bundle image in Mac OS X will grow as you add files to it but never shrink if you remove files inside of it. To reclaim the disk space, you must run the following command :

hdiutil compact path/to/sparsebundle

If your account is protected with FileVault, this is done automatically for you when you logout of your account.

Published Nov 30, 2008

I am a computer scientist specializing in building machine learning powered products. I’m currently a machine learning developer at Local Logic.

5 thoughts on "Shrinking sparse bundle images"

Adam Backstrom

Commented 2009-08-14 08:30:24

Thanks for that, I've looked for this option occasionally but never found it before your post. Just reclaimed 10% of my image size.


Commented 2010-06-06 04:42:53

Great tip. Worked like a charm.

John Warlow

Commented 2010-03-08 07:55:04

Thanks for that - my MacBook Pro ran out of disk space because of my sparsefile - busy shrinking it now thanks to your info!


Commented 2011-01-16 05:02:05

Excellent! Just recovered 75% of a 30GB image, and in about 3 seconds. Thanks!


Commented 2013-04-24 14:24:55

This worked for me as well, very useful. Note that if you're on a laptop that is not plugged in, you may get this ridiculously cryptic message:

<code>hdiutil: compact failed - Function not implemented</code>

Adding "-batteryallowed" to the invocation should fix that.