Tuesday 20 November 2012

Windows Defrag

Defragmenting the Windows hard drive

 Defragmenting the hard drive. Before we go into defragmenting the hard drive it will be useful to explain what fragmentation is and how it occurs. On a hard disk information is stored in segments called sectors, each sector is 512 bytes in length. The Windows operating system stores files in units of multiple sectors called clusters or allocation units. Typically a cluster will be 4 kilo bytes. Files are placed on a Windows disk in the first available space and are allocated complete clusters. So if we have a file that is 1kb long it will occupy one cluster, a 5kb file would occupy two clusters a 21kb file will occupy six clusters. In a perfect world files would occupy consecutive clusters making ready and writing the files faster. As we use a computer we are continually adding and removing files. Consider what would happen in a simple system or three 3Kb files on a disk that had four clusters numbered one to four. Each file would occupy one cluster, file on occupying cluster one and file two occupying cluster two and so on. If we deleted the second file, cluster two would become empty, if we later added a fourth file that was 7Kb long. The fourth file would need to occupy two clusters. When we write the file the operating system will see cluster two as empty and write part of the file there. As the fourth file needs two clusters the second bit of file four would go into cluster four. The two parts of file four and not next to each other. We call this fragmentation. So now we know what fragmentation is and that it slows down the system, how do we get rid of it?

 Defragmenting a drive

 There are many freely available tools to defragment a drive, indeed Windows comes with the graphical Disk Defragmenter dfrgui.exe and the command line Defrag.exe. Both are good, free and already on your Windows PC!


Defraggler options
Defraggler options
However I prefer a third party tool called df.exe for scripting and defraggler as a gui tool. Both have more options than Windows built in defragmenters and both come from Piriform www.piriform.com. With Defraggler you can select to defrag file, folders or the entire drive. There are many options available. Defraggler is also portable. If a drive has not been defragmented previously, especially one that is heavily fragmented, say 20%, it will benefit from several consecutive runs of the defragger. What happens when you run a defragger is that the program woks out how best to shuffle the files around to achieve least fragmentation. It never does a perfect job, but each attempt will take it a step closer to that goal. Once you get down to say 5% fragmentation you are at the limits of practicability and will get diminishing returns for each re run.


So how often should you run a defrag, well that depends and really may be just a mater of opinion. I would suggest that once a drive is reasonably defragmented then keeping it that way can be achieved by defragging once every month or two.

No comments:

Post a Comment