What is defragmentation?

Defragmentation, also known as defragging or defrag, is the process of rearranging the data on a storage medium, such as a hard disk drive (HDD), for efficient storage and access.

Defragmenting a hard drive can improve a computer's or laptop's performance and speed. To reduce fragmentation, a disk optimization tool typically uses compaction to free up larger areas of space. Certain disk defragmentation tools might try to keep smaller files together, especially if they're often accessed sequentially.

Fragmentation doesn't happen as much in Linux-based file systems as the Linux journaling system stores the data across multiple locations in the disk and automatically moves it around as soon as it senses fragmentation.

Why is defragmentation needed?

Defragmentation can solve and mitigate problems, such as slow speeds, freeze-ups and extended boot times of a computer. If there's not enough contiguous space to hold complete files on an HDD, files can become fragmented and the storage algorithms on the disk separate the data to fit it inside the available space. Defragmentation consolidates these fragmented files so all the related pieces are aligned together.

A fragmented hard drive is similar to a huge, jumbled-up load of laundry, where all the different clothing types and colors are mixed up. Once the HDD is defragmented, the system performance improves because all the jumbled-up data is reorganized and stored appropriately.

The following are the main benefits of defragmenting a hard drive:

  • Files stay organized. Over time, adding and deleting files from a hard drive can make the data scattered, especially if it's running low on storage space. Defragmentation organizes the individual files, resulting in improved hard drive speed.
  • Unused space is freed. Any unused space on a hard drive can be maximized by defragmentation. Sometimes, it can also create more usable space if bits of data are left over from deleted files.
  • The HDD life is extended. With regular defragmentation, the files on a hard drive stay organized. This means the mechanical and spinning components of a hard drive aren't used as extensively, which in turn extends the life span of a hard drive.
Fragmentation and defragmentation of a hard drive.
Visual illustrates a hard drive before and after defragmentation.

How does fragmentation occur?

Fragmentation happens over time and can be caused by many reasons. The following are a few reasons why fragmentation occurs inside a hard drive:

  • If an excessively large file, such as a media or movie file, cannot fit into the empty spaces on a hard drive, fragmentation will occur.
  • If an existing file is updated, but the space it occupies doesn't have room for any new changes, then it will cause fragmentation.
  • The file system -- the part of the operating system (OS) that controls how files are stored -- may break the files into smaller chunks when trying to save them quickly.

How to perform defragmentation

Most contemporary operating systems have built-in disk defragmentation tools that perform the defragmentation process automatically. However, some operating systems, such as Microsoft Windows 7 and beyond, can be defragmented manually.

To manually defragment a hard drive on a Windows 11 machine, take the following steps:

  1. Go to the search bar on the Start menu and type defrag.
  2. On the Defragment and Optimize Drives option, select the drive that needs to be defragmented and click on Optimize.
Screenshot of defragging a hard drive.
Screenshot showing how to defrag a Windows 11 hard drive.

This process is almost identical to defragmenting a server hard drive, such as a Windows Server 2016 or a Windows Server 2022 drive.

How often do you need to defrag a hard drive?

The frequency of defragging a hard drive depends on its usage.

Since modern versions of both Windows and macOS come with built-in optimization tools, there's no need to manually perform defragmentation, especially if the computer is on all the time. However, if a device is routinely shut down after each use, its built-in defragmentation utilities might be prevented from running automatically.

In such cases, running the defragmentation utility once a month is probably a good idea.

When it comes to data storage, a solid-state hybrid (SSHD) drive offers the best of both worlds. Learn how an SSHD differs from a solid-state drive (SSD) and hard disk drive (HDD) and the benefits and drawbacks of using one.

This was last updated in March 2023

Continue Reading About defragmentation

Dig Deeper on Windows Server OS and management

Cloud Computing
Enterprise Desktop
Virtual Desktop