Jump to Key Sections
Even if disk optimization is automatic on today’s computers, it is important to know how to perform defragmentation, to plan the operation or to launch it on an external disk without waiting.
Contents
- What is fragmentation?
- Should you defragment your hard drives?
- When should you defragment a hard drive?
- Is it dangerous to defragment an SSD?
- How to defragment a hard disk with Windows?
- Schedule defragmentation in Windows
- Defragment a hard disk with the command prompt
- Defragment a hard drive with specialized software
If you are a computer user, you have already heard about fragmentation and defragmentation of hard disks. Of course, with the development of SSDs, this issue is less crucial today than it used to be, but it is still relevant. It is therefore still useful to understand this phenomenon and to know what solution to implement to limit it.
What is fragmentation?
Every time a file is saved on a computer, it is written to a disk in the form of blocks. To use an analogy, it’s a bit like writing a text in a notebook, with a page-by-page breakdown. At first, when the medium is blank, all the parts are written consecutively, one after the other. But each time a file is deleted, the space it occupied is freed up to accommodate new files that are obviously not the same size. Quite quickly, the new files are cut into different segments – fragments – spread out everywhere. To continue with the notebook analogy, it is as if the texts were scattered over non-consecutive pages. This phenomenon is known as fragmentation.
While fragmentation is not a problem with SSDs, which use electronic circuitry, it is not a problem with magnetic hard drives, which are mechanical devices: like vinyl turntables, they have an arm that moves so that the read/write head is in the right place. And when a drive is highly fragmented, the head is constantly moving to read and write files, which hurts its performance – in terms of access time and throughput – and slows down the computer, making it much less responsive.
And fragmentation is an insidious phenomenon. Because in addition to the files you consciously create or download, there are countless other items that come from operating system updates and invisible data from the Internet – cookies, cache, etc. As a result, whatever you do, your disks become a veritable swamp!
But since this phenomenon has been well known for ages, it is well controlled. And both operating systems and modern hard disks include functions to limit it. Like defragmentation, a function that consists in gathering the scattered fragments of files to speed up their reading. The operation was particularly efficient and sensitive with the first hard disks… and it still is today! But technologies have evolved, and with them the answers provided by new defragmentation and optimization tools for the latest storage media. Let’s take stock.
Should you defragment your hard drives?
Yes, magnetic hard disks should always be defragmented to avoid slowing down file access. But if you have a PC running Windows 7 and a fortiori Windows 8 or 10, or a Mac with an OS less than ten years old, your operating system takes care of everything. At least on internal disks, whether they are hard disks or SSDs. If you haven’t touched any system settings, the system optimizes your disks regularly and automatically, giving priority to the times when you’re not using the computer.
In Windows, the operation is just as automatic as in macOS, but with the tools provided by Microsoft, it is also possible to launch an ad hoc optimization and to modify the defragmentations scheduled by Windows.
A clarification: we do not defragment a physical disk but a partition of a disk, which Windows calls a "drive" (the C: drive, the D: drive, etc.) or a "volume". A single disk can thus have one or more partitions, possibly with different file management systems (NTFS, FAT32, exFAT). Each partition dedicated to users may need optimization, but do not touch hidden partitions and other partitions reserved for the system – especially those dedicated to Windows or macOS recovery.
When should you defragment a hard drive?
As we said above, Windows and macOS already take care of optimizing the operation of your computer’s magnetic hard drives and SSDs on a regular basis.
- If you have a fairly simple use of your computer (you don’t modify many large files), let your operating system do it.
- Leave your laptop plugged into the power outlet during the operation.
- You may want to go to the Windows tools to defragment an external hard drive that you plug in occasionally or to change the weekly disk schedule.
- In order not to see a computer’s performance drop, we think it is important to delete files you no longer use from time to time in order to keep, for example, 10 to 20% of free space on the disk (regardless of its technology). This gives the system more room to store new files, and its defragmentation and optimization mechanisms will take care of the rest.
- On their websites, disk manufacturers offer to download free optimization and repair software (more often for Windows than for macOS and Linux). As an example, our illustration shows the one from Samsung for its SSDs.
- First, refer to the manufacturer’s advice and tools if you notice that the performance of your magnetic disks or SSDs is deteriorating.
Is it necessary to defragment an SSD?
This is a statement that we often hear: "it is dangerous to defragment an SSD". Let’s remember that an SSD is a disk composed only of electronic memory cells (like a USB key), contrary to a magnetic hard disk with its reading head which moves. Three notes on SSDs:
- The usual defragmentation of hard disks has no interest on an SSD, since there is no mechanical arm to move : no matter where a memory cell and a file fragment is located, it is read at electron speed.
- Writing to an SSD increases wear and tear: running a utility that spends time moving file fragments from one location to another could shorten the life of the media.
- Since SSDs and electronic memories still need to be optimized regularly, they have their own optimization mechanisms: they are called TRIM commands.
As you can imagine, this information has been known for a long time to the designers of Windows, macOS and Linux! These operating systems know exactly what kind of storage they are dealing with and for at least ten years they have been running either a defragmentation on a magnetic hard disk or an optimization (TRIM) on an SSD.
Unless you’re using an old PC running Windows XP or Vista, one of the very first SSDs released on the market, or some ancient defragmentation software, you’re not at risk.
So don’t panic if you find that Windows 10 automatically optimizes your SSD every week: it knows what it’s doing.
How to defragment a hard drive with Windows?
- Log into Windows with an Administrator account.
- In File Explorer, right-click on the drive you want to defragment.
- Click Properties on the menu.
- Click on the Tools tab.
- Click the Optimize button.
- The Optimize Drives window shows you the internal and external drives that Windows will accept for defragmenting or optimizing (some storage is not listed here, so that’s not a problem).
- The Media Type column specifies whether it is a hard drive, SSD, removable storage.
- The Current Status column indicates whether Windows thinks a drive needs to be optimized.
- Select a drive and click the Scan button to find out in a few seconds whether it is worth running a defragmentation – which will last longer – on this hard drive. This Scan button is not available for SSD drives.
- Select a drive and click the Optimize button to defragment this hard drive or optimize this SSD.
- The messages provided by Windows when scanning and optimizing are very brief.
Schedule disk defragmentation in Windows
Windows 10 normally optimizes your drives automatically every week. But you can change the schedule of this maintenance.
- Still in the Optimize Drives window, click the Change Settings button to change the scheduling options.
- You may want to uncheck the Scheduled Run checkbox to interrupt Windows defragmentation, but this is not recommended. If you prefer to use another disk defragmentation tool, it will probably handle this option by itself.
- Select a Frequency: Weekly or Monthly seems to be the best option; Daily seems to be really superfluous.
- Leave the Increase task priority box checked if three consecutive scheduled runs are missed: Windows offers to favor the task at the expense of your other activities, it may be worthwhile here.
- Press the Choose button to specify which drives will be subject to scheduled optimization.
- Check or uncheck the box of the drives you are interested in, possibly the one of the new drives that Windows detects.
Defragment a disk with Defrag at the Windows command prompt
Regardless of the version of Windows, it is also possible to launch the Defrag tool at the command prompt, specifying one or more parameters. Without abandoning the command prompt, Windows 10 offers another environment to type commands: Windows PowerShell. The Defrag command works identically in both environments. The disks to be optimized (drives C: D: E:) are called volumes here.
- To launch an analysis or a defragmentation, you must be connected to Windows with an Administrator account.
- In Windows 10, right-click on the Start menu and, depending on your settings, choose Windows PowerShell (admin) or Command Prompt (admin).
- Another method: type the word command in the search field, Windows suggests Command Prompt as the best result, right click on Run as administrator.
- Type defrag /? on the command line to get an explanation of all parameters.
- If necessary, use the middle wheel of your mouse to scroll through the text in the window.
- Type defrag C: D: /M to, for example, defrag C: and D: in parallel (/M).
- Type defrag /C /H /V to, for example, defragment or optimize all internal disks (/C), increasing the priority of the task (normally low priority to let you use the PC without slowing it down too much, /H), and with detailed fragmentation statistics (/V).
- Type the key combination Ctrl+C (hold down the Ctrl key, the right one or the left one, briefly tap the C key and then release Ctrl) to interrupt the operation. There is no risk in interrupting a defragmentation in this way. On the other hand, do not turn off the computer by unplugging it or forcing it to shut down by pressing and holding the power button. Wait until Ctrl+C returns you to the command line.
Defragment a hard disk with specialized software
On Windows, macOS and Linux, there is specialized software – sometimes called defragmenters – to further optimize the defragmentation of magnetic hard disks and/or act more quickly. The operation takes several hours on large hard disks and is best performed at night… Creative people who work with large files, for example, may find it useful. We present some of these utilities in our Download area.
Another possible interest is that the Windows defragmentation and optimization tool does not show you all the drives that File Explorer gives you access to: we found that it hides some external drives that Windows Defragmenter doesn’t want to act on (for example, a partition formatted as exFAT), while it shows others by specifying Optimization not available.
If you want to optimize a drive that is not supported by the Windows tool, or try a hard disk defragmentation even more advanced than the Windows or macOS one, download a free or paid software, for example Defraggler for Windows from Piriform. Avoid downloading software that is too old if you have SSDs (or eMMC memory storage on cheap, lightweight laptops), especially since your operating system already supports SSD optimization.
Upon installation, some utilities let you choose whether to act in addition to the Windows Defrag tool or to replace it (Replace Windows Disk Defragmenter option in our illustration).