Maintaining Windows 2000 Peak Performance Through Defragmentation

By Michael Kessler

Microsoft Corporation

On This Page

Introduction Types of Fragmentation Analyzing Defragmentation Safe Defragmentation Windows 2000 Disk Defragmenter Summary Related Information

Introduction

It's essential that an operating system be able to maintain your disks at peak levels of reliability and performance. The Windows® 2000 operating system does this through a built-in system tool called Disk Defragmenter. Disk Defragmenter was developed through a collaborative effort between Microsoft Corporation and Executive Software International. Read on to learn more about disk fragmentation and defragmentation, and how Disk Defragmenter supports the maintenance of disk efficiency.

Types of Fragmentation

Fragmentation is caused by creating and deleting files and folders, installing new software, and downloading files from the Internet. Computers do not necessarily save an entire file or folder in a single space on a disk; they're saved in the first available space. After a large portion of a disk has been used, most of the subsequent files and folders are saved in pieces across the volume. (In this discussion the terms disk and volume are used interchangeably.) When you delete files or folders, the empty spaces left behind are filled in randomly as you store new ones. This is how fragmentation occurs. The more fragmented the volume is, the slower the computer's file input and output performance will be. There are two main types of disk fragmentation: file fragmentation and free space fragmentation.

File Fragmentation

A file with all its parts stored in one location on a disk is described as "contiguous." If a file is not contiguous, it's fragmented; broken into pieces that are scattered throughout the disk. All Windows NT® and Windows 2000 file types—File Allocation Table (FAT) and NTFS file system (NTFS)—are susceptible to fragmentation.

File fragmentation has a negative effect on disk performance because the disk head requires more time to move around to different points on the disk to read scattered file parts. This is a primary reason for the gradual degradation of system performance—and the specific cause of longer reads and extended reboots.

Free Space Fragmentation

A partially full disk contains unused space, known as free space. Ideally, this space would be available in a few contiguous portions of the disk. And while it's good to have free space, it's not good if it's fragmented. Free space fragmentation refers to file space that's broken into small pieces, rather than joined together. This type of fragmentation results in slowed performance because of the time it takes for the disk head to move to different points on the disk to find free space and then write the file. Fragmented free space also increases the possibility of file fragmentation; when a file is larger than the space it's being written to, the file fragments.

Analyzing Defragmentation

Defragmentation is the process of rewriting non-contiguous parts of a file to contiguous sectors on a disk for the purpose of increasing data access and retrieval speeds. Because FAT and NTFS disks can deteriorate and become badly fragmented over time, defragmentation is vital for optimal system performance.

Fragmentation Analysis Study

How fragmented can a system get? In June 1999 the American Business Research Corporation of Irvine, California performed a fragmentation analysis and found that, out of 100 corporate offices that were not using a defragmenter, 50 percent of the respondents had server files with 2,000 to 10,000 fragments—and another 33 percent had files that were fragmented into 10,333 to 95,000 pieces. In all cases the results were the same: Servers and workstations experienced a significant degradation in performance.

Good Housekeeping

Even a new computer system will experience disk fragmentation because loading the operating system results in both file and free space fragmentation. You can test this by loading the operating system onto a new machine, and then run the analysis function of Disk Defragmenter (explained below).

For the individual user, Disk Defragmenter should be run right after the operating system is loaded, and then manually at regular intervals thereafter. Deciding when to defragment your disk depends on the type of work you've been doing—keeping in mind that normal, day-to-day use of your computer will cause fragmentation. You should consider defragmenting after you've been compressing and decompressing files and after installing operating systems and applications. In general, consider defragmenting once a week for moderate to heavy use; less frequently for intermittent use.

You can use Disk Defragmenter to analyze disks before deciding whether or not to defragment them. After analyzing a disk, a dialog box tells you the percentage of fragmented files and folders on the volume and recommends a course of action. Analyze volumes regularly and defragment them when Disk Defragmenter recommends it.

You should perform disk analysis and defragmentation on a regular basis for all Windows 2000–based servers and workstations to ensure that disks are operating optimally.

Safe Defragmentation

