What is Fragmentation & Defragmentation?

Why Fragmentation Occurs, How Defragging Helps, & If Defragging an SSD is Smart

Illustration of two people putting two large blocks together
Chad J. Shaffer / Getty Images

Fragmentation occurs on a hard drive, a memory module, or other media when data is not written closely enough physically on the drive. Those fragmented, individual pieces of data are referred to generally as fragments.

Defragmentation, then, is the process of un-fragmenting or piecing together, those fragmented files so they sit closer - physically - on the drive or other media, potentially speeding up the drive's ability to access the file.

What Are File Fragments?

Fragments, like I mentioned above, are simply pieces of files that aren't placed next to each other on the drive. That might be kind of strange to think about, and nothing you would ever notice, but it's true.

For example, when you create a new Microsoft Word file, you see the whole file in one place, like on the Desktop or in your Documents folder. You can open it, edit it, remove it, rename it - whatever you want. From your perspective, this is all happening in one place, but in reality, at least physically on the drive, this is often not the case.

Instead, your hard drive is probably saving portions of the file in one area of the storage device while the rest of it exists somewhere else on the device, potentially far away... relatively speaking, of course. When you open the file, your hard drive quickly pulls together all the pieces of the file so it can be used by the rest of your computer system.

When a drive has to read pieces of data from multiple different areas on the drive, it can not access the whole of the data as fast as it could if it had all been written together in the same area of the drive.

Fragmentation: An Analogy

As an analogy, imagine that you want to play a card game that requires an entire deck of cards.

Before you can play the game, you have to retrieve the deck from wherever it might be.

If the cards are spread all over a room, the time needed to gather them together and put them in order would be much greater than if they were sitting on the table, nicely organized.

A deck of cards spread all over a room can be thought of as a fragmented deck of cards, much like the fragmented data on a hard drive that, when gathered together (defragmented), might equal a file you want to open or a process from a particular software program that needs to run.

Why Does Fragmentation Take Place?

Fragments happen when the file system allows gaps to develop between the different pieces of a file. If you know anything about file systems in general, you may have already guessed that the file system was the culprit in this fragmentation business, but why?

Sometimes fragmentation happens because the file system reserved too much space for the file when it was first created, and therefore left open areas around it.

Previously deleted files are also another reason the file system fragments data when written. When a file is removed, it's previously occupied space is now open for new files to be saved to it. As you can imagine, if that now open space isn't large enough to support the whole size of the new file, then only a part of it can be saved there.

The rest must be positioned somewhere else, hopefully, nearby but not always.

Having some pieces of a file in one place while the others are located elsewhere is going to require the hard drive to look through the gaps or spaces occupied by other files until it can gather all the necessary pieces to bring the file together for you.

This method of storing data is completely normal and likely won't ever change. The alternative would be for the file system to constantly reshuffle all existing data on the drive each and every time a file is changed, which would bring the data writing process to a crawl, slowing down everything else with it.

So, while it's frustrating that fragmentation exists, which slows the computer down a little bit, I think about it a "necessary evil" in a sense - this small problem instead of a much larger one.

Defragmentation to the Rescue!

As you know from all the discussion thus far, files on a storage device can be accessed much faster, at least on a traditional hard drive, when the pieces that make them up are close together.

Over time, as more and more fragmentation occurs, there can be a measurable, even noticeable, slowdown. You might experience it as general computer sluggishness but, assuming excessive fragmentation has occurred, much of that slowness may be due to the time it takes your hard drive to access file after file, each in any number of different physical places on the drive.

So, on occasion, defragmentation, or the act of reversing fragmentation (i.e. gathering all the pieces closer together) is a smart computer maintenance task. This is usually just referred to as defragging.

The defragging process isn't something you do manually. Like I mentioned above, your experience with your files is consistent, so there's no rearranging needed on your end. Fragmentation isn't just a disorganized collection of files and folders.

A dedicated defragging tool is what you need. Disk Defragmenter is one such defragger and is included for free in the Windows operating system. That said, there are many third-party options as well, the better of which do a considerably better job at the defragmentation process than Microsoft's built-in tool.

See my List of Free Defrag Software for full, updated reviews of the best ones out there. Defraggler is hands down my favorite one.

Defragging is pretty straightforward and all of those tools have similar interfaces. For the most part, you simply select the drive you want to defrag and tap or click the Defragment or Defrag button. The time it takes to defrag a drive depends mostly on the size of the drive and the level of fragmentation but expect most modern computers and large hard drives to take an hour or more to fully defrag.

Should I Defrag My Solid State Hard Drive?

No, you really should not defrag a solid-state hard drive (SSD). For the most part, defragging an SSD is a wholesale waste of time. Not only that, defragging an SDD will shorten the overall lifespan of the drive.

A solid state drive is a hard drive that has no moving parts. SSDs are basically overgrown versions of the storage used on flash drives and digital cameras.

As you may have already guessed, if a drive doesn't have moving parts, and so nothing to take up time as it moves around gathering all of a file's fragments together, then all the fragments of a file can essentially be accessed at the same time.

All that said - yes, fragmentation does occur on solid state drives because the file system is mostly to blame. However, because performance isn't impacted nearly as much as it is on non-SSDs, you really don't need to ever defrag them.

Another reason you don't need to defrag solid state drives is because you shouldn't defrag them! Doing so will cause them to fail more quickly than they would otherwise. Here's why:

SSDs allow a finite number of writes (i.e. putting information on the drive). Each and every time a defrag is run on a hard drive, it has to move the files from location to another, each time writing the file to a new location. This means the SSD would endure constant writing, over and over again, as the defrag process progresses.

More writing = more wear and tear = earlier death.

So, without a doubt, don't defrag your SSD. Not only is it unhelpful, it's also ultimately damaging. Many defragmenter tools actually won't even give you the option to defrag SSDs, or, if they do, they'll prompt you with a warning that says it's not recommended.

Just to be clear: do defrag your regular, old fashioned, "spinning" hard drives.

More on Defragmentation

Defragmenting a hard drive does not move the reference to the file, only its physical location. In other words, the Microsoft Word document on your desktop isn't going to leave that place when you defrag it. This is true for all fragmented files in any folder.

You shouldn't feel as if you need to defrag your hard drives on any sort of regular schedule. Like all things, however, this will, of course, vary depending on your computer usage, the size of the hard drive and individual files, and the number of files on the device.

If you do choose to defrag, just remember it's completely safe and there's absolutely zero reasons to spend any money on a program to do it: there are many, very good free defrag tools out there!