Defragging rearranges the layout of files on your hard disk for faster access. Specifically when (or even if) you need to do it at all is evolving.
“Defragging” is short for “de-fragmenting” and it’s a process run on most hard drives to help make accessing the files on that disk faster.
Traditionally, it’s something you need to do periodically as files on the disk become more and more fragmented over time (hence, the term ”defragmenting”).
So, what does it mean to be fragmented? Why does it get worse over time?
I’ll review that, as well as how to defragment, when to defragment, and even if you need to worry about defragmenting at all.
To you and me, a file on your disk is a single thing. You open it, you work on it, you save it. It’s a single entity. We might compare it to say a book.
To your computer, however, a file is a lot more like a bunch of pages in that book that it has to keep track of individually.
Imagine that you have a book, but that the pages are randomly scattered throughout your house. You have a list of where each page is, so when you want to read your book you go find page 1, then you look on the list for page 2 and go to that, then look up page 3, and so on. In order to read your book in order, you’re racing around the house like crazy because the pages are all over.
That’s a fragmented file. The sectors1 that make up the file are scattered all over the disk. The result is that when you access the file, Windows has to race all over the
disk to retrieve the whole thing. That takes time.
Defragmentation is nothing more than pulling all the pages/sectors together in order, so that they’re close to each other. In an ideally defragmented disk, the sectors of each file would be in an orderly sequence one right after the other, just like the pages in a book.
Now, UNlike the pages of a book strewn about your home, disk sectors are a little more limited in how they can be laid out. The result is that in order for the sectors of one file to be able to be arranged in a defragmented order, other files or fragments of files may have to be first moved out of the way to make room.
In fact, that’s what a defragmenting tool spends most of its time doing: moving files around on the disk to make room so that other files can be laid out in order.
It’s also one of the things that differentiates one disk defragmenting tool from another: some are simply better or more efficient at moving things around as little as possible so as to be done as quickly as possible with an result that’s as acceptable as possible.
Why fragmentation happens
Fragmentation happens because files on the disk are constantly changing; being created, deleted, grown, or shrunk in size. And all of that happens in a fairly random order.
For example purposes, let’s say we have a very tiny disk that has exactly 12 sectors and no more.
On this disk, we’ve created three files: file1, file2 and file3:
File 1 takes up two sectors, file 2 takes two, and file 3 takes up five sectors on the disk, leaving three sectors free at the end.
We now delete file 2:
As you can see, that leaves a “hole” of two empty sectors between the remaining files 1 and 3.
Now, we’ll create a new file, file 4, which is four sectors long:
The only way to store file 4 is to split it into two fragments: two sectors in part “(a)” and two sectors in part “(b)”.
It’s important to note that this all works just fine. The fact that files are fragmented is handled quite transparently by the operating system and the file system. The various pieces of the files are all kept track of and located as needed.
It’s just that in our silly little example above if we want to read file 4 from end-to-end, we need to spend a little time “skipping over” file 3. If file 4 were in one contiguous set of sectors, it’d be a tiny bit faster.
Making that happen is what defragging is all about.2
But do I need to defrag?
In the past, the answer was a pretty clear yes, but that answer is changing.
- Solid State Drives (SSDs) should not be defragmented. The “tiny delay” in our example above and the real delays in traditional hard disks have to do with the physical movement of the disk read/write head over spinning magnetic material. Movement takes time. In SSDs, there is no movement, and there’s actually no practical advantage to sectors being logically adjacent. Flash memory wears out the more you write to it and not only does defragmenting write to the disk a lot, but the technologies used in flash-based drives to spread the wear and tear over the entire device also often hides the actual physical location so that sectors that might appear to be adjacent actually are not.3
- Windows 7 does it for you. Beginning in Windows 7, there’s an automatically scheduled weekly task to defragment your hard disks. Once a week is just fine and you need do nothing more.
Manually defragging your hard disk is easy.
Start Windows Explorer (Windows Key + E, or right-click on My Computer and click Open), right-click on the drive you want to defrag, click Properties, click the Tools tab and then click Defragment Now….
That’ll open up the Windows Disk Defragmenter:
In Windows 7, you can also adjust the regularly scheduled defragmentation here. Note that my two drives are 0% fragmented, meaning that all (or most all) files are not fragmented. That’s simply a result of the automated task run by Windows 7.4
You can analyze the fragmentation of a drive or you can actually defragment the drive using this tool.
There are also third-party defragmenting tools that can be used. One such example is Piriform’s Defraggler. Windows’ own tool is typically more than sufficient, but outside tools may provide more information or may be able to perform a faster or more thorough defragmentation.