“Defragging” is short for de-fragmenting. It’s a process run on most hard drives to make accessing the files on that disk faster. In years past, it’s something you would do periodically, as files on the disk became more and more fragmented over time (hence, the term “defragmenting”).
So, what does it mean for a disk to be fragmented? Why does it get worse over time?
And is defragging something you need to worry about?
Become a Patron of Ask Leo! and go ad-free!
- Fragmentation refers to the physical layout of data on a hard disk. Information that seems logically connected to us might be scattered across a hard disk.
- Defragmentation refers to the process of rearranging the files on disk so that all data is adjoined.
- Fragmentation is a side effect of normal disk usage, including file creation, growth, and deletion.
- If you’re running Windows 7 or later, or you have SSDs, you do not need to defrag manually.
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 a book that it has to keep track of individually.
Imagine the pages of your book 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 consult the list for page 2’s location and go find it, look up page 3, go find it, and so on and so on. In order to read your book in order, you’re racing around the house because the pages are scattered 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 arranging all the pages/sectors together in order so they’re close to each other. In a perfectly 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. In order for the sectors of one file to be arranged in order, other files or fragments of files may have to be 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 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 a result that’s as acceptable as possible.
Why fragmentation happens
Fragmentation happens because files on the disk are constantly changing. They are created or deleted; they grow or shrink in size. And it all happens in a fairly random order.
For purposes of example, 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: File 1, File 2 and File 3.
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. Fragmented files are handled transparently by the operating system and the file system. The various fragments 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, the process would be a tiny bit faster.
Making that happen is what defragging is all about.2 Defragging would potentially move File 3 over two sectors, and move File 4’s (b) fragment to be adjacent to the (a) fragment, resulting in File 4 being contiguous.
But do I need to defrag?
In the past, the answer was a pretty clear “yes”, but things have changed.
- Solid State Drives (SSDs) should not be defragmented. The delays defragmenting seeks to reduce have to do with the hard disk’s read/write head physically spinning over magnetic material. Movement takes time. In SSDs, there is no movement, so there’s no practical advantage to sectors being logically adjacent. Solid state 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 hide the actual physical location — so sectors that might appear to be adjacent actually are not.3
- Windows versions 7 and later do it for you. There’s an automatically scheduled weekly task to defragment your hard disks. Once a week is just fine, and you need do nothing more.
So if either of those things are true — you have SSDs or you run Windows 7 or later — you need do nothing.
If, however, you’re running something earlier than Windows 7 or you suspect that the once-a-week schedule might not be enough, and you have a traditional hard drive, then manual defragmenting might be worth a shot.
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 Optimize.
That opens up “Optimize Drives”, also known as the Windows Disk Defragmenter:
You can adjust your computer’s defragmentation schedule here. Note that my drives are listed as “Needs optimization”. Since they are listed as “Solid state drive”, this is technically incorrect. Scheduled optimization is turned on, so drives are being checked for any needed optimization weekly.
Using this tool, you can analyze the fragmentation of a drive or defragment the drive.
There are also third-party defragmenting tools that can be used. One example is Piriform’s Defraggler. Windows’ own tool is typically more than sufficient, but outside tools may provide more information or be able to perform a faster or more thorough defragmentation.
If you found this article helpful, I'm sure you'll also love Confident Computing! My weekly email newsletter is full of articles that help you solve problems, stay safe, and give you more confidence with technology. Subscribe now and I'll see you there soon,
Footnotes & References
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 hold at least the largest file being defragmented.
3: Although I do recall reading an analysis that seemed to indicate that defragging an SSD did 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.