hdiutil compact failed - internal error 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.

Thanks.
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.