Archives

Creative Commons License
This blog is licensed under a Creative Commons License.

Defragmentation and disk images

| No Comments | No TrackBacks

There has been a small debate among some Mac users about whether defragmenting your disks is necessary for the smooth operation of OS X. I’ve always been in the camp of those who do it regularly, because I’ve seen what my disk ends up looking like after a few weeks of not doing it (and how pretty the graph looks afterwards). It could all be psychological, but I find the progress bar rather hypnotizing, and my wife has been known to find me staring at it for hours on end. Ok, very psychological.

Well, I’ve found one circumstance where defragmentation is definitively helpful: compressing sparse disk images.

I have a habit of creating encrypted disk images for every client I work for. A lot happens in those images, which tend to grow and shrink quite a bit. OS X has a command to squeeze out the unused space, which looks like this:

$ hdiutil compact DiskImage.sparseimage

I just ran this command on one of my work images, and it reported a savings of 786 Mb out of 3 Gb. Just for interest’s sake, I ran iDefrag on the same volume, which eliminated the small amount of fragmentation that had built up, and compacted the files down toward the beginning of the image.

Running hdiutil compact on the same disk image again resulted in a further savings of 518 Mb! Given that the image itself is now 1.4 Gb, that’s about a 30% further reduction.

So, if you’re like me and you use lots of virtual disk images – and you’ve always wondered if defragmentation tools were worth anything at all – here’s one reason to consider it.

No TrackBacks

TrackBack URL: http://www.newartisans.com/mt/mt-tb.cgi/17

Leave a comment

About this Entry

This page contains a single entry by John Wiegley published on March 20, 2008 12:17 AM.

A Ledger success story was the previous entry in this blog.

Script of the week: linkdups is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Recent Comments

  • Przemek: Great article, indeed. @Kyle: I’m a git newbie and SVN read more
  • Kyle Bennett: John, thanks for the work you put into this. Since read more
  • Sigi: You deserve a lot of praise for this article. It’s read more
  • Tony: this is an excellent write up; I’ve been reading much read more
  • John Wiegley: Thanks for letting me know, I’ll try to rectify the read more
  • Rudi Farkas: Hello John Above, you say “The date at the front read more
  • Uwe Kleine-König: Hi John, a comment to the paragraph about reset: $ read more
  • Leonardo Boiko: Thank you very much for this; as a bottom-up guy read more
  • John Wiegley: Thanks for the update. I’ll include this among the next read more
  • Laust Rud: Excellent writing, thanks! The url for the git-core tutorial has read more
OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.25