I am trying to compact a TimeMachine sparsebundle (to reclaim space) using

sudo hdiutil compact /Volumes/TimeMachine/MyMac.sparsebundle

and the error message that I receive is:

hdiutil: compact failed - internal error

When I look in the System Log, I see the following message:

diskimages-helper: cannot compact filesystem because it was not unmounted cleanly.

I am running on a MacBook Air (13-inch, early 2014) on Mavericks and the sparsebundle is located on an Iomega StorCenter ix2-dl NAS with 2TB running RAID 1.

When I look via Finder at my Iomega NAS share, I see that it is "mounted" (with that eject icon shown next to the share name). But if I eject the drive (to dismount it), then Terminal can no longer see the Time Machine volume when I use the hdiutil command.

UPDATE: I've tried the techniques on Garth Gillespie's blog and no issues were reported. I also used Disk Utility and it ran cleanly (no repairs).

Any help would be most appreciated.



Update: I was running LenovoEMC's Storage Manager in another window and had a webpage opened to the ix2-dl drive.

After closing these applications, I did a full shutdown and restarted.

This time, when I tried hdiutil compact, it worked.

Just putting this answer here for anyone who runs into a similar issue. Most of the web pages that I found during searching were related to problems with sparsebundles that used FileVault.


Same issue here, I had to mount/unmount the sparsebundle volume before running hdiutil to compact it.


Whilst not directly answering the question a related issue led me here, and maybe others might find this useful, but when I attempted to compact and image I got the following error:

hdiutil: compact failed - Function not implemented

It turns out that hdiutil compact function is soft-disabled when the machine is running on battery power resulting in the above error. To override this behaviour add the following argument after the image name -batteryallowed when calling compact.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .