“defrag” is short for “defragment”. when a file is saved to a hard drive, it is physically written to the device by a needle. when you need to read the file, the needle moves along the portion of the disk that contains the data to read it.
let’s say you have three files on a hard drive, on a computer running windows. when you created them, windows automatically put them in order. as soon as the data for file A ends, the data for file B begins. but now you want to make file A bigger. file B is in the way, so you can’t just add more to it. your computer can either
a) move file A somewhere else on the drive with more free space. this is a slow operation, and may be impossible if you don’t have much free space remaining.
b) leave a note saying “the rest of the file is over here” and put the new data somewhere else.
option B is what windows will generally do. this means that over time, as you delete and create and change the size of files on your PC, they end up getting split into lots of small pieces. this is bad for performance, because the hard drive platter and needle need to do a lot more moving around to be able to read the data. if a file is in ten pieces, the needle has to move somewhere else ten times just to read that one file.
to fix this, you need to defragment your hard drive. when you do this, windows will take some time to scan the hard drive and look for the files that are split up into multiple pieces, and then it’ll do its best to ensure that they end up split into as few pieces as possible. it also ensures (to some extent) that related files are next to each other – for example, it might put five files it needs to boot up right next to each other to ensure they can be found and read faster. by default, windows 10 defragments your computer weekly at 3am, but you can do it manually at any time. doing it weekly ensures that things never get too messy. leaving a hard drive’s files to get fragmented for several months or even years can cause the defragmentation process to take hours.
many modern file systems use techniques to avoid fragmentation, but no hard drive based system is truly immune to this issue. this isn’t a problem with SSDs, however, as they work completely differently to a hard drive.
a heavily fragmented file system will work, it’ll just be slower, and might wear down the mechanisms of the hard drive a little faster. defragmentation is entirely optional, but a good idea. plus, it’s always cool to watch the windows 98 defrag utility doing its thing!