Table of Contents
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.
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
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.
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:
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.
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:
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.
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.
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.
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:
Recommended Macintosh Programs:
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.
Bleeping Computer Basic Concepts Series
BleepingComputer.com: Computer Support & Tutorials for the beginning computer user.
Most people think computers, being electronic devices, don't require any mechanical maintenance, but this is not so. Many computer faults are caused by components overheating due to poor airflow in the case because of a buildup of dirt and dust over time. It's worthwhile cleaning your computer annually or even more often if it is in a particularly dusty environment, on carpet or in a ...
A very common question I am asked is which is more important, the speed of the processor or the amount memory. This is a difficult question to answer and it would help if we had some understanding of what each component does and how they relate to each other. This article will strive to teach you the fundamental tasks of both memory and the cpu and how they relate to each other. Hopefully at the ...
This tutorial is intended to explain what RAM is and give some background on different memory technologies in order to help you identify the RAM in your PC. It will also discuss RAM speed and timing parameters to help you understand the specifications often quoted on vendors' websites. Its final aim is to assist you in upgrading your system by suggesting some tools and strategies to help you ...
This tutorial focuses on using GParted, or Gnome Partition Editor, a free and open source partition editor. To use GParted, you must first download the CD Image file (.iso file) of GParted Live for this program. Instructions on where to find and how to burn the GParted ISO file are covered in the Preparation step. In this tutorial we will be using Microsoft Windows XP for certain steps. If you use ...
Everyone knows what a floppy disk is, but a common question, is how do I clean out a floppy so that it can be used again? I have spoken to many people who have said that after they store information on a floppy they throw them out as they do not know how to erase the files on them so that it is an empty and clean disk. This tutorial will cover how to reformat a floppy disk so that you can reuse it ...