Why defragging your computer may be a waste of time

If you counted the number of computer troubleshooting web pages that start off with recommendations to defrag your hard drive regularly, well, you'd be counting for a long time.

I just tried a Google search for "Defrag regularly" and got 42,900 results. Of course some of them may have been recommending NOT defragging, but I'll bet most are enthusiastically in favor of it.

In fact, defragmenting may be a total waste of time. It's unlikely to be harmful (though it can be if interrupted by a sudden power failure), but it may actually accomplish nothing worth even the minor effort it takes to run it.

That's especially apt to be true for desktop computer users.

So why do we have all this possibly pointless advice?

It's probably because that in some situations, defragging may speed things up. Someone who uses several large databases (which will include some games, by the way), may benefit. Defragging may also be useful with older computers.

Understand that when I say "old", I mean very old, much older than any system you are likely to own. As an example of a system that is NOT old enough, I'm going to show you some disk fragmentation information from a computer my wife started using in 2006. It ran Windows XP and we never even looked at defragging it until 2008. The picture below shows the fragmentation state of that system then.

An XP computer after 2 years of daily use

I'm going to be referring back to this throughout this article, so you might want to print that out - you can right-click on the image, open it in another tab or window and print it if you like.

What causes fragmentation?

Let's imagine a bookcase.

Wait, we don't need to imagine: I have a bookcase.

A partially filled bookcase

Let's say that bookcase represents my computer hard drive and the books are the programs and files that came with it. Yes, yes, it's a small hard drive and there aren't many programs. I said "represents", didn't I?

Of course the first thing I want to do is buy some more programs - I mean books. Because I am a strange person, I'm going to buy Linux and Unix books. You'd probably buy much more interesting books, but this is MY bookshelf, okay? You fill your bookshelf however you like.

I buy some Unix and Linux books

So I have my new books and it is very nice that I'm able to fit them all together in one spot, because that makes it easier for me to find a particular Linux or Unix book when I want it.

I'm happy.

Well, actually it's often hard for me to find the book I want, but it helps me to look it up on Amazon to see what color the cover it. That helps me find the book on the shelves a bit more quickly, but having similar books grouped together really does help.

I bought more books

Well, the shelf is filling up, isn't it? That's because, silly me, I keep buying more books.

Oh, there's a new Linux book I just bought. Unfortunately, I can't fit it in with the others. It will have to go up on the top shelf. That's not really where I want it, but it would be a pain to rearrange everything.

The new book won't fit with the others

If only I had thought to delete - throw away - an old book before I bought this new one! If I had, there would have been some room right next to the the other Unix and Linux books and I could have snuck it in the newly empty space.

But I didn't. I deleted a book AFTER buying a new one. I now have plenty of room to put things where I want them, but to do that, I need to rearrange - defragment.

I "deleted" an old book but now I need to rearrange (defragment)

There. That wasn't so hard, and now I have my Unix and Linux books together again.

After rearranging, everything is where I want it.

It's a little different with disks

If these books represent files on your computers hard drive, things actually work a little differently. You do buy some whole books, but a lot of what you "buy" on a disk is just new chapters.

Consider your virus definition file. That's something you bought from your Anti-Virus vendor and it got put on the shelf just like one of those Linux books. Other "books" got put on top of it, just like I did here.

But next week, the Anti-Virus people have a new definitions to add to that file or perhaps a larger file to replace the old. Either way, the new file is bigger than the old one. It won't fit where the old one was. What should your computer do?

Fragmentation

Your computer has three basic choices. It could delete the original book and then, because there isn't enough space in that part of the bookcase, it could go look for another place that is big enough to hold the new book. Ideally, that's what it should do.

But what if we really had filled the book case up and had thrown away some books from time to time and from here and there, but there was no one place big enough?

It could rearrange everything, shoving books around, moving them to make room. That's defragging, and it takes time, so it probably won't.

So instead, it puts PART of the "book" (the new virus file) in one empty slot and part in another. The file is now "fragmented" - if we want to read the whole thing, we need to go gather the parts and put them together.

That would take more time, right? That's why people recommend defragmenting your hard drive - to put the fragments together to make them easier to get at.

So we DO need to defrag?

Sure sounds like it, doesn't it?

Well, not so fast.

First. let's think about the kinds of things most home computer users do.

You use your browser, right? That adds a lot of "books". Those are the "Temporary Internet files" that everybody tells you to clean up (delete) when your browser acts up.

If you regularly take photos, you may add those to your computer. If you run Windows, of course you have anti-virus files that get updated frequently. If you get email on your computer (not through your browser), you are constantly growing your Inbox file.

Another place is Windows Update. Those are the patch files that Microsoft wants you to download every now and then. Apple does the same thing. These aren't quite as frequent as your virus updates, but they are likely to get fragmented because of their size.

