View Single Post
  #3  
Old 01-05-2005, 04:13 AM
SpinUp SpinUp is offline
Registered User
 
Join Date: Dec 2004
Posts: 2
Shrinking Sparse Images

I use a sparse image to back up and recently noticed that the file size has been growing far beyond the size of the data on the disk image. The sparse image had max size of 7 GB and contained only 4.95 GB of data, but the file size was 6.45 GB!

That seemed unreasonable, so I decided to look into shrinking it. Reading from here,

http://www.hmug.org/man/1/hdiutil.html

I found the hdiutil command "compact", which can be used in the terminal as follows:

Code:
hdiutil compact imagename.sparseimage
This removes the parts of the image file that aren't being used in the volume. The process ran for a couple of minutes, and the file size of the sparse image was subsequently reduced to a more reasonable 5.3 GB. Note that the above link is just the man page for hdiutil in Panther, and has this to say on the subject of reliability:

Quote:
As of OS X 10.3, partially-updated SPARSE images are now properly handled such that they can be safely used for persistent storage. SPARSE images are not recommended for persistent storage on earlier versions of the operating system.
I was using sparse images for backup in Jaguar, when perhaps I shouldn't have been...
Reply With Quote