Welcome Guest (Log In | Create Account)
New Member? Join for free.

The Importance of Disk Defragmentation

By on April 14, 2004 | Last Updated: April 21, 2012 | Read 165,046 times.
  • Print this page

Table of Contents

  1. Introduction
  2. Fragmentation
  3. Defragmentation
  4. Using the Windows Defragmenter
  5. Defragmenter Software for other Operating Systems
  6. Using a spare hard drive to defragment
  7. How to prevent fragmentation
  8. Conclusion

Introduction

I am sure many of you have been told in the past to defrag your hard drives when you have noticed a slow down on your computer. You may have followed the advice and defragged your hard drive, and actually noticed a difference. Have you ever wondered why defragging helps though? This tutorial will discuss what Disk Fragmentation is and how you can optimize your hard drive's partitions by defragmenting them for better performance.

Fragmentation

In order to understand why defragging works, it is important to understand how data is stored on your hard drive. When data, such as a file, is stored on a hard drive the operating system attempts to store that file in one section of contiguous, locations that are connecting without a break, space. When you have a new hard drive, storing data in contiguous spaces is not a problem. As you use the hard drive, though, files will be deleted from it and small pockets of space will be created on your hard drive. These small pockets of space on your hard drive is called fragmentation.

When a hard drive is fragmented, and the operating system wants to store a file on the hard drive, it attempts to store it in a section of contiguous space that will be large enough to accommodate the file. If the hard drive is heavily fragmented, there is the possibility that there will not be enough contiguous space available to store the file, and therefore the file will be broken up and stored in multiple locations on the hard drive. This causes the file to become fragmented. This is especially bad when installing new software on your computer because the program will now be installed over multiple locations on your hard drive. Now when you run this particular application its performance will be degraded because it has to be loaded from multiple locations on the hard drive.

Figure 1 below shows an example of a fragmented file. Notice how File1 is stored in two locations which are not contiguous.

Figure 1: Fragmented File

Defragmentation

To solve this problem, software developers developed a type of program called a Disk Defragmenter. A defragmenter is an application that reorganizes the data on your hard drive's partitions in such a manner that the files are stored in as much contiguous space as possible. The defragmenter will search your hard drive partition and move data from one location to another location, so that the files stored there are one contiguous piece, instead of being spread throughout multiple locations on the hard drive's partition. This allows the programs and data to run more efficiently and quickly as the operating system does not have to read from multiple locations.

Figure 2 below shows an example of a file store in contiguous space. Notice how the entire file is located in one area and not split between multiple locations.

Figure 2: File that is not fragmented

There are two ways to defragment your hard drive. One way is to use a Disk Defragmenter program and the other is to use an extra empty hard drive. We will discuss both ways below.

Using the Windows Disk Defragmenter

Please Note that this tutorial will cover the defragmenter found in Windows XP only. The other versions of windows, and other vendor's applications, have similar programs that should not be too hard to figure out when following this tutorial.

Step 1: Shut down all applications

It is a good procedure to shut down all applications before you run a Disk Defragmenter including your Antivirus software. This is to make sure that no programs attempt to write to the drive while it is being defragmented. Though this will not cause any damage, it may cause you to have to restart the entire process from the beginning.

Step 2: Running the Disk Defragmenter

Windows comes with a program called Disk Defragmenter which is installed with the operating system. This program can be found in your System Tools folder under Accessories on your Programs menu. This is shown in Figure 3 below.


Figure 3. Launching Disk Defragmenter


Click once on the Disk Defragmenter as show above in Figure 1 to launch the program. You will then be presented with a screen similar to Figure 4 below.


Figure 4. Disk Defragmenter Startup Screen


The main screen of Defragmenter will show you a listing of your hard drive partitions and then give you the option to Analyze the partition or Defragment it. Before you choose the Analyze or Defragment button, you should select the partition you want to work with, by clicking once on it. By default the first partition will be selected.

Step 3: Analyze your partitions

When you click on the Analyze button, designated by the red box in Figure 4, the Defragmenter will scan the partition you have selected and give you a report on how badly it is fragmented. The higher percentage that you are fragmented, the worse it is. When it is done analyzing your hard drive it will give you a prompt that tells you the recommendation on whether you should defragment or not and gives you the option to defragment or view the report as show in Figure 3 below.


Figure 5. Prompt to view Report or Defragment


I always make it a habit to view the report so I can see how badly my hard drive is being used. You would do this by clicking on the "View Report" button designated by the red box in Figure 5. When you click on the View Report, you will be presented with a screen similar to Figure 6 below.


Figure 6. Report of Analysis