Look again at that picture of my wife's machine. I used a free utility called Contig to get that report. As I said, this was a system that had been running for two years and had never been defragged. What did Contig have to tell us?

Pretty much what I expected. The virus files are fragmented, so are a few pictures and the rest of it is Windows updates. She didn't use Outlook on this computer, so we don't see those. One of the files is Quickbooks data - that gets updated constantly.

By the way, Mark Russinovitch has other free tools. Another you might be interested in is "PageDefrag", which can defrag Registry files. Again, that's probably silly and unnecessary for most of us, but some people could benefit.

Two things to note: the fragmentation on her drive really isn't bad and secondly, the files that ARE fragmented are files that will quickly become fragmented again in normal activity. We can defrag, but these same files will just pop back a few days or a few weeks later.

One of the reasons for that is that she frequently runs low on disk space. Although that 25 GB drive was pretty good in 2006, it's not a large hard drive by today's standards. If you have a more modern machine, you might have 100 GB or more.

Why is that important? Do you remember that I said that if there was space on the "shelf", the computer could delete the old virus file and put it all in a new space big enough to hold it? Well, if you have a big hard drive and you have not used most of it, there probably IS space.

For example, I'm using a four year old MacBook right now. The free space, the space I am not using, is far larger than that old XP's machine 25 GB drive!

Just for that reason alone, my hard drive is far less likely to have to fragment any files.

File system Design

Wouldn't you have thought that after 2 years of work that old XP machine would have been very fragmented? It was in constant use, browsing, photos, Windows updates.. why was it not highly fragmented?

One reason is that it used a decent file system (NTFS). As the Wikipedia article on fragmentation explains, NTFS is "designed to decrease the likelihood of fragmentation". So is the HFS+ file system used on my Mac. All modern file systems use smart positioning and some even defragment "on the fly". Given their improved brains and the large hard drives in modern systems, it has become much harder to get any significant fragmentation.

Windows XP does some helpful work when you aren't doing anything else, too.

Optimising

There is another reason to move books or files around.

Those Unix and Linux books are probably the ones I need to access most frequently. It would make sense to put them in a convenient spot closer to me.

There are "convenient" places on hard drives too. The outer tracks of a hard disk can actually transfer data more quickly than the inner tracks. It therefore makes sense to put the most frequently used files on the outermost tracks. Disk defragmenters can do that, so that can give some boost.

For most of us, that would be very minor. If you were accessing a very large database frequently, it might make sense to have that put on the outer tracks. Few of us use large files like that on our home computers - even the virus definition files aren't all that large, so having files on the outer track won't help us much.

Mac OS X actually watches this for you as you use your computer and moves the things you use most to what it calls the "Hot Zone" - that's the outer tracks. It also automatically defrags files "on the fly" that need it when you try to access them. See "Do You Need to Defragment a Mac’s Hard Drive?" for more on that.

Most Mac users feel no need to defrag, but if you are the exception, there are tools like Coriolis System's iDefrag. They have a free demo that will not actually defrag, but it will show you what files are fragmented.

Other thoughts

First rule of fragmentation: if you hardly ever USE a particular file, do you care that it is fragmented? No, you do not. For example, Windows Restore point files are fragmented. So what? I'm unlikely to ever need them, and if I do, does it matter that it takes an extra half second to read it? I don't think so.

Second rule: Files that do fragment (virus definitions, Quickbooks, Restore points and the like) are going to become fragmented again very quickly. You can keep defragging every day, but is that really how you want to spend your time?

Chrome "Clear Browsing Data"

Third rule: Some of the things that fragment (or cause other things to fragment) are temporary - like "Temporary Internet Files". A quick and easy way to fix that is to just delete them!

Fourth rule: Big hard drives protect against fragmentation. Keep your junk deleted and there will be space for the things you need.

Given all this, you probably do NOT need to worry about fragmentation. Mac OS X doesn't even include a defragmentation tool. You have one in Windows, but in truth, you may not really need it.

So no one needs to defrag?

That's not to say that no one ever needs a defrag tool. Some people use their systems for different purposes and may have real need. They may even want to buy a third party tool rather than use the tools Microsoft provides. People who regularly access large files which change frequently may find the time spent on defragmentation to be worth their while.

But you and I and most people we know do not. Use a tool like "Contig" if you run Windows to see what really is fragmented. Remember the rule about "if you hardly ever use it" when looking at the report.

If you do decide to defrag, check again a few days later with Contig. Get an idea of how quickly your system typically gets fragmented. If you feel you need to to this regularly, there's no point in doing it more often than you need to (assuming you need to at all). You might also decide that it re-fragments so quickly that there is little to gain.

Also, try using the file(s) you defragged. Does it REALLY make a noticeable difference loading those files? Don't try it until you reboot, because they could be in cache, which makes them load fast anyway. Try it after rebooting - if you can't tell the difference, was it worth your time to do this?

Don't trust speed tests

In the case of my wife's old XP, defragging made no noticeable difference. I might have been able to measure some specific difference if I wanted to, but there was nothing noticeable in real use. Measuring the speed at which a large file can be copied is only meaningful if copying large files is what you do every day. That's the problem with many articles that praise the benefits of defragging: they measure results based on activities you don't actually do!

SOME people need to defragment. Most of us do not.



Got something to add? Send me email.





(OLDER) <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> Why defragging your computer may be a waste of time


6 comments



Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Anthony Lawrence







Sat Sep 3 12:23:52 2011: 9768   BrettLegree

gravatar


I love your book collection :)

I've had the same experiences with defragging. And still, I see big box stores (Staples, I'm looking squarely at YOU) charging people for this hocus pocus.

*sigh*



Sun Sep 4 13:16:45 2011: 9770   AndrewSmallshaw

gravatar


I think it was in Yes Minister (an old British sitcom) where someone said "We must do something. This is something. Therefore we must do this."

Just as governments often feel compelled to be seen to be doing something, even if there is nothing they can actually do, online there are any number of well-intentioned teenagers who feel compelled to provide an answer - any answer - even if the question is so vague and generic that no meaningful and effective answer is possible.

"Why is my computer slow?" Who knows? There are dozens of possible reasons. No-one can diagnose the real issue without much more information. Getting that soon turns into a tremendous time sink so things like defragging are trotted out as a universal panacea. Thus the myth is perpetuated.

Sure, an occasional defrag (annually, or possibly quarterly) gave a noticeable boost to MS-DOS based systems. NTFS on modern Windows systems doesn't have all the anti-fragmentation tricks of some of the more recent Unix systems, but it is still much improved to the point that fragmentation is fairly moot. Even some of the cases highlighted as potentially problematic here are generally not so: for example any decent database will be able to quickly determine the data it needs is on, for example, the 1841st block of the data file. It doesn't read blocks 1-1840 first: it goes straight to where it needs. Any fragmentation in first 1840 blocks is a complete irrelevance to access times.

On other occasions a little fragmentation can be a positive good thing: modern systems are multi-tasking and possibly multi-user. If an application requests 10Mb from the disk in one go that is going to take time to transfer. If another then requests a kilobyte or so it has to wait. If the first large request has to re-seek due to fragmentation, that gives an opportunity for the second request to be dealt with quickly before continuing. The result is that at least it can continue instead of both having to wait.



Sun Sep 4 15:25:10 2011: 9771   BigDumbDInosaur

gravatar


In most cases, the amount of data grabbed during one disk read is small. Defragging isn't going to have any measurable effect on the read's performance unless one block is on cylinder zero and the next is on cylinder 999, in which case a time-consuming (by microprocessor standards) seek will be necessary. Even then, we're talking milliseconds with any reasonable disk. The fact is, modern disks have gotten so fast, the amount of wall-clock time needed to find some data is way too short for anyone to perceive.

In the DOS world using FAT style filesystems, defragging might reclaim some otherwise inaccessible disk space, thanks to the general inefficiency of the FAT structure. The effect will be minimal in the case of NT filesystems with their smaller cluster sizes. Even then, any performance gain due to defragging will most likely be vanishingly small.

Several years ago I replaced the secondary disk (SCSI) in our office file and print server. Now, after restoring all the files I would, in theory, have a fully defragmented filesystem. Did I see any performance improvement? Of course not.



Mon Dec 3 08:53:29 2012: 11472   iwuzicarus

gravatar


At times it's good to keep .iso files defragged. ( contig.exe is fine ) Some USB boot managers can fail when writing ISOs that aren't.



Mon Dec 3 11:37:53 2012: 11473   TonyLawrence

gravatar


I haven't seen that, but I'll let it stand unchallenged for the moment. I do tend to be skeptical of that claim.



Mon Dec 3 14:59:28 2012: 11476   BigDumbDinosaur

gravatar


At times it's good to keep .iso files defragged. ( contig.exe is fine ) Some USB boot managers can fail when writing ISOs that aren't.

I've never heard of such a thing and hold that it's nonsense.

A real filesystem really doesn't care about fragmentation -- that's strictly a matter of how well the low level disk driver and the disk itself can deal with it. All modern filesystems use block-random allocation, which means when a block is needed for a file, the first available one is usually selected, using an algorithm that is specific to the type of filesystem. Similarly, as a file is read, the kernel is merely following the chain of blocks, the details of which are not actually known by the low level disk driver. The driver merely accesses the blocks that it is told to access.

If any failure is going to occur while writing an ISO image it will be in the host system not being able to keep the CD/DVD drive's buffer filled, causing an interrupted write. The only way a non-contiguous file is going to affect the ability to record the image will be in the case where the operating system can't read blocks fast enough due to lots of disk seeking. That's the fault of the hardware, not any "USB boot manager."

------------------------
Kerio Samepage


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us