How to Defrag Your Hard Drive

By: Peter May
Hard drive
Hard drives have more moving parts than most of your computer.
Howard Kingsnorth/Photodisc/Getty Images

A computer has very few moving parts to wear down, break down or slow down. The obvious exception is the hard drive. It has many moving parts that must operate at near perfection to fetch and store data efficiently. This fact makes the hard drive the prime suspect when processes seem to be lagging. If the hard drive takes too long to provide the data a program needs, processing speed can quickly change from instant to "hurry up and wait" status.

So what do you do about it? Disk defragmentation has long been the go-to cure for a sluggish computer. Until recently, if you asked most computer geeks how to speed things up, they would tell you to try a "defrag" before just about anything else. Today's faster, larger and more efficient hard drives make defragmentation a less effective solution for slow computers. In most cases, however, a defrag remains a relatively simple way to boost your system's speed and efficiency.


­In this article, we'll explore the defragmentation process to learn what it is, how it works and the potential benefits. We'll also explore advances in hard drive and operating system technologies and how they affect the defragmentation process.

Windows File Management: Losing the FAT

Basically, a hard drive consists of a spinning disk over which a read/write head is suspended on an arm. The file management system divides the disk into rings, and then divides each ring into allocation units (or clusters). The size of these units varies depending on the size of the drive. In most cases, the operating system will automatically determine the best cluster size. Program and data files are divided into allocation units before being written to, or read from, the disk.

When a specific file is needed, the head moves to the assigned ring and waits for the spinning motion to bring the required allocation units to it. If the allocation units for the file are stored in a contiguous section of a ring, things can progress quickly. However, if the file is spread over multiple locations, things can slow down considerably. In some cases, the pieces of a single file can be in thousands of locations on the disk. This situation is called fragmentation.


In the days of DOS, Microsoft created a file management system called FAT (File Allocation Table). By today's standards, FAT was pretty thin when it came to storage limits and capabilities. Early versions of FAT (FAT12 and FAT16) limited file size to 2 GB. Volumes could be no more than 4 GB and file names could contain no more than eight characters.

A later version, FAT 32, expanded the limits and provided additional capabilities. Volumes could be as large as 32 GB and files could extend to a whopping 4 GB. FAT 32 was the file management system of choice for Windows 95 and 98. As applications grew more complex and files grew in size, a more flexible system was an absolute must.

When Microsoft introduced Windows 2000, it also created a new file management system called NTFS (New Technology File System). All versions of Windows XP and Vista use the NTFS system. According to Microsoft, the maximum volume size for NTFS is 2 terabytes and individual files can be as large as the entire volume. In addition to working with larger files, NTFS includes many other improvements, such as more powerful file security, enhanced error recovery and a more efficient file storage structure, which makes searches faster.

The NTFS file management system is one reason disk defragmentation may not provide the improved processing speed it once did, but it also helps to keep the system from slowing down in the first place.

So what happens when a disk becomes fragmented? On the next page, we'll take a look.


Fragmentation: Your Ducks are No Longer in a Row

Hard drive defrag illustration
(c) 2009 HowStuffWorks

Disks become fragmented as files are written and deleted. Fragmentation tends to get worse over time. When you install programs on a new disk, the allocation units are written to a single, contiguous area. As you delete existing files and write new ones, free allocation units begin to appear all over the disk. Before you know it, pieces of the file for your new computer game are spread around like seeds in the wind, causing the drive head to dart all over the disk like a game of "Whack-a-Mole." Not only does this slow down the file transfer process, it also causes additional wear and tear on hard disk components, potentially shortening the life of the drive.

­This simple illustration shows how fragmentation occurs. When you first load programs and copy data to your disk, the allocation units (in this case, ducks) are written one after another. All neat and tidy. Over time, however, writing, deleting and rewriting files to the disk leaves empty space in lots of places. The more deleting and rewriting the hard drive does, the more spread out the ducks get.


