What is defragmentation?
Defragmentation, also known as defragging or defrag, is the process of rearranging data on a storage medium, such as a hard disk drive (HDD), to ensure 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 is less common in Linux-based file systems. The Linux journaling system stores data across multiple locations on the disk and automatically moves it around as soon as it senses fragmentation.
Longtime users of Windows and Mac computers will remember when defragmentation was strictly a manual process they had to initiate themselves. However, Windows and macOS have been automatically defragmenting disks for some time -- Windows, since the Vista release, and macOS since Mac OS X 10.2.
Why is defragmentation important?
Defragmentation can solve and mitigate computer problems such as slow speeds, freezes and extended boot times. If there is 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.
A fragmented hard drive is like a huge, jumbled-up load of laundry, with all the different clothing types and colors mixed up. Once the HDD is defragmented, system performance improves because all the jumbled-up data is reorganized and stored appropriately.
The benefits of defragging
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 scatter the data, especially if it is 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 lifespan of a hard drive.

How does fragmentation occur?
Fragmentation happens over time and can be caused by many different things. 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 does not 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 -- might break the files into smaller chunks when trying to save them quickly.
How to perform defragmentation
Most contemporary OSes have built-in disk defragmentation tools that perform the defragmentation process automatically. However, some OSes, such as Microsoft Windows 7 and beyond, can also be defragmented manually.
To manually defragment a hard drive on a Windows 11 machine, perform the following steps:
- Go to the search bar on the Start menu and type defrag.
- On the Defragment and Optimize Drives option, select the drive that needs to be defragmented and click on Optimize.

This process is almost identical to defragmenting a server hard drive, such as a Windows Server 2016 or a Windows Server 2022 drive.
It is also possible to change the schedule of defragmentation on a Windows 11 machine using the following steps:
- Go to the search bar on the Start menu and type defrag.
- On the Defragment and Optimize Drives option, select the drive where defragmentation needs to be rescheduled, and click on Change settings under Scheduled optimization. Options include daily, weekly, monthly or not at all.
How often do you need to defrag a hard drive?
The frequency of defragging a hard drive depends on its usage. Because 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 always on. 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.
By default, a Windows 11 machine defragments a hard drive once a week; macOS does not have a defragmentation schedule option but defragments in real time.
How long does disk defragmentation take?
The time required for defragmentation of a disk drive can vary considerably, due to the following factors:
- The size of the drive. The larger the drive, the longer the defragmentation process lasts.
- Speed of the hard drive. The faster the drive, the faster the defragmentation process goes.
- Speed of the processor. The faster the processor executes the process, the faster the defragmentation proceeds.
- Fragmentation level. The more fragmented the drive, the longer the defragmentation takes.
- First-time defragmentation. If a hard drive has never been defragmented before, the first time might take longer than normal.
It is also important to remember that solid-state drives do not require defragmentation.
What's the difference between defragmentation and disk cleanup?
The terms defragmentation and disk cleanup are sometimes used interchangeably, but this is incorrect: They are different.
Disk defragmentation is strictly limited to reorganizing the physical storage of data to group related data and improve storage and retrieval efficiency.
Disk cleanup is also about storage efficiency, but its purpose is to remove files from storage that have accumulated over time but are no longer necessary. This includes temp files, system files and other files that are just taking up space.
Primary data storage is often all-flash, but solid-state hybrid drives (SSHD) blend flash and hard disk drives. Learn how an SSHD differs from an SSD and an HDD, and the benefits and drawbacks of each.