Defragging Your Windows Hard Drive

What is Defragging?

Any time an application or the operating writes data to your hard drive, it writes it to the next available cluster. What that means is that each time you save a file you changed, each piece may be located in different areas of your hard dive. The file system keeps track of where all the pieces are located so finding the file in not a problem. However, fragmentation makes the computer run slower because it takes longer to find and load all of the pieces into memory. Therefore, regularly scheduling defragmentation of your PC should be part of optimizing your hard drive’s performance. The frequency will be determined by the file system in use.

How does Defragmentation Work?

The computer will first analyse your hard drive to see how many files are stored in non-contiguous locations, That means they are not stored next to each other and can be anywhere on the hard drive.

Next the application will calculate how much free disk space it needs to move the files around so that every cluster used by a file is located next to the others.

Defragmenting Your Hard Disk

We are only going to talk about how to defrag XP and defrag vista. There may be minor differences in how the screen shots look in windows 2000, 2003, XP and vista but the steps should be basically the same. You can buy a commercial product that allows you to automatically schedule defragmenting but most people will use the built in utility provided by Microsoft. Later I will tell you how to automate the process using the free utility.

Each hard disk partion (drive C, D, etc.) must be defragged separately. FAT and FAT32 partitions should be degragged wekly. NTFS partitions should be checked monthly to see if they need defragmentation. Anything over 5% should be defragmented.

Go to Start->All Programs -> System Tools -> Disk Defragmenter to start the application. Or you can open windows explorer and right click on the partition you want to defrag by selecting Properties -> Tools -> Defragment Now. In either case, the window below opens.

Select the hard drive you want to defrag and then click on Analyze. The screen shown below will open. I selected drive C because it has the most read write operations since all of the applications and system files are stored on it.

It may take several minutes but eventually the analysis will stop and the application will tell you if the drive needs defragging. My second drive (G) has 0% fragmentation and has not been defragged for almost a year. However, my system drive needs defragging as shown below.

The picture below is a portion of the report.

30 % file fragmentation is a lot and the computer will definitely run faster when this partition has been defragmented.

Before defragging the drive, close all open windows applications except the defragger.

Select Defragment and then go do something else because, depending on the size of the partition, it can take anywhere from 20 minutes to more than an hour to complete the process.

Defragging the Boot Sector

Windows XP and vista allow boot files to be placed next to each other speeding up startup process. Boot defrag should be enabled by default. However, it is a good idea to check and make certain. Open regedit and go to the HKEY_LOCAL_MACHINE \ SOTWARE \ Microsoft \ Dfrg \ BootOptimizeFunction registry key. Check that the Data value for Enable is set to Y. If not, right-click on Enable and choose Modify. Then change the value to Y, click OK and close Regedit.

Automating the Defrag Process

You can automate the defrag process by creating a batch file with the proper commands and then using the windows task scheduler to run the file at periodic intervals. Open Notepad and type the following commands

DEFRAG C: DEFRAG D: DEFRAG E: DEFRAG F:

Use the appropriate letters for the hard drive partitions on your computer. Save the file as defrag.bat.

Open the Control Panel. Select Scheduled Tasks and then click on Add New Scheduled Task. A wizard will open to guide you through the process. When asked, browse to the batch file you created, then select an appropriate time period such as monthly and a time of day to run the task. Since defragging can take several hours, I recommend setting it up for the wee hours of the morning.

After you configure the task, the computer should run it at the scheduled times.

 

Did you find this article helpful? Please help share it!

  Stumble This Article     Add to Del.icio.us    Digg This!