Home > System >
Defragmenting Disks

This comparison has been updated for Windows Vista and moved to our new website Mac vs. Windows

The first time you put data on a freshly formatted disk, all the data is laid out together in nice contiguous blocks. However, over time, as the disk gets used (and files are written to and removed), files become fragmented and are stored in discontiguous locations. The disk has to work harder to retrieve files, potentially slowing the overall performance of your computer. This can be can a problem for tasks like video or audio capture, where the disk must keep up with a high-bandwidth data feed.

Defragmenting a disk forces all the fragmented parts of a file to be written again into contiguous blocks speeding up retrieval and reducing access times. Both Mac OS X and Windows XP offer ways to optimize against disk defragmentation.


If you need laptop screen repair, our smart technicians are experts in laptop repair and will fix or replace your broken screen and laptop battery too.


Mac OS X:

OS X offers no manual method for a user defragment their disks. However, OS X has implemented five methods of dealing with fragmentation and hard drive IO performance. Here's a quote from the Apple support article About disk optimization with Mac OS X regarding this matter this matter:

You probably won't need to optimize at all if you use Mac OS X. Here's why:
  • Hard disk capacity is generally much greater now than a few years ago. With more free space available, the file system doesn't need to fill up every "nook and cranny." Mac OS Extended formatting (HFS Plus) avoids reusing space from deleted files as much as possible, to avoid prematurely filling small areas of recently-freed space.
  • Mac OS X 10.2 and later includes delayed allocation for Mac OS X Extended-formatted volumes. This allows a number of small allocations to be combined into a single large allocation in one area of the disk.
  • Fragmentation was often caused by continually appending data to existing files, especially with resource forks. With faster hard drives and better caching, as well as the new application packaging format, many applications simply rewrite the entire file each time. Mac OS X 10.3 Panther can also automatically defragment such slow-growing files. This process is sometimes known as "Hot-File-Adaptive-Clustering."
  • Aggressive read-ahead and write-behind caching means that minor fragmentation has less effect on perceived system performance.

While OS X's disk optimizations are impressive and help can reduce fragmentation while increasing access times to files, it has some limitations:

  • Only files smaller than 20MB will be defragmented on-the-fly
  • These disk optimization methods only work on HFS+ formatted volumes that have journaling turned on
Checking how fragmented an HFS+ disk really is...

OS X provides no built-in way to check how fragmented an HFS+ formatted disk really is, but there is an alternative. Download hfs-debug to your desktop and type this at the command line:

cd ~/Desktop chmod 755 hfsdebug-1.12 sudo /Users/<user name>/Desktop/hfsdebug-1.12 -f -t 5

The last two lines will give you the amount and percentage of unfragmented files on your system.

Windows XP:

According to the Microsoft article Benchmarking on Windows XP (under Disk Efficiency Optimizations), XP has some automatic methods to reduce fragmentation:

If deemed necessary, Windows XP will adjust the file layout at three day intervals. By placing files that are referenced together near each other on the disk, and towards the more dense outer edge of the disk, seek distances are reduced which results in shorter seek times and improved performance. The performance benefit of placing files becomes increasing important as the size of the disk increases.

The files moved for more efficient layout are also kept contiguous. Windows XP does not intentionally fragment files as was done by some earlier versions of Windows.

Even so, Microsoft still recommends that users defragment their drives on a periodic basis. That's why XP comes bundled with a utility to defrag your disks called Disk Defragmenter. You can launch Disk Defragmenter from the Microsoft Management Console under 'Disk Defragmenter'. It does what the name says...defragments the files on your disk.

maintenance_defrag1_xp.gif
XP's Disk Defragmenter utility

A nice feature of Disk Defragmenter is its "analyze" option which analyzes the current level of fragmentation of a disk. Depending on the size of a disk and and number of files stored on it, a defragment process can potentially take hours to perform. Clicking the 'Analyze' button will quickly analyze your disk and notify you whether or not defragmentation is necessary. If not, you don't have to waste any time defragmenting the disk when doing so won't provide any significant performance gains anyway.

I defragmented my hard drive, and once it was done, Disk Defragmenter notified me that it was unable to defragment some files, giving me the option of seeing those files in a report.

maintenance_defrag2_xp.gif
XP's Disk Defragmenter Report

XP users can use XP's Scheduled Task Wizard to automatically launch Disk Defragmenter at a scheduled time and defragment the drive of your choice. The Microsoft article Maintaining Your Windows XP-based PC explains how to do this in more detail.


OS X's on-the-fly defragmentation of files smaller than 20MB and other disk optimization methods help reduce fragmentation on HFS+ formatted volumes, but it is still limited by the fact that users can't manually defragment a volume or even analyze the level of available fragmentation. While XP does offer some auto-defragment abilities, it is not enough as Microsoft still recommends manually defragmenting disks a regular basis. XP users do still have the advantage of being able to manually run a complete defragment of their disks.

OS X:

  • Hot-File-Adaptive-Clustering defragments files smaller than 20MB and places frequently used files on the faster portion of a hard disk
  • Delayed allocation allows a number of small allocations to be combined into a single large allocation in one area of the disk.
  • Aggressive read-ahead and write-behind caching reduces the impact associated with minor fragmentation
  • HFS+ avoids reusing space from deleted files as much as possible, to avoid prematurely filling small areas of recently-freed space, thereby reducing the risk of fragmentation.
  • Automatic file defragmentation only works for files under 20MB which offers no easy way to defragment larger files
  • OS X's above disk optimization methods only work for volumes that are formatted in HFS+ and have journaling turned on
  • No manual tool to report on % of disk fragmentation or defragment a disk

XP:

  • Every three days XP places frequently used files on the faster portion of a hard disk (those files are kept contiguous)
  • XP comes with Disk Defragmenter that can defragments all files, even those over 20MB
  • Provides analysis tools to view the % of fragmentation on a disk
  • Can defragment NTFS as well as FAT32 formatted disks
  • Can automatically schedule Disk Defragmenter to defragment your disks
  • XP requires at least 15% of free space available on the disk being defragmented

Mac OS X: 5
Windows XP: 7