File fragmentation is one of the constants of Microsoft’s, and other, operating systems.
On a brand-new drive, the first files written are all written to contiguous parts of the drive, making for the fastest possible read times. Gradually, as more files are added, removed or changed, there is no longer adequate contiguous space, and the new files take whatever space is available. This leads to file fragmentation and longer access times to read the files, as well as longer time spent writing changes or new files.
To overcome this problem, you use a disk defragmenter utility. This moves parts of files and free space around until the files are using as contiguous a space as possible. Windows 2000 (like all Microsoft operating systems since Windows 95) includes a built-in defragmenter utility, which you should run from time to time.
You will notice, though, that some files are never defragmented by this utility. Among these are the NTFS Master File Table (and its mirror copy) and the Virtual Memory Paging file (the so-called "swap file"). Nonetheless, these will become fragmented over time. There are ways to remove the fragmentation, but they're relatively drastic -- so you should be sure to have decent backups before attempting these procedures.
The swap file is best defragmented by re-creating it. To do so, follow these steps (for Windows 2000):
Click Start, point to Settings, click Control Panel, and then double-click System.
On the Advanced tab, click Performance Options.
Click Change to open the Virtual Memory dialog box.
Change the paging file to another drive.
Reduce the minimum and maximum size of the original paging file on the drive you want to defragment to 0M bytes.
Restart your computer to have the system use the new paging file.
Run Disk Defragmenter on the original drive to consolidate the free space segments created by moving the paging file.
Re-create the paging file on the original drive.
Reduce the minimum and maximum size of the temporary paging file to 0M bytes.
Restart your computer.
Defragging the Master File Table also requires re-creating it, but you'll want to make doubly sure you have good backups, because the procedure will destroy all data on the drive! Nevertheless, it can increase access time to files.
First, you'll want to see how fragmented the file table is. Do this by performing a Disk Defragmenter analyze operation to generate a report. View the report and look for the section of the report called "Master File Table (MFT) fragmentation" (it’s under Volume Information). It might look like this:
Total MFT Size = 8512K
MFT record count = 8,504
Percent MFT in use = 99%
Total MFT Fragments = 4
Then get a copy of Microsoft's Knowledgebase article Q174619, "How NTFS Reserves Space for its Master File Table (MFT)":
You'll use the data from the report according to the instructions in the article to adjust the NtfsMftZoneReservation value. But first you need to back up and reformat the volume in order to create a contiguous MFT using the higher zone reservation space, and then perform a full volume restore. This is not something for the faint of heart! Nevertheless, it can increase the pperformance of your system -- sometimes remarkably.
This story, "How to defrag " was originally published by Network World.