During the developmental stages of Windows NT, defragmentation application programming interfaces (APIs) were developed and built into Windows NT to ensure that files could be moved safely—without data loss, system crashes, or corruption—while the operating system was running. In Windows 2000 these defragmentation APIs have been enhanced, tested and certified by Microsoft to make certain that files created using Windows 2000 can be defragmented without risk.

Disk Defragmenter In Action

To ensure against data loss, system crashes and file corruption, the Windows 2000 Disk Defragmenter interoperates with the file system and APIs.

Disk Defragmenter works to optimize your disks and keep them running efficiently by:

  1. Locating the fragments of each file throughout the disk.

  2. Copying them contiguously to a new location.

  3. Verifying that the copy is an exact duplicate of the original.

  4. Updating the Master File Table (MFT) so that the new file location is set.

  5. De-allocating the old location and reclassifying it as free space.

Points to Keep in Mind

  • It's the file system, not Disk Defragmenter, that takes care of all data movement.

  • The APIs do not support defragmentation of the MFT, the Paging File, FAT directories, or files open for exclusive use—for example, Windows registry.

  • NTFS directories can be defragmented in Windows 2000.

Key Elements in the Disk Defragmentation Process

To maintain the operating efficiency of a disk, several key elements need to be understood and managed: the Master File Table; the Paging File; the Hibernate File; and directories.

Master File Table

NTFS contains a file called the Master File Table (MFT). The MFT is an index file that maps everything stored on a disk. There is at least one entry in the MFT for every file on an NTFS disk, plus the MFT itself. Each entry in the MFT contains the following data: size; time and date stamps; security attributes; and data location.

Disk Defragmenter cannot defragment the MFT once it becomes fragmented. But, because the MFT is constantly being used to access all other files on the disk, it also gradually becomes fragmented, resulting in longer disk access times and diminished performance. NTFS minimizes this impact by reserving one-eighth of the total disk space for the exclusive use of the MFT. This area of the disk—known as the MFT Zone—keeps the MFT as contiguous as possible as it grows.

Paging File

The Paging File is the disk space that Windows 2000 uses to swap data in and out of Random Access Memory (RAM). When memory requirements exceed the amount of physical RAM, the Virtual Memory Manager transfers the oldest data stored in RAM to the Paging File. This makes RAM available for higher priority uses. If the Paging File becomes fragmented, performance can degrade severely due to increased disk input and output times.

When Windows 2000 starts up, disk space is allocated to the MFT and the Paging File for their exclusive use. It's important to know that the APIs that enable safe defragmentation do not support the movement of these files; as a result, they cannot be moved safely. Therefore, it's recommended that the MFT and the Paging File be defragmented when Windows 2000 is not running. But, because this places them beyond the range of routine defragmentation methods, the standard solution is to defragment the MFT and the Paging File during boot time, using a third-party, enterprise-level defragmenter.

Hibernate File

The Hibernate File is the disk space where memory data is stored when the computer is turned off. Because the location of the Hibernate File is determined very early in the boot process, it cannot be moved. It can, however, be defragmented safely at boot time using a third-party, enterprise-level defragmenter.

Directories

Directories can also become fragmented; adding to the time it takes to access files. Windows 2000 directories, on an NTFS disk, can be defragmented while the operating system is running. However, FAT directories can only be defragmented at boot time.

Windows 2000 Disk Defragmenter

Disk Defragmenter is a compact, manual system tool that supports FAT 16, FAT 32, and NTFS (which supports compressed and encrypted files). It includes an analysis program that illustrates the extent of disk fragmentation, with the Analysis Display illustrating the condition of the disk before defragmenting, and the Defragmentation Display showing the condition of the disk after defragmentation. For the individual user, Disk Defragmenter is more than adequate for the job of maintaining high-level disk performance.

Using Disk Defragmenter

Disk Defragmenter's easy-to-use interface offers two disk management options: Analyze and Defragment.

Bb742585.w2kexc01(en-us,TechNet.10).gif

Figure 1: Analyze and Defragment options

Analyze and Defragment

Analyze is a diagnostic tool that examines the condition of the disk you've selected, and let's you know if you need to defragment your disk(s). After using Analyze in the example illustrated below, in turns out that defragmentation of volume (C:) is not necessary. If it was necessary to defragment the disk, the message box would indicate so, and you would only need to press the Defragment button and the defragmentation process would begin automatically.

