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


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

In: 57

When you save a file on your computer, it is stored on your hard disk drive. Over time, as you add, delete or modify files, they can get scattered all over the hard disk, leaving gaps of unused space. This is called disk fragmentation.

Disk fragmentation can slow down your computer, as it takes longer for the hard disk to locate and read all the scattered file pieces. To optimize your hard disk, you can use a process called defragmentation, which rearranges the scattered file pieces into contiguous spaces, making it faster and more efficient.

File fragmentation occurs when new data is written into spaces freed by deleting other files. If the new file is bigger than the chosen free section, it must be split into more fragments and writen onto other spots. This slows down access to the data because the reading head must jump around.

Defragmentation rearranges data on a disk to be as contiguous as possible. This means that all files neatly follow one another alphabetically.

The rate of fragmentation depends on how often files get replaced.

In more modern solid state flash memory conventional defragmentation doesn’t work because the actual layout of the data is managed by the device internally and is invisible to the operating system.

If you add a file to your computer, it will be saved on the hard drive. Most of the time, the file is saved as one continuous block of data. Over time, with new files getting added and deleted, a file might get split up into multiple blocks in your hard drive. If you now want to read and use that file, the computer has to find each block of the file, before it can use it. Obviously it is much faster to find just one block than to find multiple, so if your file is scatters all over the hard drive, stuff takes longer to load.

Windows (and the other operating systems probably as well) can optimise your hard disk by looking for each block of a file, and putting them back together in one block. On earlier versions you had to initiate this process manually, nowadays it gets automatically done in the background

It’s disk defragmentation, and it optimizes your hard disk by decreasing fragmentation.

Fragmentation happens naturally over time due to the way hard disks store files. The disk is divided into segments called clusters, that can hold a small chunk of data each, commonly 512 bytes to 4 kilobytes. When files are written, they’re stored in consecutive clusters that can be read quickly as the hard disk platter spins. When a file is deleted, its associated clusters are marked as free.

As more and more files are written, deleted, moved, change size and so on, the pattern of free clusters starts to resemble swiss cheese, and new files are put in the available holes because there are no long continuous sequences of free clusters anymore. This means the hard disk needs to jump around to collect all the different clusters spread across the platter, which is a lot slower.

Disk defragmentation is a sorting program which shuffles around the files between clusters until they can be made continuous again. This requires using the free space on the hard drive as temporary storage, so an almost full disk can take a very long time to defrag.

Most home computers today use a solid state drive (SSD) instead of a hard disk, at least for files where quick access is important. Those don’t have mechanical parts that need time to move into position when eading and writing, so they don’t benefit from being defragged. It is in fact detrimental to them, because writing data to them slowly wears them down, and defraggig entails a whole lot of writing.

This doesn’t apply to newer solid state drives, but rather the slightly older spinning-disk style hard drives.

With the spinning disks, there is a seeker head, like the needle on a record player, that has to physically go to the location on the disk where the relevant bit of information is stored. If all those bits are right in a row on the disk, this is a very quick operation.

However, it can happen that those bits get scattered all over the physical platter, so that the seeker head has to travel to many different places on the disk. That’s called fragmentation, and it makes it take many times longer to read a file.

Defragmenting a disk is the process of taking all those fragmented files, and rewriting them so they’re in nice rows on the disk again.

It mostly doesn’t matter these days though, even if you don’t have an SSD, modern operating systems do a good job of not fragmenting drives too badly. This is mostly something we worried about back in the Windows 98 era and before.