Defragmenting Disks

As files are created, modified, and moved, fragmentation can occur both within the volume's allocation table and on the volume itself. This happens because files are written to clusters on disk as they are used. The file system uses the first clusters available when writing new data, so as you modify files, different parts of files can end up in different areas of the disk. If you delete a file, an area of the disk is made available, but it might not be big enough to store the next file that is created and as a result, part of a new file might get written to this newly freed area and part of it might get written somewhere else on the disk.

Although the file system doesn't care if the file data is on contiguous clusters or spread out across the disk, the fact that data is in different areas of the disk can slow down read/write operations. This means it will take longer than usual to open and save files. It also makes it more difficult to recover files in case of serious disk error. Windows Server 2003 provides a tool for defragmenting volumes called the Disk Defragmenter.

Fixing Fragmentation by Using Disk Defragmenter

Fixing Fragmentation by Using Disk Defragmenter

Using Disk Defragmenter, you can check for and correct volume fragmentation problems on FAT, FAT32, and NTFS volumes. The areas checked for fragmentation include the volume, files, folders, the page file if one exists on the volume, and the MFT. Being able to check the MFT is a new feature for Windows Server 2003. Another new feature is the ability to defragment volumes with cluster sizes greater than 4 KB.

You can run the graphical version of Disk Defragmenter using either Windows Explorer or Computer Management. In Windows Explorer, right-click the volume, and choose Properties. In the Tools tab of the Properties dialog box, click Defragment Now to display the Disk Defragmenter dialog box. In Computer Management, expand Storage, and select Disk Defragmenter as shown in Figure 20-17. Select the volume you want to work with by clicking it, and then determine the level of fragmentation on the volume by clicking Analyze.

Use Disk Defragmenter to check disks for fragmentation

Figure 20-17. Use Disk Defragmenter to check disks for fragmentation

If the disk is marked to be checked the next time the operating system is started, you won't be able to analyze it. Instead, you will be told that Check Disk is scheduled to run on the volume, and you must run it before you can analyze the disk. If the disk is possibly corrupt and has been marked as such, you won't be able to analyze it either. In this case, you will be told that you should run Check Disk. Otherwise, Disk Defragmenter will then analyze the disk and graphically display the current disk usage, indicating the following information:

  • Fragmented files Files that are fragmented

  • Contiguous files Files that are written in consecutive clusters

  • Unmovable files Files that can't be moved, typically because they are system files, such as the page file

  • Free Space Space that is available on the volume

When Disk Defragmenter finishes the analysis, it displays a recommendation, as shown in Figure 20-18. You will be told either that you should defragment the volume now or that the volume doesn't need to be defragmented. If you click View Report, you can view a report of the analysis, as shown in Figure 20-19. You also have the option to print or save the report. If you save the report, it is saved to a text file that can be viewed in any standard text editor.

After analysis, Disk Defragmenter will recommend an action and let you view an analysis report

Figure 20-18. After analysis, Disk Defragmenter will recommend an action and let you view an analysis report

The Analysis Report dialog box allows you to view the results of running Disk Defragmenter

Figure 20-19. The Analysis Report dialog box allows you to view the results of running Disk Defragmenter

After you analyze the disk, you can defragment it by clicking the Defragment button. Disk Defragmenter needs at least 15 percent free space to defragment a disk completely. Disk Defragmenter uses this space as a sorting area for file fragments. If a volume has less than 15 percent free space, Disk Defragmenter will only partially defragment it.

Disk Defragmenter can also be run at the command line using Defrag (Defrag.exe). You can run Disk Defragmenter in analysis mode at the command line by typing defrag –a followed by the drive designator. For example, if you want to analyze the fragmentation of the D drive, you'd type defrag –a d:. To analyze and then defragment a volume if defragmentation is necessary, type defrag followed by the drive designator, such as defrag d:. No parameters are necessary.

The complete syntax for Defrag is this:

defrag volume [-a] [-v] [-f]

The –V parameter is used to display detailed output and the –F parameter is used to force defragmentation even if there is low free space on the volume.

Understanding the Fragmentation Analysis

You can perform fragmentation analysis using the report generated from the graphical user interface (GUI) or the command line. Both techniques produce similar results as long as you use the –V parameter at the command line. The graphical report is in two sections: The first section provides a summary of fragmentation in all areas checked, and the second section provides information on individual file fragmentation. The command-line report shows only the summary of fragmentation. The summary looks like this:

Volume Apps (D:)
       Volume size                              = 55.91 GB
       Cluster size                             = 4 KB
       Used space                               = 50.18 GB
       Free space                               = 5.73 GB
       Percent free space                       = 11 %

Volume fragmentation
       Total fragmentation                      = 13 %
       File fragmentation                       = 24 %
       Free space fragmentation                 = 3 %

File fragmentation
       Total files                              = 116,409
       Average file size                        = 210 KB
       Total fragmented files                   = 11,874
       Total excess fragments                   = 68,585
       Average fragments per file               = 1.58

Pagefile fragmentation
       Pagefile size                            = 768 MB
       Total fragments                          = 1 
Folder fragmentation
       Total folders                            = 7,477
       Fragmented folders                       = 610
       Excess folder fragments                  = 3,418

Master File Table (MFT) fragmentation
       Total MFT size                           = 123 MB
       MFT record count                         = 124,119
       Percent MFT in use                       = 98 %
       Total MFT fragments                      = 255

Disk Defragmenter provides a summary of the volume's configuration and space usage. In addition, depending on the type of volume you are working with, it reports on the following areas:

  • Volume Fragmentation Gives on overview of fragmentation on the volume. Total Fragmentation details the percentage of the total volume that is fragmented. File Fragmentation details the percentage of used space that is fragmented. Free Space Fragmentation details the percentage of unused space that is fragmented.

  • File Fragmentation Gives an overview of file-level fragmentation showing the total number of files on the volume, the average size of those files, how many files are fragmented, and the average number of fragments per file. Ideally, you want the number of fragments per file to be as close to 1.00 as possible. In this example, the fragments per file ratio is 1.58, indicating that about 58 percent of files are fragmented into two or more clusters.

  • Pagefile Fragmentation Gives an overview of how fragmented the page file is (if there's one on the volume). If you followed my advice of setting a fixed page file size, as discussed in the section entitled "Tuning Virtual Memory", the page file shouldn't be fragmented, which is the case here. Otherwise, the page file can get fragmented as it grows in size and is written to new areas of the disk.

  • Folder Fragmentation Gives an overview of folder-level fragmentation showing the total number of folders on the volume and how many folders are fragmented.

  • Master File Table (MFT) Fragmentation For NTFS volumes only, gives an overview of fragmentation in the MFT, showing the current size of the MFT, the number of records it contains, the percentage of the MFT in use, and the total number of fragments in the MFT. In this example, the MFT has some fragmentation. But the real concern is that it is at 98 percent of its maximum size. Because of this, the MFT could become more fragmented over time—there is still 11 percent free space on the volume, and if it needs to grow it will grow into the free space.

That's it. If you click Defragment or run Defrag again without the -A parameter, the Disk Defragmenter will set about cleaning up the drive to give optimal space usage. This won't clear up all fragmentation, but it will help so that disk space is used more efficiently—and on a moderately fragmented volume like the one shown, you should see some performance improvements after defragmentation as well.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset