Helping people with computers... one answer at a time.
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.
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
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.
(This is an update to an article originally published July 16, 2004.)
1: Technically, the information is grouped in "clusters" of sectors, rather than individual sectors. But for purposes of this discussion, the difference is immaterial.
2: It's worth noting that because of the small amount of free space left in our example, defragging may or may not be possible, depending on the tool used. While theoretically it should be possible by shuffling individual sectors around, most tools require enough free space to contain at least the largest file being defragmented.
3: Although I do recall reading an analysis that seemed to indicate that defragging an SSD did indeed improve performance slightly. My recommendation remains don't do it. To me, the risk of wearing it out sooner is too great compared with the small performance improvement that might (or might not) be had.
4: I have two physical drives that Windows defragments once a week. The other two are mounted TrueCrypt volumes, the contents of which I should probably defrag as well.
Article C2123 - October 24, 2012 « »
October 29, 2012 11:46 AM
@Jack
Windows 7 and 8 turn off automatic defragging if they detect an SSD drive.
October 29, 2012 2:15 PM
I've been told that you do not need to defrag a Mac. Does Mac have an SSD?
I see no utility for defragging.
October 29, 2012 2:50 PM
@Robert
Macbook Air is the model with an SSD.
30-Oct-2012
October 30, 2012 2:38 PM
In the example picture of your Disk Defragmenter, when I open mine up like that, it always shows that my C drive is fragmented and that number keeps increasing, right now it's at 34%. But I cannot analyze it or defrag it. Is there a reason for that happening? Should I be able to defrag the C drive? And why does it keep increasing like that? I'm afraid of what will happen when it gets fuller.
31-Oct-2012
November 1, 2012 1:05 PM
The other drives defrag properly, whether with the automatic scheduling in Windows or if I do it manually, although they usually are never more than 2 to 5% fragmented. However, when I click on the C Drive, even to analyze it, nothing at all happens. The same for when I try to defrag it. And then the next time I look at that window, I see the percentage has usually risen by a couple points on the C drive. Should I be able to defrag the hard drive? How do I get that 34% to zero out again, or does it even matter?