Bb742585.w2kexc02(en-us,TechNet.10).gif

Figure 2: Analysis Message Box

Whether you're analyzing or defragmenting a volume, Disk Defragmenter works on only one volume at a time, and each one must be manually selected by clicking it. After choosing a volume, and the process you want performed, the interface displays a map illustrating the disk's current state of fragmentation.

Operating the Disk Defragmenter

The following steps detail how to use Disk Defragmenter:

  1. Click Start, point to Programs, point to Accessories, point to System Tools and click Disk Defragmenter.

  2. Select the volume(s) that you want to check for fragmentation.

  3. Click Analyze and wait for the message box to find out whether or not you need to defragment.

  4. If you need to defragment, click Defragment.

    Note: While it's possible to do other tasks while Disk Defragmenter is defragmenting a volume, it's not recommended. This is because the defragmentation process may reduce overall system response time. It is recommended that you run Disk Defragmenter when you've finished using the computer for the day.

  5. When the defragmentation process is completed, select the next volume (if any) to defragment, until all volumes are defragmented and consolidated.

Understanding the Color-coded Display Map

Disk Defragmenter uses a color-code system to show how different file types and free space are organized on a volume. Fragmented files are coded red; contiguous files, blue; system files—which include the MFT and the Paging File, green; and free space is white. The size of each color segment on the display map represents how much space—along with its relative position—each file element occupies on the volume.

Bb742585.w2kexc03(en-us,TechNet.10).gif

Figure 3: Color-coded display map

It is important to understand that this color-coded map represents an "approximation" of the disk's condition. In reality, each pixel-wide line (72 pixels = 1 inch) usually represents thousands of clusters, some of which may contain a mix of fragmented files, contiguous files, free space, and system files. Considering this, an algorithm determines what color to display based on the predominance of the particular file elements comprising the section of the disk represented by each pixel-wide line. And, because it's an approximation, the Disk Defragmenter display can illustrate a somewhat skewed representation of the condition of the disk.

For example, if a pixel-wide line on the display represents 1000 clusters, 51 percent of which are contiguous, and 49 percent are free, Disk Defragmenter would color that segment of the display blue for contiguous. The effect would be to hide the free space, and have the amount of available free space appear to be much less on the display map than is actually reported by Windows Explorer. However, after you successfully defragment the disk, the color display will present a more accurate representation of the condition of the disk, and the amount of free space represented will be more accurate.

Defragmenting Requires Sufficient Space on Your Disk

If the disk that you intend to defragment is already highly fragmented, there may be insufficient free space on that disk to effectively run the defragmentation process. This is because a complete copy of the defragmented file is made in the new, defragmented location before the original clusters are marked free.

After defragmenting a disk , Disk Defragmenter may still report: "It is recommended that you defragment this disk." This indicates that there is too little free space to effectively perform the defragmentation routine. If this occurs, do one of the following:

  • Temporarily move a few large files off the disk.

  • Delete files that are no longer needed.

Calculating Required Free Space

As noted above, in the section describing the Master File Table, one-eighth of a disk is allocated to the MFT zone. Although this area is marked as free space, it is reserved by Windows 2000 for the exclusive use of the MFT. When defragmenting, the Disk Defragmenter cannot take advantage of this space by moving files into the MFT zone. So when calculating the amount of free space available for defragmentation, you must subtract about 12 percent from the free space reported by Windows Explorer. It is recommended that you maintain about 30 percent of any NTFS-formatted disk as free space to ensure that you have sufficient room for effective defragmentation.

Summary

File fragmentation can negatively affect operating system speed and performance. To maintain peak performance when using Windows 2000, the condition of your disks should be analyzed on a regular basis—preferably once a week for moderate-to-heavy use; less frequently for intermittent use—and defragmentation performed as needed.

Disk Defragmenter is designed primarily for stand-alone machines and users with Administrator privileges. It is not intended to be used for network defragmentation. Administrators who require network controls, automatic scheduling, and the capability to simultaneously defragment multiple partitions, and MFT and paging files, should consider upgrading to a third-party, networkable defragmenter.

For additional information on this subject, please go to: