How-To Geek

Defragment Your System Files (Pagefile and Registry) in Windows XP

In the pursuit for performance, making sure your drive isn’t fragmented is a regular task. The problem is that Windows XP doesn’t allow certain system files to be defragmented without commercial software. What about free solutions?

There’s a utility called PageDefrag from Sysinternals (Microsoft) that lets you do one single task, and it does it well. It runs as a boot-time process that defragments the system files before they are locked by XP.

Thanks to Reader Shawn for suggesting this as a topic.

Defragment Your System Files

When you open up the application, you’ll see a list of the system files and the number of fragments each file is in. Select the “Defragment at next boot” option, or you could even choose to defragment at every boot, although I wouldn’t necessarily recommend that.


When you reboot, you’ll be prompted by PageDefrag to hit a key if you don’t want to defragment now.


If you didn’t abort the defrag, you’ll now see the defragment in process. As you can see, mine didn’t need to be defragmented anyway…


If you selected the option to defragment on every boot but would like to remove it, you can open up the application and select “Don’t defragment (uninstall)”, and then click the OK button.


This should be an essential utility in any geek’s toolkit. Note that this isn’t a substitute for defragmenting your other files on a regular basis.

Download PageDefrag from

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 03/4/08

Comments (22)

  1. JCB2

    Very nice, I’ve been looking for an application similar to this for ages now.

  2. Eddie Clark

    You do a great job. I wish I knew 1/4 as much. Keep up the good work. Eddie

  3. jambarama

    You won’t need this program most of the time, but when it is needed there is nothing like it. System file fragmentation really will hurt performance, especially on machines with lower memory and slow hard drives. This program is part of the incomparable sysinternals suite:

    To see if you need to run program, just start it. As you can see in the image above, all of the How-To Geek’s system files were already in 1 piece, and you can’t do better than that. Most of the time this will be true. I’ve only run into system file fragmentation trouble on a machine with very limited hard drive space.

  4. Zac Garrett

    I personally do not see a big need for this tool, like others have said. Unless you install and uninstall a ton of software and its been years since your last reformat it won’t really do much good.

    For my systems I’ve got a cron (technically a automated task in the Windows world) to automatically defrag using contig. This is the best lightweight and totally functional tool for defragging a hard drive.

    It should be noted that the computers I run a defrag on each night do video editing. They move massive chunks of data around and therefore need to be defragmented quite often. Weekly would work, but nightly is even better in my situation.

  5. Planet Lowyat

    I used TuneXP

  6. The Geek

    This definitely isn’t something you need to run all the time… it’s just a one of a kind tool that really does it’s job well.

    If your pagefile is configured to grow automatically it can get fragmented. The same problem happens with the hibernate file…. if you run disk cleanup it removes the file, so when it’s created again it might be fragmented.

    The registry is probably less likely to be fragmented, but it’s certainly possible over time.

  7. fig455

    Thanks, I have been wanting a utility like this.

  8. Chris

    I noticed this article is in the xp section? Would this also needed to be done on vista machines?

  9. mgo

    Another helpful defrag item: From the command line (in either XP or Vista) run “defrag c: -b” This is a undocumented but legit command to defragment the prefetch folder in XP or the Superfetch folder in Vista. First time you run it, it may take several minutes. After that, it’s pretty quick.

  10. ankit agarwal

    when i try to defragment my c drive in which windows xp is installed ,it shows an error of missing file “some ‘.dll’ file” to check the disk and defragment the drive .please reply me as soon as possible .

  11. Matt

    I used to use this all the time on older machines that I had. it worked great. most of the time when it ran, it just took a few seconds. I haven’t yet tried it in vista.

  12. deedhoet

    i tried to imitate linux, making dedicated partition for paging file, fixed size paging file & moving temporary folder to that partition => reducing system file fragmentation. I wonder how to move registry file…

  13. ana

    i know i’m a bit (to much) off topic, but i’m wondering how did you managed to take a chkdsk screenshot? google gave me no answer. help?
    as about the application, now at least i know that i have no reason to worry about my system files, since they’re looking quite like yours…

  14. Olly

    On the command line, first I use:

    rundll32.exe advapi32.dll,ProcessIdleTasks


    defrag c: -b

    NOTE: ProcessIdleTasks is case sensitive! No space between advapi32.dll and the comma and the ProcessIdleTasks. The first command line ensures all your files in the prefetch folder are updated (the prefetch folder only works when taskmgr.exe is running – check your processes), and the last uses the files layout.ini and ntosboot files in prefetch to defrag your boot files.

  15. CSB

    it does not work on the custom managed page file on vista.

  16. Biep

    I need something related, but not quite this.
    My C: drive is littered with small (unfragmented) system files that make it impossible for any defragmenter to free a large continuous space. How do I move all these small files to a corner?

  17. Larry Miller

    PageDefrag is essentially a solution looking for a problem. Except in extreme cases pagefile fragmentation will have virtually no impact on performance. If you do use this tool it need be used only once. The pagefile does not become fragmented with use, even if it is system managed. Anyone who claims otherwise is misinformed. After the pagefile is defragged it will stay that way, even after months of heavy use. Running this tool on every boot is silly and will accomplish nothing except lengthen boot times.

    To see if you need this tool:
    Look at the report in the standard defrag program. Divide size of the pagefile by the number of pagefile fragments (usually 1). If the result is over 1MB (highly likely) you do not need PageDefrag.

    Larry Miller
    Microsoft MCSA

  18. Steve

    It doesn’t move my system files. They are still spread out in the middle of nowhere.

  19. Navvie

    Biep… if you haven’t found something already, MyDefrag is excellent at doing this.

    Larry… before I was educated enough to set fixed size page files I have seen page files on many many PCs (I am tech support for friends and family) that are fragmented, it all depends on how full the partition where the pagefile exists is. If there isn’t space to extend the existing pagefile, space will be used where it is available.

  20. virpi

    thank you

  21. bob

    I can vouch for the sometimes usefulness of such a tool. I am currently running another one (puran), however here is what it is telling me

    Pagefile Fragments: 76,808
    MFT Fragments: 2
    Registry Fragments: 260

    While I am not saying this is an everyday problem (this XP build is 5 years old), people who like to push the useful life of their PC’s may well find this tool incredibly useful, if very occasionally.

  22. matt

    wondering about those registry entries, some games/software if you have add ons they do not delete the add on keys such as “Elderscrolls Oblivion” not deleting “Shimering Isles” key when you uninstall it, how inconsiderate of bethesda! anyway this is good, my PC still exits slower than normal in Windows XPPro SP3. don’t know why, deleted all the Securom with that utility on the “Securom” site.

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!