“Defragging” is short for “de-fragmenting” and 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 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?
And is defragging something you need to worry about these days at all.
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 contiguous to us might be scattered across a hard disk.
- Defragmentation refers to the process of rearranging the files on disk so that all parts are contiguous.
- Fragmentation is a side effect of normal disk usage, 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 that 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 look on the list for page 2 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 like crazy 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 that 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. The result is 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 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 it all 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 this all works just fine. That files are fragmented is handled transparently by the operating system and the file system. The various fragments 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 exactly 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 in two important ways:
- Solid State Drives (SSDs) should not be defragmented. The delays defragmenting seeks to reduce have to do with the physical movement of a hard disk disk read/write head over spinning magnetic material. Movement takes time. In SSDs, there is no movement, so there’s no practical 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 hides the actual physical location so that 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 only SSDs, or you run Windows 7 or later — you need do nothing.
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’ll open up “Optimize Drives”, also known as the Windows Disk Defragmenter:
You can also adjust the regularly scheduled defragmentation 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.
You can analyze the fragmentation of a drive or you can 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.
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 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 <strong>don’t do it</strong>. 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.