How to Optimize Computer Performance with Hard Drive Defragmentation?
Hard Drive Performance Optimization
Windows comes with a collection of house cleaning tools, including ScanDisk, Disk Defragmenter and Disk Cleanup, to help keep your disk in peak working order.
Why should you bother with the housework? A couple of reasons. First, disks are hard working, mechanical devices and, like all mechanical devices, prone to failure. A little preventative maintenance can warn you of potential problems and fix minor glitches before they can do damage to your data.
Second, the way files are organized on your drive has a perceptible impact on the performance of your computer. If your files are stored neatly, end-to-end, without fragmentation, reading and writing to the disk is speedier.
What is file fragmentation?
Sometimes when you install a program or create a data file, the file ends up chopped up into chunks and stored in multiple locations on the disk. This is called fragmentation.
What makes this happen?
When you first install your operating system and programs on your hard disk, they are written to the disk, for the most part, in one contiguous block without any gaps. The exceptions are certain system files that must be stored in specific locations. Over time, as you create and then delete documents or uninstall programs, once-filled locations are left empty and you end up with files dotted all over the disk.
Now, when Windows is writing a file to the disk, it looks for a suitable piece of free space in which to store it. What happens, then, when you copy a 40 MB database or audio file to the disk and the biggest slice of free space is only 30 MB? Or say you modify an existing file, appending a whole bunch of data so the file now takes up more space on the disk. To accommodate the files, Windows writes the first part of the file in one section of the disk and then scouts around for other places to store the rest of the file. The end result is that a single file may be stored in several chunks scattered about the disk.
Of FAT and files
Windows keeps track of each file’s location in the File Allocation Table, or FAT (Windows 98 and Me use a file system called FAT32). When your file is written to disk, FAT32 provides Windows with the address of an unoccupied disk cluster. FAT32 also tells Windows on which disk sectors it will find that cluster; that is, it provides the physical location of the cluster. This information is used by your PC’s BIOS (the Basic Input/Output System) to direct the actual disk writing operation.
If the file is too large to fit in a single cluster, Windows asks FAT32 for another vacant cluster, and another, and another until the whole file is written to disk. If you have lots of free clusters side by side, FAT32 can point Windows to an adjacent series of clusters, resulting in a file which occupies one contiguous chunk of the disk. If no adjacent cluster is available, FAT32 tracks down a space elsewhere on the disk and tells Windows to put the next bit of the file there; and so on until the full file is written to disk.
A record of the clusters used for storing the file is kept by FAT32 so Windows can find the file once more when you want to read it.
The fragmentation penalty
Although this all happens quickly, it makes a lot of work for your hard disk. Its read/write head, which moves across the drive platter from location to location transferring data, has to zip all over the place when saving or opening a single highly fragmented file. (By the way, many disks have more than one read/write head and multiple platters.) If a file is unfragmented, the disk head moves to one location, reads the file in one sequential swoop, and that’s it.
A file stored in, say, four fragments, can easily take twice as long to open as the same file unfragmented, although the actual performance hit you take is affected by other factors, including the total size of the file.
The techniques used by the Disk Defragmenter
# Moving all the index or directory information to one spot. Moving this spot into the center of the data, i.e. one third of the way in, so that average head travel to data is halved compared to having directory information at the front.
# Moving infrequently used files further from the directory area.
# Obeying a user provided table of file descriptions to emphasize or ignore.
# Making files contiguous so that they can be read without unnecessary seeking.
Windows XP Disk Defragmenter Limitations
Disk Defragmenter in Windows XP has the following MAJOR limitations:
# It does NOT defragment files residing in the Recycle Bin.
# It also cannot defragment "in-use" files.
# Does not defrag and clean the registry.
# It can defragment only local volumes.
# It can defragment only one volume at a time.
# It cannot defragment one volume while it is scanning another.
# It cannot be scheduled automatically. If you need to schedule disk defragmentation, use the Defrag.exe command line tool.
Defragment Your Disk Drive Volumes in Windows XP
Disk Defragmenter Microsoft Management Console (MMC) is based on the full retail version of Executive Software Diskeeper. The version that is included with Windows XP and later provides limited functionality in maintaining disk performance by defragmenting volumes that use the FAT, FAT32, or NTFS file system.
To start Disk Defragmenter MMC, use one of the methods.
Method 1: Use the Properties of Your Local Disk
- Open My Computer.
- Right-click the local disk volume that you want to defragment, and then click Properties.
- On the Tools tab, click Defragment Now.
- Click Defragment.
- If you have more than one hard disk, repeat this process for each hard disk listed.
- Start Computer Management MMC (Compmgmt.msc).
- Click Disk Defragmenter.
- Click the volume that you want to defragment, and then click Defragment.
- Start Disk Defragmenter MMC (Dfrg.msc).
- Click the volume that you want to defragment, and then click Defragment.
The Disk Defragmenter tool can take anywhere from minutes to hours to run, depending on the size of your hard drive and also how fragmented the drive is. One way to run the Disk Defragmenter and not lose any computing time is to leave the system and run the Disk Defragmenter during a time when the system can be left on but is not be in use (e.g., 3 or 4 a.m.). You can simply use the steps above to launch Disk Defragmenter when your computing tasks are done for the day or you can have the Windows Task Scheduler automatically run the Disk Defragmenter on a certain day and time each week or month.
Tips for Getting the Best Results
- Ensure you have no applications running when you start the Disk Defragmenter. If you system is accessing applications the Defragmenter will not stay running. Be sure to turn off your screensaver also.
- Delete your Temporary Internet Files and other files you do not use. You can also uninstall unused programs. In the Properties tab of your hard drive you can access "Disk Cleanup," which will help you get rid of unused and unnecessary files.
- Run the Disk Defragmenter at regular intervals. However you can also run the tool if you add a lot of files to the disk at one time or find you are running low on disk space.
- The volume must have at least 15% free space for Defrag to completely and adequately defragment it. Defrag uses this space as a sorting area for file fragments. If a volume has less than 15% free space, Defrag only partially defragments it.
- Open Control Panel, double-click Scheduled Tasks
- Double-click Add Scheduled Task
- On the Scheduled Task Wizard dialog, click Next.
- Click Browse and navigate to windows’system32 folder. Select defrag.exe and click Open. In the Scheduled Task Wizard dialog, type a name for the scheduled task (for example type Disk Defrag).
- Under Perform this task, select how often you wish Disk Defragmenter to run. Click Next.
- Set the time at which you wish the Disk Defragmenter scheduled task to run. This should be a time when your computer is turned on but not under heavy use (i.e. at night time). Select the frequency at which you want the Disk Defragmenter task to run (Every Day, Weekdays, or Every <N> days, where <N> is the number of days between scheduled runs). Click Next.
- Enter a user name under which the Disk Defragmenter scheduled task will run. This user must be an administrator on the local machine (see note above). Enter the password for that user and confirm it. Click Next.
- Check Open advanced properties for this task when I click Finish, and click Finish.
- In the Run text box, you can see the full path and command for defrag.exe. Add the drive letter for the drive you wish to defragment to the command in the Run text box. If you want to defragment drive C:, your Run command should look like this: C:’WINDOWS’SYSTEM32’defrag.exe C: Click OK.
- In the Set Account Information dialog, enter and confirm the password for the user listed in Run as and click OK.
- Task Scheduler will automatically run Disk Defragmenter with the settings you selected at the time you selected.
Defrag Your Boot Files
File fragmentation can happen at start-up too. A real power tip (not for beginners) is to have Windows XP automatically defragment these files, but you will have to make sure your Windows XP registry has the correct setting.
Open your Registry Editor and go to key:
HKEY_LOCAL_MACHINE’SOFTWARE’Microsoft’Dfrg’BootOptimizeFunction
Look for a VALUE in the right hand pane called BootOptimizeFunction
...if it does NOT exist, choose from the menu Edit > New > String Value and create it.
Make sure that it has the entry Y.
Sources and Additional Information:
http://www.geekgirls.com/windows_defrag.htm
http://support.microsoft.com/kb/314848
http://www.webopedia.com/DidYouKnow/Computer_Science/2008/disk_defragmentation.asp
http://www.petri.co.il/schedule_disk_defrag_to_run_automatically_in_windows_xp_2003.htm
http://www.updatexp.com/disk-defragmenter.html