Fragmentation is unavoidable, although newer hard drives are designed to reduce its effects. The best way to avoid spreading allocation units all over the disk is to use a high capacity hard drive. If the amount of free space available remains high, files are more likely to be saved in contiguous areas of the disk. In most cases, a drive that is at less than 70 percent of its capacity will not benefit significantly from the defragmentation process. This is particularly true with newer, high-speed drives. These drives spin at a higher RPM and have faster read and write capabilities. Also, they often have larger buffers in which to combine file segments before sending a large file to the operating system.

Although technology and the lower cost of drive capacity have significantly reduced the amount and the effect of fragmentation, fragmentation still exists. Today's drives are larger, but so are today's files. Once you've loaded a disk with music, games, applications and even a couple of full-length movies, fragmentation can still be an issue.


Windows Defrag

Windows XP disk defrag screenshot
The Windows XP defragmentation program provides a visual display of the reduction in fragmented files. Note that there are virtually no red lines in the bottom representation.
­Screenshot by Peter May­




­Defragmenting your hard drive is relatively simple, but can use significant system resources, so it's better to do it when the computer isn't in use. Every version of Windows has a built-in defragmentation utility. These programs are actually subsets of third-party applications, such as Executive Software's Diskeeper. The complete Diskeeper software package includes additional capabilities, such as scanning one drive while defragmenting another. For most users, however, the Windows utility has all of the functionality required to get the job done.

Using the Windows onboard defragmentation utility is simple. Here's how to launch the program:

In Windows XP (any variety):

  • Open My Computer.
  • Right-click the local disk volume you wish to defragment.
  • Click Properties.
  • On the Tools tab, click Defragment Now.
  • Click Defragment.

­There are several limitations to the defrag function in XP. For instance, it's only possible to defrag one volume at a time. The utility does not include a scheduling function, however, it is possible to use the Windows Scheduler utility to run Defrag from the command line. This is a somewhat complicated process and it's really only appropriate for advanced users and IT professionals. Information is available on

Windows Vista disk defrag screenshot
­­The Defrag utility in Widows Vista makes it easy to schedule and control the process.
­Screenshot by Peter May


­In Windows Vista, type "defrag" into the start ­menu search box and press­ Enter. Note that you must be logged in as an administrator to run the Defrag utility.­

The Vista Defrag utility is easier to use and offers some significant advantages over the XP version. When you launch the application using the above command, you'll be presented with a screen that allows you to control many aspects of the defragmentation process. The most useful of these is the ability to schedule defragmentation to run at a time that is convenient for you.


Defrag for Other Operating Systems

As you might suspect, operating systems such as Mac OS and Linux use different file management systems and have different requirements in terms of defragmentation.

The operating system for Apple's Macintosh computers doesn't include a built-in defragmentation application, although third-party utilities are available. According to Apple, Mac OS is designed to reduce fragmentation by writing new data to larger open areas of the disk. Smaller segments, such as those left over when a file is deleted, are only used when necessary. Macintosh software developers are taking advantage of faster hard drives to eliminate fragmentation by always writing complete files to the disk rather than adding data to existing files. Mac OS (10.3 Panther) and later versions defragment files on an ongoing basis, making batch defragmentation unnecessary.


As for Linux, there are two major reasons defragging is less of an issue. First, Linux doesn't store files in order, so there's often room to append data to an existing file in its current location. Linux also places the disk reading head at the center of the platter. Unless a file is fragmented to opposite sides of the disk, the head can reach multiple clusters quickly. Linux isn't, however, immune to fragmentation, particularly when a disk nears its maximum capacity. The bad news is, when the disk is nearly full (more than 75 percent of space used), it becomes more difficult for a defrag utility to operate effectively. So, by the time a Linux disk becomes fragmented enough to slow things down, it's difficult to solve the problem. For many users, this paradox provides a reason to defragment Linux hard drives on an ongoing basis.

