File Fragmentation
When a file's data is stored in non-contiguous chunks across a storage device, potentially slowing access and increasing corruption risk.
Last updated
What Is File Fragmentation?
File fragmentation occurs when the data making up a file is stored in non-contiguous (non-adjacent) blocks on a storage device. Instead of the file being stored in one continuous run of disk blocks, its pieces are scattered across different physical locations.
How Fragmentation Happens
When a file system writes a new file, it places it in the first available contiguous free space. When that file is later modified and grows larger, there may not be enough contiguous space next to it — so the additional data is written elsewhere. The file's data is now split across two locations.
Over time, after many files are created, modified, and deleted, the disk resembles a patchwork of small free spaces and fragments.
Impact on Performance
HDD (Hard Disk Drive): Significant performance impact. An HDD reads by physically moving a mechanical read head across a spinning platter. Fragmentation forces the head to move to multiple locations to read one file — this is slow.
SSD (Solid State Drive): No mechanical parts — fragmentation has negligible performance impact. However, unnecessary writes from the OS defragmenter accelerate SSD wear. Windows automatically disables defragmentation for SSDs and uses TRIM instead.
Fragmentation and File Corruption
Fragmentation itself does not cause corruption under normal operation. However, on a failing HDD:
- Fragmented files have data on more physical disk sectors
- More sectors means higher probability that at least one bad sector affects the file
- Files stored in one contiguous block have lower exposure to bad sector damage
When to Defragment
- HDD on Windows: Windows 11 automatically defrags on a schedule. Manual defrag rarely necessary.
- SSD: Never defragment — it wastes write cycles. Windows handles this automatically.
- macOS: macOS uses HFS+/APFS which includes online defragmentation for frequently-accessed files. No manual action needed.