What is Disk Fragmentation on Windows and how does it optimize your hard disk?

1.20K views

What is Disk Fragmentation on Windows and how does it optimize your hard disk?

In: 57

52 Answers

Anonymous 0 Comments

So, there are a lot of answers here explaining the basics of data storage, but not really showing it, so here it is (extremely simplified) in the form of tables:

|A|A|A|A|A|A|B|B|B|B|C|C|D|D|-|-|
|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|

Imagine this as one continual line where each letter signifies a block of data for a file and a dash signifies empty or unassigned space. When the writer (or reader) head of the hard drives passes above each segment, it reads that piece of data but it must ALWAYS go left or right, it can never skip and it can never ‘just go there’.

If we delete the file A (again, this is extremely simplified) we get this as our line:

|-|-|-|-|-|-|B|B|B|B|C|C|D|D|-|-|
|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|

Now those blocks for data are freed, but physically the read head still has to move past them to get to the other files. Now, this isn’t a problem here because thankfully the other files are stored contiguously anyway, but what happens if we delete and add new files over a few iterations?

|E|E|E|-|-|-|B|B|B|B|C|C|D|D|-|-|
|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|

Adding a new file, E the hard drive places the data in the available unassigned space, again thankfully there is no need to fragment here with these very simple files, and the same happens when we add F

|E|E|E|F|F|-|B|B|B|B|C|C|D|D|-|-|
|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|

Seemingly fine. But what happens if we delete E and add file H which is five blocks in size?

|H|H|H|F|F|H|B|B|B|B|C|C|D|D|H|-|
|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|

It’s starting to get messy.

So as you can see, after adding and deleting a few files we have gotten to the stage that to read file H, the read arm will have to pass over multiple pieces of data needlessly adding to the read time. Multiply this out to massive file sizes on many hundreds of thousands of these ‘blocks’ and you can see why it’d become a problem.

Defragmentation aims to resolve this simply by rearranging these blocks of data so that they are closer together allowing the hard drive to read the necessary pieces of data faster without having to pass over parts that it doesn’t need to.

So hopefully we would end up with something more like this in the end making it easier and faster for the hard drive to read file H:

|H|H|H|H|H|F|F|B|B|B|B|C|C|D|D|-|
|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|

You are viewing 1 out of 52 answers, click here to view all answers.