File fragmentation occurs when data is stored across non-contiguous clusters on a storage device, which can degrade performance and shorten the lifespan of mechanical hard drives. Defragmentation consolidates scattered file clusters and is recommended for HDDs but should not be run on solid-state drives or optical media.
Fragmentation & Storage
Our data gets saved in clusters, and a single file could take up many different clusters, and those clusters don't even need to be next to each other. We call that fragmentation, and it can cause some problems.
Let's say we have a saved file in 11, 12, 13, 14 and 15, so 11, 12, 13, 14 and 15. It takes up all of these clusters right here. But then we go and we save a second file. We're going to call this file two, and so it's taking up, let's say, 16, 17, 21, 22 and 23.
Now, when we go and save more changes to this file right here that needs more clusters, what's going to happen is it's going to start saving in the next available clusters. And now what we've just done is we've created fragmented files.
Fragmentation is when a file is split amongst clusters that aren't right next to each other. So in this case right here, we've got file one that takes up five clusters right here, then we have file two, and now we have file one again. So since the file is split amongst these clusters, file one is now fragmented.
I used my DiskView 64 program to map out the clusters of this drive, and so we can see there's some color coding involved. What I can do is I can go to the Help menu and say Legends to see what the different colors mean, and it actually points out fragmented file clusters, and that's in red.
So what I'm going to do is I'm going to look, and I can see that there are these — let me turn off the highlighter here — we've got these little red dots sprinkled throughout here. So these are the different files that we see, and when you click on them you can see them highlighting different sections. So this file has some clusters here, some clusters here, some clusters here, some clusters here.
I'm going to double click on this to open it up, and we can see a list of all of it. So in total it has 185 clusters that this takes up, but you can see that they're — we call this discontiguous — they're not contiguous, which means they're not in sequence with each other. So here are the different ranges here, and you can see that it's quite a bit broken up into all of these. So this is what's considered a fragmented file.
When we access a file, what's going to happen is it's going to take all of the clusters that have that file in it, assemble it together and put it into the RAM, and then we have access to it.
This can be problematic if we're talking about magnetic storage. With magnetic storage, for instance this hard disk drive, what has to happen is that the spindle turns in order to access different parts of this disc, and then we have this arm that goes back and forth and reads the data on that disc. Now if it's all contiguous, that means the clusters are all lined up, then this arm spins to that location, the spindle spins around, it then loads, brings it into RAM, and now we have access to it. However, if it's in different parts of this disc, then this arm has to go and find those different parts and read the data to put it all together.
Now this causes two problems. Number one, there's a lot of extra searching that happens with this, so it slows the access that we have to that data; it takes a lot longer for it to access all of that data. The other problem is that this device has bearings to it, there's physical movement of it, and over time those parts wear out and we wear them down and this device slows down. So by putting all that extra effort into reading all that data and finding it on different spots of this disc, we're actually reducing the lifespan of this, and this whole drive will slow over time and it will get slower and slower as we're trying to access the data on this device.
Because this can cause problems on some storage devices, there is a process called defragmenting, or defrag. You do a defrag on something like a hard disk drive. What that means is what it'll do is it'll start consolidating these fragmented files into contiguous clusters. And so what that means is that it will rewrite this file one into a different spot on the drive, and then it will remove it from this spot right here. So now we have it all contiguous; it's all in clusters that are in a row on this storage device.
On Windows devices, if I click on the start button and type in defrag or defragment, here pops up Optimize Drives, and it shows the different drives on here and when it's gone through its last routine.
Now, I specifically said defragmentation is a problem on hard disk drives, and we wouldn't necessarily want to have that same process happen on solid state drives. So it knows that this is a solid state drive, and it performs other drive optimization on the solid state drive. But if there was a hard disk drive, then on here we could actually go through the process of defragmenting.
Solid state drives are a different technology, and the way it works works very different. There's no moving parts on this, it's not mechanical, and so it really doesn't matter too much about fragmented files on something like a solid state drive. So we wouldn't really want to run a fragmentation process on a solid state drive, because it doesn't really do anything for us, and then what it would do is it would just put extra load on this device. And these devices can wear out over time as well, so we wouldn't want to go through the process of reducing the lifespan of these devices. So you wouldn't run defragmenting on a solid state device.
CD-ROM technology is a little different. CD stands for compact disc; this is a small disc format. And then ROM stands for read-only memory, which is primarily what CD-ROMs are used for, is for read-only memory, that it has a burned-on image, which means that it doesn't really change, that it's something that's incorporated into it.
There are some writable discs, and with those writable discs, typically what we do with it is we write the files onto the disc, and then once we're done writing the files on the disc we will finalize, we'll do a finalization, and then you can't really write onto the disc after that. That finalization just creates kind of like a file location table where it just tells you what's on the CD, and that's the last step of burning a CD.
There are actually rewritable discs where you can change the information that's on the disc, but those are a little more rare, and it has a very limited lifespan of how much you can actually do that onto these discs.
So ultimately, I guess where I'm going with this is, you wouldn't really need to do a defrag on the disc. Typically what you do on compact discs is you just burn the image or whatever it is onto the disc, and then that's the format, that's what's on it, and from then on it's read-only memory.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →