When you defrag files the pieces of the file are physically arranged for quicker access. But you can't defrag some files. At least, not easily.
Actually, this is not necessarily a problem. It’s not at all uncommon to have some files that refuse to defrag, and that’s quite alright. Chances are it won’t impact performance in any noticeable way, and that’s really what defragging is all about: improving performance.
Let’s look at some of the reasons, and some of the ways to force the issue if you still feel you need to.
Defragging, or more properly, defragmenting, is the process of taking all the parts or “fragments” of a file on your hard disk and making sure that they are physically next to each other, and in order.
Files don’t need to be that way: the first part of your file could be on the outer rim of the hard disk, the next part somewhere on the inner portion, and other parts scattered everywhere in between.
The “problem” that defragging solves is simply that when all those pieces are next to each other and in order, the hard disk has to do a lot less work to access the file.
There are several technical approaches to defragging, but most require that you have enough free space on your hard disk for a copy of the largest file that needs defragging. No, that’s not technically necessary, but it makes the defragmenting tool significantly simpler, faster and otherwise more reliable.
As a result, many, if not most defragmenting tools just require some fairly random percentage of free space, like 10% or 15%. If there’s not enough room for a second, temporary, copy of a file that needs to be defragmented, then that file cannot be processed.
The most common reason files do not get successfully defragged is simply that there’s not enough free space on the hard disk to do so.
The second most common cause is that the file is in use by some program.
That’s why most defragging utilities suggest you close down all running programs prior to attempting to defrag. One of the things you can do when you run into this situation is to look at the list of files that were not defragged and see if they are in use. This article: How can I find out who is using a “file in use”? explains how. If you can, you can then close the program that has the file open, and try defragging again.
The next problem is that the operating system itself, as part of its normal workings, often has files open in such a way that those files cannot be defragged. One very common example is windows paging or swap file. The folks out at Sysinternals.com have a free utility, PageDefrag for just this purpose. It can schedule a defrag of the system files on your next boot, before the system is actually running.
My question to you is a simple one: why bother?
Defragging the files you can defrag easily, and doing so regularly, gets you 99% of the performance gain you’re looking for anyway. Jumping through these extra hoops to get the system files defragged is typically just not worth it, unless you’ve determined that these files are severely fragmented. And that’s rare.
My recommendation is to simply do the normal defrag “every so often”.
In fact Windows 7 and better will do it automatically for you, once a week.