PDA

View Full Version : Sparse image grows beyond actual data?


jamart
07-29-2005, 06:09 PM
I have been using SuperDuper to backup to sparse images created with Disk Utility to potentially expand to the full size of the original volume. For my needs, I like this approach better than Retrospect.

I recently noticed that the sparse image continually expands with each backup to far beyond the actual data written into it. Aparently the new/changed files is written and then the old files are deleted but the disk image does not release the empty space.

Is there a way to retrieve the disk space being retained without data by the sparseimage?

Thanks

John

dnanian
07-29-2005, 06:15 PM
You can potentially recover unused space in the image using hdiutil and the "compact" option. You have to do this in the Terminal.

The syntax would be:

hdiutil compact image-file

So, if your image is called "My Happy Image.sparseimage" and it's stored on your desktop, you'd use:

hdiutil compact ~/Desktop/My\ Happy\ Image.sparseimage

(the backslashes escape the spaces, the "~" means "My Home Folder").

You can also just type:

hdiutil compact

(include a space at the end)

and then drag the image file into the Terminal -- OSX will automatically put the path in place for you.

jamart
07-29-2005, 06:46 PM
Thanks Dave,

That worked very well.
John

dnanian
07-29-2005, 09:17 PM
Great: glad to hear it!

Bartmart
09-27-2005, 03:22 PM
I'm having the same troubles with sparse image sizes and after following your instructions to compact I get an error in Terminal saying, "hdiutil:compact failed - internal error".

I'm not a wizbang with Terminal. Any ideas?

Thanks,

Wayne

dnanian
09-27-2005, 03:27 PM
Sounds like it doesn't want to compact, Wayne... the image frameworks can be buggy, unfortunately, and you might have hit one of the situations where those bugs are exposed.

Are you certain you gave it a good "path" when you specified the location of the image?

Bartmart
09-27-2005, 04:35 PM
Hi Dave,

Found an apple script at: <http://www.macosxhints.com/article.php?story=20041207153823222>.

Seems to work if I drag the image to the app as stated.

thanx,

Wayne

dnanian
09-27-2005, 04:57 PM
Ah, good. So the path must have been mis-specified. Glad you've got it working.

edoates
10-08-2005, 05:44 PM
I got tired of checking the size of my sparse images and manually compacting them with hdiutil. So, I added the script fragment below to the end of the "daily backup applescript" which I had already modified for my specific volumes:

tell application "Finder"
activate
eject disk "Music Backups"
end tell
activate
display dialog "Awaiting dismount of Music Backups" buttons {"OK"} giving up after 5 default button 1
-- compact the sparse image to prevent unregulated growth
do shell script "hdiutil compact " & "\"/Volumes/Eds Office Backups/Music Backups.sparseimage\""
activate
display dialog "Music Backup Complete" buttons {"OK"} giving up after 30 default button 1

The "activate" verbs cause the script to become the top application so the dialogs show up (for testing, mostly); the dialogs are all for information and time out. I wait 5 seconds for the dismount to occur: always enough time unless the volume cannot be dismounted for some reason. hdiutil will not compact a mounted sparse image.

Hope you find this useful.

Ed

dnanian
10-08-2005, 05:49 PM
Nice work, Ed. Thanks!