Disk Defragmenter

Use Win2K's built-in manual defragmenter to put your data files' pieces together again.

Kathy Ivens

September 16, 2001

7 Min Read
ITPro Today logo in a gray background | ITPro Today

Keep your Win2K system from going to pieces

The first lesson of disk fragmentation and defragmentation is how to use the jargon. No self-respecting IT professional uses the word defragment. The correct word is defrag, as in "I need to defrag my drive." Next, familiarize yourself with Windows 2000's built-in manual defrag tool—Disk Defragmenter (a lite version of Executive Software's full-power Diskeeper product). Disk Defragmenterworks with Win2K APIs to gather fragmented files' segments and reassemble the pieces into files that reside in contiguous clusters on the disk. You can improve Disk Defragmenter's usefulness by knowing when it's important to defrag and the best way to go about doing so.

Fragmentation generally occurs after more than half of a system's disk space is occupied. At that point, files you add to the disk fill the empty spots left by files you've deleted. Often, this empty space isn't sufficient to contain an entire new file, so the file is fragmented (i.e., saved in separate pieces). The more fragmented the files on a system's hard disk, the slower the computer's performance for file input and output. Some experts believe that a fragmented disk also increases the chance of lost clusters and file segments (especially when you have an unexpected shutdown).

What the Tool Can (and Can't) Do
Disk Defragmenter works on both FAT and NTFS drives. (Don't believe the rumor that you don't need to defrag NTFS drives.) To defrag your drives, the program works hand-in-hand with Win2K APIs. Disk Defragmenter finds file fragments and loads them into memory, then writes the data to a part of the drive that has enough free space to hold all the fragments. Win2K tracks this new location and writes the location information back to the FAT in a FAT system or the Master File Table (MFT) in an NTFS system.

You can't use Disk Defragmenter to defrag the FAT, MFT, paging file, hibernate file (if the computer uses one), or registry. Also, the built-in defragger works only on the local computer. Therefore, you need to invest in a third-party program if you want to defrag system files, defrag remote drives, or schedule defrag tasks to occur automatically on multiple machines. (However, a few workarounds exist to help you defrag the paging file or schedule defrag tasks. See the sidebar "Work Around the Limits," page 124, for information about these workarounds.) The three most popular full-strength defrag products are Diskeeper, Symantec Speed Disk, and Raxco Software's PerfectDisk 2000. For a comparison of these products, see Tom Iwanski, "Enterprise Defragmentation Utilities," February 2001.

When (and When Not) to Defrag
I suggest that you run Disk Defragmenter on your systems immediately after you install the OS and before you install any software. Additionally, whenever anyone removes many files from a drive—especially during a software uninstall—defrag the drive immediately.

Then, defrag drives monthly or weekly, depending on how many files users delete and save on their computers. Computers that hold many data files—especially systems on which users frequently delete and save small files—are primary candidates for weekly defragging. Users who primarily use graphics or presentation software don't usually delete and save many small files, so monthly defragging should be sufficient for these users' machines.

Regular defragging is effective but can be onerous. As I mentioned earlier, you can't run the built-in program remotely, and you need Administrator permissions to launch Disk Defragmenter. Users generally don't have Administrator permissions, so you must assign an administrator to perform the task manually on each user's system. (Chalk up another reason to store data files on your servers instead of on local machines—as if data backup weren't enough motivation.)

Don't defrag servers that are running Microsoft Exchange Server, Microsoft SQL Server, or any ongoing Microsoft BackOffice type of application. These applications always have open files (e.g., transaction log files) that you shouldn't disturb. Disk Defragmenter can't defrag open files, so to defrag the server, you'd need to stop the services; doing so wreaks havoc. Instead, use the applications' built-in tools for cleaning and compacting files. (Usually, these tools can rebuild indexes and help get rid of the holes that result from deleted information.) Enterprisewide applications' defrag restrictions reinforce the benefits of dedicating servers to such applications rather than mounting the applications on servers that also provide file and print services.

Getting Down to Business
To open Disk Defragmenter, select Start, Programs, Accessories, System Tools, Disk Defragmenter. The main interface, which Figure 1 shows, displays information about the volumes on the computer.

You can click Defragment to start the defrag process directly, but before doing so, analyze the condition of the drive first to determine whether defragging is necessary. The defrag process can take a long time, especially for large drives with a lot of files. To launch an analysis, simply select the drive you want to examine, then click Analyze.

If the software determines that defragging isn't needed, a message appears to inform you of that fact. You can click View Report on the message box to see the Analysis Report, which provides a detailed listing of files and their fragmentation status, as Figure 2 shows. Even if the software has deemed it unnecessary, you can click Defragment (either in the message window or in the report window) to defrag the drive—a good idea if you're about to install a large software program. (You should always defrag a drive on which you're planning to install Exchange, SQL Server, or any other humongous application.) If Disk Defragmenter concludes that defragging is warranted, the program displays a message to that effect. Follow the same steps to view the report or start the defragging process.

Regardless of whether you've already performed an analysis, clicking Defragment launches another analysis (the program always analyzes the drive immediately before starting the defrag). During the defragging process, the software's main interface presents a color-coded display, which Figure 3 shows.

You can run other programs during the defrag process, but any open application and the defragger will both run slowly. You're better off closing all other software and leaving these programs closed during the defrag.

A message appears to inform you when the process is completed. Click View Report in the message window to see the new fragmentation status on a file-by-file basis.

Optimizing the Tool—and Your System
When a drive is running low on free space, the defrag process doesn't do a complete job because the system doesn't have enough space to transform all the file fragments into contiguous files. Instead, the process merely reduces the number of existing fragments. (For example, after you run Disk Defragmenter, a file that was in 25 pieces might be in only 8 pieces.)

Although immediately rerunning Disk Defragmenter often improves your defrag statistics, a better tack is to establish as much free disk space as possible before you defrag a drive the first time. In preparation for your defrag tasks, perform some housekeeping and delete obsolete and unused files, especially temporary files. A useful trick is to temporarily move files to another drive, usually on another network computer (unless the computer you're defragging has multiple drives). After you defrag the original drive, copy the files back; they're more likely to be saved contiguously.

I suggest that you keep at least 30 percent of a drive's capacity free so that you have sufficient room to store temporary files, to swap files, and to save files contiguously. When you calculate free space for NTFS volumes, the math isn't straightforward. NTFS sets aside one-eighth of a drive in an area called the MFT zone, which only the MFT can access. Because the MFT rarely uses all that space, it appears to be free, but Disk Defragmenter can't access the space. You must account for the MFT zone when you view an NTFS volume's free space from Windows Explorer or My Computer. Deduct about 12 percent from the statistic to get an accurate figure.

To give Win2K enough room to operate at a decent performance level, run Disk Defragmenter regularly on the systems that you've determined most likely need defragging. Despite Disk Defragmenter's restrictions, you'll enjoy the benefits of this built-in tool.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like