The report will give you a lot of details about various attributes of your file system. We are only concerned with the Volume Fragmentation as show in Figure 6 above designated by the red box.

Step 4: Defragmenting

NOTES: Before defragging will occur the following rules apply:

  • A partition must have 15 percent free space on the drive for the Disk Defragmenter to work properly.
  • A partition that is marked dirty will not be defragmented as it may possible have corruption.
  • You can only run one instance of Disk Defragmenter at a time.
  • You can only defrag local drives.

As you can see from Figure 6 above, this computer has a total fragmentation of 34%. That is not good and my computer is not giving me the performance that it should be. I am therefore going to defragment my hard drive by clicking on the Defragment button, designated by the blue box in Figure 6 above. After clicking on the Defragment button you will see a window similar to Figure 7 below.


Figure 7: Defragging


Lets explain what you see on the screen. The two bars in the middle of this screen with all the colors on it are the the Analysis and Defragmentation displays.

The top bar, labeled"Estimated disk usage before defragmentation" is the Analysis display and shows a graphical representation of your partition before the defrag started.

The bar under it, labeled"Estimated disk usage after defragmentation" is the Defragmentation display. This shows a real-time graphical representation of your partition while it it going through defragmentation.

The colors on the displays, with they key designated by the blue box in Figure 7, represent the state of the different sections of the partition. The colors mean the following:

Red Most of the clusters are part of a fragmented file.
Blue Most of the clusters are contiguous files with clusters in the group that contain only free space and contiguous clusters.
Green Most of the clusters are part of a file that cannot be moved from its current location for security or physical reasons.
White Most of the clusters are free space and contiguous clusters

You should let the hard drive defrag your partition, which can take many hours so you may want to do something else for a while. When it is completed, it will give you a summary report and then you can shut the program or defrag any other partitions that you may have. When you are completed your hard drive partition should now be defragmented.

Defragmenter Software for other Operating Systems

In general disk fragmentation is not as much of a problem for Linux or Macintosh based computers.

Most Linux computers use the ext2 or ext3 file system which is known to be resilient against fragmentation and is not as severely affected when it does occur. It is advised that you do not manually defragment these types of file systems.

Macintosh based computers do not require defragmentation as much either. Apple actually recommends you do not defrag your drives if you are using MAC OSX as there will be little benefit. They even state that defragging has the chance of causing a loss of performance.

If you would still like to use a tool that works on an Apple hard drive, the a program that is highly recommended is:

Diskwarrior

Please note that many people have reported that Norton Utilities for Mac can actually cause problems when using their Disk Defrag utility, so it is advised that you do not use that program for these purposes.

Using a spare hard drive to defragment

Probably the best way to defragment your hard drive, if it is in your budget, is to use a spare hard drive. In order to defrag you would copy all the data off the heavily fragmented drive onto a clean spare drive. You would then delete all data on the fragmented drive, and then restore that data back from the spare drive. This will then copy all the data back to the drive in a clean contiguous manner.

This method will work for any operating system.

How to prevent fragmentation

There really is no way to prevent fragmentation as it is a natural process that occurs when writing and deleting data to a hard drive. Some file systems are more resilient to Disk Fragmentation such as NTFS and EX2. If you are a Windows user and are not dual-booting operating systems that are not compatible with NTFS then you should upgrade your file systems to NTFS. Not only will you gain the benefit of a more intelligent file system but you will gain added security benefits as well.

Conclusion

As you can see disk fragmentation can cause varying degrees of problems depending on the operating system you use. If you are a Windows user, then it is advised that you defragment, if you are a Linux or Mac user then it is said to not be as important. If you do choose to defragment your hard drives, the list of tools below can be used for the various operating systems:

Recommended Windows Defragmenter's:

Windows Disk Defragmenter
Speed Disk
Disk Keeper

Recommended Macintosh Programs:

Diskwarrior

As always if you have any comments, questions or suggestions about this tutorial please do not hesitate to tell us in the computer help forums.

--
Lawrence Abrams
Bleeping Computer Basic Concepts Series
BleepingComputer.com: Computer Support & Tutorials for the beginning computer user.

 

Comments:

blog comments powered by Disqus

Advertise   |   About Us   |   User Agreement   |   Privacy Policy   |   Contact Us   |   Sitemap   |   Chat   |   Tutorials   |   Uninstall List
Tech Support Forums   |   The Computer Glossary   |   RSS Feeds   |   Startups   |   The File Database   |   Virus Removal Guides   |   Downloads


© 2003-2014 All Rights Reserved Bleeping Computer LLC.
Site Changelog