thoughton:digitallife banner
about downloads imagery work
-- How To... --

Compressing sparse disk images


After recently getting a bargain on a no-name 256MB USB key drive I wanted to store an encrypted password-protected disk image on it. However after playing around with Disk Utility for a while, I discovered that although a 'sparse' disk image sounded like what I wanted, it actually wasn't! The problem with sparse disk images is that although they aren't fixed in size and grow as you add more stuff to them (which is what I wanted), when you delete the same stuff they do not automatically shrink! Technically this is understandable since the 'deleted' data hasn't been zeroed and is actually still on the 'disk', however it wasn't what I was hoping for.


So after much fruitless searching, I appended a question onto this existing Apple discussion in the hope for an answer. However after re-reading the discussion and having a look at the hdiutil man pages I eventually managed to refine my search enough to turn up an article on MacOSXHints which had exactly the solution I needed!

The answer is simple! Simply fire up the terminal, and type:

hdiutil compact (with a space at the end)

and then drag and drop your sparse disk image file into the terminal window. Note that you need to type a space after the word 'compact', before you drag the image icon to the terminal window.

Depending on the size of your sparse image the process will take a few seconds to a few minutes. Get info should now reveal that the image file no longer 'remembers' the size of the deleted files.

Note: when specifying the size of an encrypted sparse image in Disk Utility you are specifying the maximum size.


Posted on 4 September 2004, to How To... | Mac OS X

Related entries

Major Tiger bug destroys data - 15 May 2005
Password assistant - 22 July 2005
Never enough storage - 11 March 2004
Stop iphoto from importing images - 14 January 2005
Automatically copy Bluetoothed images into iPhoto - 14 January 2005
Drastically reduce mailbox disk usage - 12 July 2005
Flickr badge and XHTML validation - 13 July 2005
Great OS X apps - 14 November 2004
Nokia Collector software posted - 28 November 2004

Comments

There have been no comments posted to this entry.

Subscribe to comments

Enter your email address in the box below to receive an email notification whenever a new comment is posted to this entry.

Email address:

Post a comment










Remember personal info?


Click a smiley!
:) ;) 8) :| :(
:P :X :? :mad: :D
:o :cry: :shock: :blush: :roll:



Security code
Please enter this security number in the space below (this prevents automated responses).



Category icon Sponsors