Third-party defrag applications are available for all operating systems. In addition to defragmentation, many of these utilities provide additional capabilities, such as:

  • Simplified scheduling
  • Background defragmentation
  • File storage optimization/fragmentation prevention
  • Optimization of other system elements such as the registry
  • Permanent removal of sensitive files
  • Elimination of cookies and temporary Internet files

But what about non-mechanical disk technologies such as solid state or thumb drives? Some computer manufacturers are already putting them in laptops and other electronic devices. Do those need to be defragged, too?

The reason defragmenting a hard drive can increase computing speed is because the drive uses moving parts (the disk and drive head) to access data. A solid state drive has no moving parts, so retrieving any specific bit of data requires the same access time no matter where the file clusters are stored. In fact, some experts claim that defragmenting a solid state drive may actually be harmful. Solid state memory can be written and overwritten many times, but there is a limit. Each time data are written to a bit of memory, its lifespan is decreased slightly. Therefore, continuously defragmenting a thumb drive could hasten its demise with no real benefit.


Disk Defragmentation Tips

Given everything we've learned, is it worthwhile to defragment your hard drive? The answer is yes, but newer drive technology is likely to reduce the speed gains. With that in mind, here are a few suggestions regarding defragmentation:

  • Defrag early and fairly often. If you believe the best defense is a good offense, it's probably wise to set up a defragmentation schedule beginning when you've installed software on a new system. If you're running Windows Vista, this is simple. If not, you can use the Windows Scheduler to do the job. The defrag utility will do its best work when there's plenty of free space on the drive. This also allows key system files to be written to the disk in order. Most experts seem to feel defragmentation should be run no more than once a week, but no less than once per month.
  • Add more memory. It's not nearly as costly as it used to be and it will improve your computer's performance in virtually every way. In terms of disk storage, more memory enables the system to cache more data, reducing the effects of fragmentation.
  • Clean up and add disk capacity. As we've seen, a disk drive that's less than 50 percent full is less likely to be slowed by fragmentation. It's also easier to defragment. Given the vastly reduced cost of disk drives, adding more capacity is a quick and easy speed booster. Don't forget to delete unused files from your hard drive from time to time. The more free space there is, the faster your programs will run.
  • Replace old drives. If your disk drive is more than two or three years old, you could speed processing up considerably by replacing it with a new drive that is faster and offers enhanced file caching capabilities. As a bonus, when you copy your existing files to the new drive, they'll be defragmented automatically as an integral part of the process.

So, while new disk drive technology may reduce the benefits of defragmentation, it still pays to get your ducks in a row from time to time. For more on hard drives and related topics, take a spin over to the next page.



Lots More Information

Related HowStuffWorks Articles

More Great Links

  • Apple Software Support. "About disk optimization with Mac OS X. June 23, 2008. (April 2, 2009)
  • Hart-Davis, Guy. "Mastering Microsoft Windows Vista Home: Premium and Basic." John Wiley and Sons. 2007.
  • Microsoft TechNet Library. "Description of the New Command Line Defrag.exe Included with Windows XP." January 7, 2006. (March 24, 2009)
  • Microsoft TechNet Library. "Features of the Windows Vista hard disk defragmentation utility." October 7, 2007. (March 28, 2009)
  • Nichol, Alex. "FAT & NTFS File Systems in Windows XP." Sept. 1, 2002. (March 28, 2009)
  • Notenboom, Leo. "Should I defragment my USB Flash Drive." (March 27, 2009)
  • PC Review Computer News & Reviews." NTFS vs FAT32." (March 27, 2009)
  • Simpson, Alan. "Alan Simpson's Windows Vista Bible." John Wiley and Sons. 2007.
  • Yegulalp, Serdar. "Disk defragmentation: Performance-sapping bogeyman, or best practice?" Sept. 18, 2006. Disk Defragmentation Fast Guide. (March 28, 2009),289483,sid68_gci1215568,00.html