Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I don't see any application to defragment my Mac (running OS X).

Is defragmenting not necessary for Mac OS X? If so, why not?

share|improve this question
3  
i know i am late to the party but there is such a program macupdate.com/info.php/id/16819/idefrag –  bronzebeard Dec 1 '10 at 6:58
add comment

5 Answers 5

up vote 43 down vote accepted

It's not necessary. For more details than you could possibly want, read Fragmentation in HFS Plus Volumes by Amit Singh (author of Mac OS X Internals: A Systems Approach).

share|improve this answer
4  
1  
Amit Singh "… sampled too few a volume to generalize my "results" …" — that's much less detail than I could possibly want. –  Graham Perrin Aug 18 '11 at 7:17
    
@Graham - is that the point at which you stopped reading? There are a few other sentences in that (lengthy) essay, also. –  Dori Aug 18 '11 at 7:23
    
@Dori I read the page in its entirety long ago. A few months ago I began using fileXray, which the author describes as better than hfsdebug (more on the relationship between Amit Singh and fileXray). Please be patient for a more detailed answer to this question. In the meantime you'll find discussion of defragmentation in one of my answers to a different question. –  Graham Perrin Aug 18 '11 at 7:43
    
Happy to discuss in Ask Different Chat — maybe my original comment came across the wrong way (if so, sorry) … –  Graham Perrin Aug 18 '11 at 9:55
add comment

HFS, the filesystem Mac OS X uses (technically HFS+) has a number of built-in measures that reduce fragmentation of the drive. First, it uses extent-based allocation, which is just a fancy way of saying that it writes multiple contiguous blocks of data a time (and therefore inherently has less fragmentation of data). Second, it uses delayed allocation, meaning that disks writes are "queued" and written to the drive as a group (again, inherently less fragmentation). On top of that, Mac OS X does on the fly defragmentation of files.

The long and short is that fragmentation isn't really an issue for Macs, which is why you don't see a program to defragment drives in Mac OS X.

As a side note, there are commercial programs that will defragment drives in OS X, but this is essentially snake-oil. There might be some small level of fragmentation on your drive, and these apps will surely take care of that. But, it's 100% unnecessary, and you're unlikely to see any benefit.

share|improve this answer
7  
To be specific, Mac OS X does on-the-fly defragmentation of file under 20 megabytes. If you're doing stuff with large files (i.e. video editing), you could end up with fragmentation issues. –  CajunLuke Feb 5 '11 at 15:51
4  
The statement "100% unnecessary" is exaggeration. I recently found it necessary. –  Graham Perrin Aug 18 '11 at 7:26
    
Defragmentation is useful when you need to re-partition a volume. (There are 3rd party utilities for this as well.) –  Andrew Vit Sep 7 '11 at 2:27
    
@andrewVit I don't know how HFS[+] works, but some file systems purposely move files away from other files to prevent fragmentation, so defragmenting might not help to consolidate data for a resize, since defragmented files still remain far apart. –  Hawken Dec 10 '12 at 2:05
add comment

Generally speaking, you do not need to defrag HFS+. While it is possible to fragment it, the implementation in the OS X kernel includes a number of features that tend to limit fragmentation, including deferred block allocation and hot banding. Unless you do something really odd (constantly keep the drive over 99% full while doing lots of reads and deletes) it is very hard to significantly fragment the drive.

The only time it is generally worthwhile to defrag an OS X drive is when you are trying to do an LVM operation (like shrink a partition for bootcamp), and the builtin tools fail. The reason is that those failures are largely caused by some core structure of the volume (Like the extents or catalog file) existing in blocks outside the target layout. Technically those are files, but because they are used to store volume metadata the builtin file move code has trouble moving them on a live (mounted) partition, but defrag utilities that work on the disk offline can just move them to the beginning of the partition, which allows the volume resizer to work.

So, while defrag utils are generally not worthwhile, they aren't snake oil, just very specialized tools.

share|improve this answer
1  
With more than ten percent free space it's easier than this answer suggests (not very hard) to find fragmentation that can contribute to real problems. –  Graham Perrin Aug 18 '11 at 7:23
add comment

Most people will tell you Macs don't suffer from disk fragmentation, citing technical arguments most people don't understand.

It's somewhat true: since there's nothing you can do about it without spending $20 on something that might not improve the performance of your computer at all, you could instead focus on other maintenance tasks and just buy a shiny new mac (or reinstall) when the old one gets too slow.

But: An important prerequisite for not caring about disk fragmentation is always keeping some free space on your disk (I couldn't find any recommendation not pulled out of thin air, but 20% is often mentioned).

And to keep the facts straight:

  • There are features in Mac OS X designed to prevent some of fragmentation.
  • Apple believes these features are enough to spare the majority of their users from caring about fragmentation issues, but also says you ''might'' benefit from defragmenting in some cases (e.g. "If your disks are almost full, and you often modify or create large files")
  • There's no built-in or free and popular defragmenter utility for Mac OS X (although there are commercial ones)
  • Some people do have issues caused by fragmentation (1, 2)
  • There's no easy way to tell if your specific problem is caused by fragmentation.

BTW (@Dori's answer), the cited Fragmentation in HFS Plus Volumes explicitly says this:

Note that I do not intend to make any claims regarding the fragmentation-resistance of HFS+. I have sampled too few a volume to generalize my "results".

P.S. I know that web browsers (the field I'm interested in) are at least sometimes are affected by fragmentation (ex.: mozilla, chrome). I myself had an issue similar to the one described in mozillla's issue tracker.

share|improve this answer
add comment

No, it doesn't. Mac OS X does it itself for files over 20MB, and for SSDs it doesn't matter at all.

share|improve this answer
2  
It will likely still matter for SSDs since I assume requesting multiple extents is still more resource intensive than just one; also there is still the B-Tree lookup for files with more than 8 extents. –  Hawken Dec 10 '12 at 2:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.