eli5: what does (de-)fragmentation even mean?

442 views

After reading another post about why defragmentation isn’t as necessary with modern devices, i started wondering what exactly fragmentation even is. How and why does it happen and doesn’t it screw up your data?

In: 0

11 Answers

Anonymous 0 Comments

So, back in the days of spinning hard drives, data was written in a big spiral on the surface of platters. There was an arm that had to physically move across the surface of the drive, to wherever the data you wanted was stored. It could keep track of where everything was written, and what parts of the drive were free to write on. But, waiting on that arm to move was the slowest part of reading data.

As you added data to the drive, it would more or less just add it to the end of that spiral of data. But along the way, you probably would have deleted some files, and eventually, its going to run out of fresh disk to write on, so it starts writing into the gaps formed by deleted files. But, those gaps might be smaller than the file being written, so it would break up new files into pieces that would fit in the open gaps. It would get the file stored, but that means that now, partway through reading the file, the arm has to move to a different spot on the drive, often many times during the file read, which slows read time considerably. When files are split up like that, they’re said to be “fragmented,” since the file has been broken up into multiple fragments across the drive.

Defragmentation is the process of re-organizing the empty space and files on a drive, so that each file can occupy one continuous block of the drive.

The reason its not necessary anymore in the days of soldi state storage are twofold: one, because hard drives had more or less infinite re-writes (they fail because of the moving parts inside. Some of those parts move over 100MPH, so eventually something is going to crash, get stuck, eventually, and it’s just toast, but the magnets don’t really lose their energy. However, solid state drives can only re-write any given bit a finite number of times (it can be tens of thousands to millions of times, but there are a lot of temporary files that come and go and generate a lot of write cycles). And you don’t want to burn up those write cycles just re-arranging which bits hold which data. Especially when you consider the second reason: there are no moving parts, no swing arm that has to come to the data. Every bit of a solid state drive can be read at more or less the same speed, whether its located right next to the previous bit or not. So, it can just find whatever space is free (and it keeps track of those write cycles, so it’ll give preference to using a spot on the drive that’s been used less, to try to wear it more evenly)

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