Disk defragging, or more correctly “defragmenting,” is the source of many questions, more than a few misconceptions, and many articles here on Ask Leo!
The good news is that for reasons we’ll explore, defragging in Windows 7 is actually something you rarely need think about any more.
While we’re exploring, we’ll also look at a brief refresher on what fragmentation is, why defragmenting is needed, and how to do it yourself, if you want to. I’ll also address some of the most common myths of defragmenting.
Become a Patron of Ask Leo! and go ad-free!
To summarize from a previous article What is ‘defragging’ and why should I do it?:
Imagine that you have a book, but that the pages are randomly scattered throughout your house. You have a list of where each page is, so when you want to read your book you go find page 1, then you look on the list for page 2 and go to that, then look up page 3, and so on. In order to read your book in order, you’re racing around the house like crazy because the pages are all over.
That’s a fragmented file – lots of “fragments” scattered all over the disk.
It takes time to do all that running around to read the book from beginning to end.
Degfragmenting is nothing more than the hard disk equivalent of collecting up all the pages and putting them next to each other, in order, for every book on your book shelf.
Things are much easier (i.e. quicker) to read when they’re gathered together in order.
Why you needn’t worry about defragging
Let’s fire up the disk defragmenting tool.
In Windows Explorer, right-click on the drive you want to defragment and click Properties:
(In Windows 8 the term “Optimize” is also being used instead of or in addition to, “Defragment”.) This will bring up the disk defragmenting tool:
The first thing that you might notice is this:
By default, Windows will defrag all of the hard drives connected to your machine once a week. In fact, if you look in the “Microsoft” branch of the Windows Task Scheduler (in Start, All Programs, Administrative Tools), you’ll see that there’s a scheduled task for exactly that purpose:
99% of the time, that’s plenty. Even if your machine is off at the scheduled time, Windows will run it as soon as possible thereafter – and only when the machine is idle so as not to interfere with whatever you might be doing.
Let’s say that for some reason, you want to defrag a drive manually. Perhaps it’s become particularly fragmented and you don’t want to wait. Perhaps it’s a drive, such as a removable drive, that the scheduled defragmentation has missed for some reason.
In the disk defragmenter, simply click the disk that you want to defrag and click Defragment disk:
Analyze disk simply updates the “% fragmented” number that appears with each disk. Defragmenting actually begins by updating that number as well.
The time defragmentation takes depends on the size of the disk, the speed of the disk, and how badly fragmented it is. After a potentially long time and many passes,…
the disk is defragmented.
Defragging from the command line
As it turns out, the task that is scheduled to defrag your computer weekly does nothing more than run the command-line version of the defragmenting tool.
You can run that too, if you like.
You’ll need to run the Windows Command Prompt “as administrator” to get the privileges required to run the defragging tool. Click Start, All Programs, Accessories, and then right-click Command Prompt and click Run as administrator.
In the command prompt, type “defrag c:” (without the quotes) to defragment the C: drive:
The command line defrag tool has several additional options, just type “defrag /?” to list them.
Another alternative: Defraggler
Piriform’s Defraggler is an alternative disk defragmenting tool that some people prefer for one or both of two reasons:
- It’s more visually informative
- It’s more aggressive than Windows built-in defragmenting tool
Defraggler displays a continuously updated map of the drive’s defragmentation status as it does its work, very similar to the old Windows XP defragmenting tool:
Those that are so inclined often feel that this gives them a much better sense of what’s happening, as well as more detailed results when the tool is finished.
When it comes to results, however, we need to talk a little about why no defragmentation programs can defragment completely.
Defragging is never perfect
After running a defragmenter on your hard drive, you will find that the drive remains fragmented. In fact, sometimes even running a different defragmentation tool may report a drive as defragmented even though the Windows tool reports it as not fragmented at all.
There are several reasons.
- Some files, like the system paging file and hibernation files, cannot be defragmented while Windows is running. The Windows tool apparently excludes them from the calculation.
- Defragmenting is a surprisingly complex process, and different tools use different algorithms to move file contents around on the disk. Some algorithms are more aggressive than others, at the cost of taking longer.
- Files are in use and being fragmented by other programs – including Windows itself – while the defragmentation process happens.
- Getting a perfectly defragmented disk – when defragged in place1 – may often take significantly more time than it’s actually worth. The thinking is that you’d never notice the performance improvement of defragging that last 3%, which might take significant additional time to achieve. Many defragging programs take this into account and simply defrag to the point of “good enough.”
The point is that “good enough” typically is exactly that – good enough. You really wouldn’t notice the performance increase if you spent the extra time defragmenting completely. (Although it can make sense to defrag the paging file – once – should it be significantly fragmented.)
If you really, really want to get near-perfect defragmentation, you can keep running the defgragging tool over and over. Each run should give you progressively better results, at least for the files that it’s able to defrag.
Debunking defragging myths
Like many things about Windows specifically and computers in general, the whole concept of defragmenting is somewhat mysterious and magical. As a result, there are many misconceptions.
“Defragging frees up disk space” – No, it does not. All defragging does is move files and file parts around on the hard disk. It doesn’t delete, remove, or repair anything. It is only a performance optimization.
- Traditional mechanical magnetic hard disks with spinning platters and moving arms work hard while defragging happens, but they’re built specifically to handle that and work hard at other times as well.
- Defragging your USB thumb drive or other inexpensive flash memory based device will significantly shorten its life, due to the fact that flash memory wears out the more you write to it.
- There may be anecdotal evidence that defragmenting an SSD – also a flash-based technology, albeit of much higher quality – may speed it up. I still strongly recommend not doing it. Ultimately, SSDs are still subject to the wear issues similar to other flash memory and the speed of an SSD shouldn’t depend on “where” the data is stored within it. I wouldn’t risk it.
“Fragmentation/defragmenting will cause my programs to crash” – No. All programs, including Windows itself, are blissfully unaware of fragmentation. Other than files reading or writing more quickly, program behavior is unaffected.