I'm an XP user and I've always wondered why files become "fragmented", and why you don't have to deal with defragmenting the hard drive in Linux? Is it something that's Windows-specific or do Linux users have to deal with this problem too?


It's due to how the filesystem is implemented. While you COULD store each byte of your million byte long document on the drive, one, by one, this is obviously horribly inefficient (keep in mind that you need to book keep these bytes.)

So most filesystem work with the concept of "blocks", say 4 kilobytes. So if you have a document taking up 10 kilobytes, it will take up 3 blocks. The last block will only be half-full (you can see this under file properties in Windows. Compare "size" versus "size on disk").

If you later on add to this document, and the following block (that would be the 3th block) is taken up by something else, the filesystem must find this last 1 block elsewhere. This is fragmentation. The document, takes up 4 blocks, but only the first 3 are consecutive on disk. The 4th is located elsewhere. And this can lead to degraded performance.

Now, this is the "classic" explanation to your question. There are many file systems, and they solve this issue in many varied ways.


It isn't really Windows specific, it is file system specific...

Typically, some of the *nix based filing systems defrag as they go along, in the background, automatically.

As for Windows based File systems... If you can imagine writing one thousand bytes of various files to your hard drive in order 1-1000, You then delete the file taking 50-100 creating a gap of 50. You then need to write 75 bytes, so it will fill 50-100 and then write 1001-1025.

So, the new file of 75 is made up of blocks 50-100 and 1001-25, meaning it is fragmented in two places.

Now, imagine that these are on different ends of the hard drive, it could take time to reach all of them, so to defrag, it will move the part of 50-100 and 1001-1025 to take the slot of 1001-1075.

It will also try and move everything down and close all gaps so that there is no gap between 50-100 after it has finished all file operations.

When files are in order, it improves access times considerably as the read head can get it in one "swoop". (obviously, less of a factor and less important with SSDs).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.