Why Defragment?
It is often asserted that defragmentation (or disk optimisation) is not a good idea on systems using Apple’s HFS+ filesystem. The main reasons given for this are:
- HFS+ is very much better at keeping files defragmented than other common filesystems.
- Advanced features of HFS+ can easily be disrupted by a defragmentation tool that does not support them, resulting in decreased performance.
- HFS+ includes its own defragmentation support.
- There is a risk associated with defragmentation.
While these arguments are certainly valid, they are not the whole story. iDefrag, unlike older defragmenters, does know about and support the advanced features of HFS+ such as the Hot Zone and the adaptive hot file clustering support introduced in Mac OS X 10.3. Not only does it avoid disrupting them, but it is capable of fixing disruption caused by other software.
Likewise, the built-in automatic defragmentation support in HFS+ is somewhat limited in scope; in order for it to trigger:
- The filesystem must be journaled.
- The file must be under 20MB in size.
- It must have at least eight fragments.
- It must not have been modified within the past minute.
- The system must have been up for at least three minutes.
- The file must not currently be in use by any program.
- A program must open the file.
Sensible arguments for occasional optimisation of your disk include:
- HFS+ is not very good at keeping free space contiguous, which can, in turn, lead to large files becoming very fragmented and can also cause problems for the virtual memory subsystem on Mac OS X.
- Older versions of the Mac OS are not themselves aware of the Hot Zone policy and may disrupt its performance.
- HFS+ uses B-Tree index files to hold information about the filesystem. If a large number of files are placed on a disk, the filesystem may have to enlarge these B-Tree structures; however, there is no built-in mechanism to shrink them again once the files are deleted, so the space taken up by these files has been lost.
- While HFS+ is good at keeping individual files defragmented, software updates may result in files that are components of the same piece of software being scattered across the disk, leading to increased start-up times both for Mac OS X itself and for applications software. This is a form of fragmentation that is typically overlooked.
- Defragmenting disk images can be helpful. It may allow them to be more heavily compressed, and it also prevents unnecessary seeking if they are burned to a CD/DVD (where seeks are especially expensive).
- Some specific usage patterns may cause fragmentation despite features of HFS+ that are designed to avoid it.
We do not recommend very frequent optimisation of your disk; optimisation can take a long time, particularly with larger disks, far outweighing the benefits that are likely to be obtained by (say) a weekly optimisation regime.
We also do not recommend defragmenting or optimising SSDs as a matter of course. Contrary to some claims on the Internet, defragmenting an SSD won’t damage it — concerns about Flash write cycles are typically overblown, and in any case are more of a problem for manufacturers than end-users — but it’s unlikely to result in a worthwhile performance gain when compared to the time you’ll spend defragmenting.