Defragmenting a hard drive means rearranging the data as saved on the disk so it is in a sequential order. If you imagine a magnetic drive as a sentence, multiple files would read something like "Create file1.txt; Create file2.txt; Add data to file1.txt; Create file3.txt" and so on. Over time as more files are created and updated each file's data is spread out throughout the disk and the drive becomes slower. Degragmention rearranges the files so that the data is sequential: "Create file1.txt; Add data to file1.txt; Create file2.txt; Create file3.txt" and so on. By grouping each file's data into the same area of the disk the performance improves greatly. Solid State Drives (SSD) do not need to be defragmented.
In the maintenance of file systems, defragmentation is a process that reduces the degree of fragmentation It does this by physically organizing the contents of the mass storage device used to store files into the smallest number of contiguous regions (fragments, extents) It also attempts to create larger regions of free space using compaction to impede the return of fragmentation Some defragmentation utilities try to keep smaller files within a single directory together, as they are often accessed in sequence Defragmentation is advantageous and relevant to file systems on electromechanical disk drives (hard disk drives, floppy disk drives and optical disk media)