The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

    Defragmenting boot files under Win7

    Discussion in 'Windows OS and Software' started by ScuderiaConchiglia, Oct 29, 2009.

  1. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    Some time ago I wrote an article here exposing the Tune XP tool's supposed magic for defraging the OS boot files. I found what it did and wrote a method for Vista users to do this boot file defrag themselves.

    Since I just converted to Win7, I was anxious to see how my method worked with Win7. I am happy to report it works well, and in fact under Win7 it is much more illuminating as to what is happening. Follow along below for details.

    First some background info. Win7 and Vista both have an automated process for defragging the boot files. However, under Vista (not sure about Win7 yet) many laptop users never have this automated process kick in. Why? Because the process is designed to start only if the machine is left idle for a period of time. Most laptops are not left idle long enough for the process to trigger, hence the need for a manual way to force the defrag.

    Attached to this post is a file named DefragBootFiles.ZIP. (This is EXACTLY the same file that appeared in my post about defragging Vista boot files.) It contains a batch file with two lines:
    Code:
    Rundll32.exe advapi32.dll,ProcessIdleTasks
    defrag -b %SystemDrive%
    
    (If you choose to create your own file DO NOT NAME IT DEFRAG.BAT! If you do it will cause the batch file to loop over and over!)

    Open the zip file and move the batch file file to your desktop. Close ALL running applications.

    Then right click on it and select run as administrator. The first line just tells Win7 that all applications are idle and it can start a background task that is just sitting there waiting for this event to occur. That task analyzes the boot file history that Win7 maintains and creates a file with the optimum order for these files. The second line starts a specialized defrag process that uses that ordering information and puts these boot files into the proper sequence!

    When you run the batch file it will popup a command window and looks like it is just sitting there hung on the first line. It's not, trust me. Read on...

    If you open Task Manager and view all running processes, the two processes (Defrag and DfrgNTFS) that showed up when we did this under Vista, no longer show up. Instead there is a service that does. In Task Manager if you switch to the Services tab and sort by name you will see defragsvc running. This is a service that is always loaded under Win7 but remains stopped until needed. The line in the batch that forces the idle tasks to start will wake up this service. If you switch to the Performance tab in Task Manager and click the Resource Monitor button, you can then click in the check box to the left of “svchost.exe(defragsvc)" and then open the disk IO segment of the resource monitor. There you can see just the IO that the defragsvc is doing. Also the CPU and DISKIO graphs will then have an additional orange trace just for the stuff the defragsvc is doing. Check this out:

    [​IMG]

    Even cooler, the defrag command in the batch file now has some output. (For those of you who used my batch file under Vista you'll remember that the command window never showed ANYTHING.) If you watch the command window where the batch file is running, when the batch file gets to the second line (and this can take a few minutes as the first line in the batch file takes a while to execute) you will see:

    Code:
    C:\Windows\system32>defrag -b C:
    Microsoft Disk Defragmenter
    Copyright (c) 2007 Microsoft Corp.
    
    Invoking boot optimization on (C:)...
    
    Pre-Defragmentation Report:
    
            Volume Information:
                    Volume size                 = 49.99 GB
                    Free space                  = 21.12 GB
                    Total fragmented space      = 2%
                    Largest free space size     = 4.59 GB
    
            Note: File fragments larger than 64MB are not included in the fragmentation statistics.
    
    When the two lines in the batch file are done the command window will disappear.

    Now some IMPORTANT words of caution: Be patient, give it some time. It can take anywhere from a few seconds to an hour even. Just depends on how fragmented your files are. I just ran it and it took about seven minutes. Your disk drive light will show LOTS of activity.

    Sit back, have a cup of coffee or whatever. Just wait until the command window disappears. That cannot be stressed highly enough! DO NOT CLOSE THE COMMAND WINDOW! BE PATIENT! LET IT FINISH! Now reboot and see if it made any difference in boot time.

    A couple of additional notes:
    First, the defragsvc will continue to show as "running" in the Services tab of Task Manager for a period of time, even after the command window goes away. It will eventually switch back to a "stopped" status all by its self. Second, on a clean install of Win7 you may not see a drastic improvement in boot times. It depends on how many drivers you had to install your self and how many were done by the Win7 install. It is perfectly safe to run this batch whenever you want, but the only time you NEED to run it is after you have updated a driver or an application that loads as a program at boot time or runs as a service (which are always loaded at boot time.)

    One more parting warning: DO NOT CLOSE THE COMMAND WINDOW!

    Gary
     

    Attached Files:

  2. brownstonemr

    brownstonemr Notebook Consultant

    Reputations:
    33
    Messages:
    139
    Likes Received:
    0
    Trophy Points:
    30
    Thx for posting this. Have Win7 64 with a lot of drivers and startup programs installed myself and not through windows update.

    However maybe the automated process had already kicked in cause I ran the file from desktop and there was no time gained when booting up. Shall try again after installing newer drivers or startup programs.
     
  3. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    brownstonemr,

    On a fresh, clean install, I am not surprised at the results you got. There would be very little fragmentation. Plus the jury is still out on how Win7 handles the automated process. They may have fixed it, I just don't know. I do know under Vista, unless you let your laptop sit idle (few of us do), the process never kicked in.

    I think we'll know more over time as we try this after the Win7 has been in wide use for a few months.

    Gary
     
  4. grbac

    grbac Notebook Deity

    Reputations:
    137
    Messages:
    982
    Likes Received:
    0
    Trophy Points:
    30
    Thanks man for sharing that. I just used your method, it finished within few minutes. Maybe BC I use regularly MyDefrag, famous ex-JKDefrag.exe. I'll update later with the gains. +Rep for that.
     
  5. coolguy

    coolguy Notebook Prophet

    Reputations:
    805
    Messages:
    4,679
    Likes Received:
    12
    Trophy Points:
    106
    I ran this in Windows 7 64-bit. The command window opened, "invoking boot file optimization" displayed after some time and then the command windows disappeared. I don't know if the optimization is complete. In the registry entry "HKLM > Dfrg > BootOptimizeFunction, it says "No" for OptimizeComplete.
     
  6. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    Were you monitoring it with TaskManager and Resource monitor as suggested?

    Gary
     
  7. coolguy

    coolguy Notebook Prophet

    Reputations:
    805
    Messages:
    4,679
    Likes Received:
    12
    Trophy Points:
    106
    Finally it ran successfully, when I tried it for the third time. I could see the registry entry "Yes" for BootOptimizeFunction now. I don't what was going on for the first two times I tried. I read somewhere that on a fresh Windows 7 install, Windows takes some time to start the auto boot optimization and the registry entries (not there before) will be created later, as I can see the new entries now.
     
  8. surfasb

    surfasb Titles Shmm-itles

    Reputations:
    2,637
    Messages:
    6,370
    Likes Received:
    0
    Trophy Points:
    205
    Anyone notice a difference after doing this? I need a boot timer program....
     
  9. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    On a clean install or an upgrade? On a clean install you probably won't see much difference. On my upgrade I dropped about 30 seconds off the boot time.

    As with Vista, this defrag will be more beneficial down the road as we install new drivers, new services and new apps that run at boot time.

    I haven't seen any info about whether or not Microsoft tweaked the scheduled task under Win7 that is supposed to do this automatically. The way it was configured under Vista it rarely got run on most laptops.

    Gary
     
  10. J&SinKTO

    J&SinKTO Notebook Deity

    Reputations:
    107
    Messages:
    767
    Likes Received:
    0
    Trophy Points:
    30
    Just ran this on my clean install (Sony FW285). Improved about 15-20 seconds. Thanks much!
    Rep
     
  11. tilleroftheearth

    tilleroftheearth Wisdom listens quietly...

    Reputations:
    5,398
    Messages:
    12,686
    Likes Received:
    2,717
    Trophy Points:
    631
    Just tried this on my VAIO (3+ month old install plus PerfectDisk 10) and boot times got worse.

    I guess PerfectDisk does it better. ;)

    Shut down 13 secs (was 10)
    Boot to DT 57 secs (was 45)
    Usable Tot 145 secs (was 120)

    Above are average of 3 runs for each test.

    same methodology as:
    http://forum.notebookreview.com/showthread.php?t=435052

    This does work good though for newly installed systems.

    However, does the first line 'processidletasks' work in Win 7? I seem to recall that it never did anything for me when the system was newly installed in the summer (2nd line 'defrag' does work, but I had to leave Win 7 at the desktop for a few hours to processidletasks automatically)?
     
  12. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    It works under Win 7, but I am not sure if it is needed for the bootfile defrag under Win7. Under XP and Vista it was, since it caused the task that processes the log of the boot files to kick in. That process prepared the list that the defrag then used.

    RE: Your times going up. What were they before?

    Gary
     
  13. Thibault

    Thibault Banned

    Reputations:
    1,079
    Messages:
    1,319
    Likes Received:
    2
    Trophy Points:
    55
    Thanks for this.
     
  14. davepermen

    davepermen Notebook Nobel Laureate

    Reputations:
    2,972
    Messages:
    7,788
    Likes Received:
    0
    Trophy Points:
    205
    as the first line worked for quite long till it was finished, i guess it does something.. :)
     
  15. tilleroftheearth

    tilleroftheearth Wisdom listens quietly...

    Reputations:
    5,398
    Messages:
    12,686
    Likes Received:
    2,717
    Trophy Points:
    631
    ScuderiaConchiglia andd davepermen,

    having just clean installed Win 7 x64 on a Patriot Torqx 64GB SSD, I just wanted to say that yes, the idleprocesstasks command does work in Win 7 (I guess my running system just does it so fast I didn't think it was working).

    Also of note is that although I had to manually disable the scheduled defrag in Win 7 because of the SSD, when I tried to run 'defrag c: -b' it gave an error that there were some files missing in the registry and did not run it.

    So, I guess Win 7 does turn off defrag for the SSD, but leaves the scheduled defrag enabled just in case you plug mechanical HD's in at a later time.
     
  16. davepermen

    davepermen Notebook Nobel Laureate

    Reputations:
    2,972
    Messages:
    7,788
    Likes Received:
    0
    Trophy Points:
    205
    yes, which is why i allways say DON'T TWEAK THE OS. leave scheduled defrag on.
     
  17. -Amadeus Excello-

    -Amadeus Excello- Notebook Evangelist

    Reputations:
    277
    Messages:
    505
    Likes Received:
    0
    Trophy Points:
    0
    Thanks for bringing this tweak/enhancement to my attention.
     
  18. sgilmore62

    sgilmore62 uber doomer

    Reputations:
    356
    Messages:
    1,897
    Likes Received:
    0
    Trophy Points:
    55
    Try Restart-Time

    [​IMG]
     
  19. surfasb

    surfasb Titles Shmm-itles

    Reputations:
    2,637
    Messages:
    6,370
    Likes Received:
    0
    Trophy Points:
    205
    I'm too lazy to reboot my machine.
     
  20. RD616

    RD616 Notebook Enthusiast

    Reputations:
    0
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    15
    What happens if you do accidentally close the command window during the first line before it finishes?
     
  21. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    You will open a worm hole and warp the space time continuum resulting in annihilation of the universe.

    Seriously, I don't know WHAT might happen. All I can tell you is you should not close it until it finishes. Beyond that I am afraid you are on your own. It might really hose things up resulting in an unbootable machine. It might do no harm at all. I just cant say.

    Gary
     
  22. RD616

    RD616 Notebook Enthusiast

    Reputations:
    0
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    15
    I found that after doing this process my laptop booted up much slower. So I system restored. It appears that doing this boot file defrag actually increased my boot time by 45-60 seconds.
     
  23. DarkSilver

    DarkSilver MSI Afterburner

    Reputations:
    378
    Messages:
    2,249
    Likes Received:
    0
    Trophy Points:
    55
    If you did FULL DEFRAG TO THE WHOLE SYSTEM(included everything) always, this method got no use or very insignificant performance increase.
    However, increased boot-time? It's strange.
     
  24. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    Clearly something went awry. You are the first person to report this. Did you monitor it as shown in the article above? Did you see the screen shown in the "code" window of the article above? Did you leave the command window open until it completed and closed itself? There is no way the process would increase the time if the process ran to completion.

    Gary
     
  25. surfasb

    surfasb Titles Shmm-itles

    Reputations:
    2,637
    Messages:
    6,370
    Likes Received:
    0
    Trophy Points:
    205
    Never cross the streams.
     
  26. TANWare

    TANWare Just This Side of Senile, I think. Super Moderator

    Reputations:
    2,548
    Messages:
    9,585
    Likes Received:
    4,997
    Trophy Points:
    431
    I have a U81a and tried this out, usually I use Diskperfect 10 and here is what I've found;

    1.) boot time to desktop 51 seconds with having run diskperfect timed from power button press.

    2.) After runing the batch boot times went to 65 seconds to desktop from the power button press.

    3.) Ran diskperfect 10, it did show some boot files moved from the front of the drive.

    4.) tested boot from power button press and now 50 second boot to desktop.

    Now it takes from power button press to loosing the bios post 9-10 seconds for me too. So for now I'll keep using Diskperfect 10. Was hoping I didn't have too................
     
  27. darthvader1432

    darthvader1432 - Audiophile -

    Reputations:
    92
    Messages:
    991
    Likes Received:
    0
    Trophy Points:
    30
    wow this really worked, thanks gary. Will this work on windows xp?

    Rep + btw
     
  28. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    Yes it does. See my signature line below for my article on how it works under Vista. It tells the tale of my uncovering what TuneXP was doing to accomplish this under XP. I then wrote the original Vista batch file to do the exact same thing TuneXP was doing. That works fine under XP as well.

    Gary
     
  29. Joe Bleau

    Joe Bleau Notebook Virtuoso

    Reputations:
    341
    Messages:
    2,497
    Likes Received:
    0
    Trophy Points:
    0
    [​IMG]

    OK, I tried the script on my VAIO_F11, i7-720QM, 6 GB memory, GT 330M, Win 7 64-bit Ultimate and 500GB 7200 RPM Seagate Momentus.

    I created a restore point, downloaded the Restart Time small script & after optimizing my Restart time with Autoruns for Windows v9.57, I measured consistently 63 sec. on the Balanced Power Plan & 60 sec on Performance:

    [​IMG]

    Then I ran the DefragBootFiles.bat you suggested following EXACTLY the how-to instructions. It took about 12 minutes to complete:

    [​IMG]

    Then I ran again Restart Time to see the result of the boot files defrag: 85 sec.!

    [​IMG]

    Now I don't know if it's Windows 7 or the utility I found in the OEM recovery disc #2 that I extracted with SonyExtractor_v0.1a: MOD-PC_Boot_Optimization.mod > MOD-PC_Boot_Optimization.EXE > installed as: PC Boot Optimization:

    [​IMG]

    But I ran several time the Restart Time script & my results kept on getting better & better to finally stabilize @ 55 sec.

    [​IMG] [​IMG] [​IMG] [​IMG]
     
  30. LLS

    LLS Notebook Consultant

    Reputations:
    105
    Messages:
    127
    Likes Received:
    0
    Trophy Points:
    30
    Windows defrag utility does this just by using a short command. You just have to open the CMD with admin rights and then run "defrag C: -b".
     
  31. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    That is PRECISELY what the second command is in my batch file. However, for that task to complete properly it needs the list of startup files and the optimization info. That is what the first task in the batch file does. Actually what it does is to tell the system that it is idle and this in turn causes a preexisting task to get its signal to start up. It is that task that prepares the list and optimization info.

    Gary
     
  32. LLS

    LLS Notebook Consultant

    Reputations:
    105
    Messages:
    127
    Likes Received:
    0
    Trophy Points:
    30
    I think that this is needed under Vista, because when I had Vista installed I tried to run directly as I've listed before and didn't work out. Right now I'm running in Windows 7 and it defrags using the CMD without processing the iddle tasks previously.
     
  33. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    The defrag test will always run, and if the idle tasks ever ran before (because you had run my batch or because the machine was allowed to sit idle long enough for the process to kick in on its own) the list of files and optimization info would already exist and would be used. That list is not destroyed after the defrag operation ends. Trouble is that list might not be fully up to date.

    So yes, the defrag might very well run without the first step. But there is really no point in skipping it, so that you are sure you have an up to date list of files and optimization info. It only takes a couple of minutes more and then you are certain of having a fully optimized boot defrag.

    Gary
     
  34. donaldc

    donaldc Notebook Enthusiast

    Reputations:
    0
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    If you use SuperFetch, is this process needed?
     
  35. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    Not related to SuperFetch at all. This organizes the files that are involved in the bootup process BEFORE SuperFetch even begins its work.

    Gary
     
  36. DCMAKER

    DCMAKER Notebook Deity

    Reputations:
    116
    Messages:
    934
    Likes Received:
    0
    Trophy Points:
    0
    question is it possible for you to do the same thing but make it for your steam folder and movies? I would love to see you take it to the next lvl where movies and music can be put on the inner part of the platter and games and apps on the outer part.
     
  37. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    Two points. First, no I can't. I didn't do anything in the first place other than create a batch file which invokes functionality that already existed in Windows. Second, even if I could, it would not really make any real measurable difference. Sure the transfer rate is a bit better at the outer edge, but you will never really notice the difference. It is imperceptible.

    Gary
     
  38. DCMAKER

    DCMAKER Notebook Deity

    Reputations:
    116
    Messages:
    934
    Likes Received:
    0
    Trophy Points:
    0
    Well that blows. On my external there is a huge difference...even on my internals. I put all my games on my external because its far faster. Faster transfer rates would help loading times alot. I have noticed a difference from my internal to my external already. My external outer parts are 130MBps and inner parts are 70-80MBps. Thats a huge difference. My internal has a 50% difference almost too. Here are the benchmarks. Is there any program that can do that?


    ImageShack Album - 3 images
     
  39. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    None that I know of. That's not to say there are none. I just don't know of any. To be honest with you I don't bother chasing down those sorts of performance tweaks, because in my day to day use they just aren't that significant. I don't really care if it takes an extra two seconds to load an app. I don't notice.

    Gary
     
  40. DCMAKER

    DCMAKER Notebook Deity

    Reputations:
    116
    Messages:
    934
    Likes Received:
    0
    Trophy Points:
    0
    alright thx. I'll try to google this but i bet i am out of luck ^^. The only reason why i care is that if i can find a program to do it. It should be easy and not take very much effort to get a nice little boost in load times.


    EDIT: side note check this thread i made. In my process of testing my external and stuff. I found out that HDTune Pro is not accurate. For some reason it gives false results as i show here.

    http://forum.notebookreview.com/win...hdtune-hdtune-pro-inaccurate.html#post6744790
     
  41. mufasis

    mufasis Notebook Geek

    Reputations:
    0
    Messages:
    83
    Likes Received:
    0
    Trophy Points:
    15
    I have been using this on all my computers and just today when I did a fresh install of windows 7 I used it but I got an error that something in the boot registry wasnt there. I ran ccleaner just a little bit before so i am thinking something might have gotten deleted. Any idea?
     
  42. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    I would suspect it is due to ccleaner, one of the reasons I avoid all such programs like the plague. Can you be a bit more specific with the error message? Give us the exact text.

    Gary
     
  43. Deks

    Deks Notebook Prophet

    Reputations:
    1,272
    Messages:
    5,201
    Likes Received:
    2,072
    Trophy Points:
    331
    It's NOT due to CCleaner.

    He/she probably tried running defrag c: -b command on a fresh Windows install or without allowing Windows prior opportunity to optimize itself.

    He/she has to run a command in the command prompt that will force start background idle tasks.
    Type in the following command in command prompt (using admin priviledges):

    Rundll32.exe advapi32.dll,ProcessIdleTasks

    You won't have an indication on how long this forced optimization of background tasks will take (use resource monitor to see your disk activity and everything else for an indication)... give it an hour or two.

    After that, you will be able to use/run the "defrag c: -b" command without a problem.

    I also thought it was due to Ccleaner at first, until I looked into the problem deeper.
    Ccleaner is perfectly safe to use and will NOT delete any vital parts of the registry that Windows needs for it's functions.
    I have yet to encounter such issues.

    I would instead avoid using any other program than Ccleaner for registry cleanup.
     
  44. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    I thought it was funny that your first version of this message admonished me to look it up on Google, since I was the one who started this thread and did the background work to uncover the need to do this with the two steps you show above.

    It may not be CCleaner, but I would still very much like to see the actual text of the error message he got. To be honest, while the ProcessIdleTasks step is necessary, I don't thing running the defrag without it would result in an error message that mentions the registry. But then again, the actual error message text would be VERY helpful.

    I am not a fan of generic use of any registry cleaners and only use them to resolve very specific ERROR situations.

    Gary

    P.S. Upon further reflection you might very well be right, if the ProcessIdleTasks had NEVER EVER been run before (as might be the case on a new install like this), the boot file optimization parameters would not exist and the defrag would not be able to find those parameters. I don't think they are stored in the registry though, BUT a pointer to them MIGHT be put in the registry and that may have been what the defrag was complaining about. But without that error text I am just speculating.

    I have a feeling though that the ProcessIdleTasks step was done since the poster has been using my batch file in the past to boot file defrag other machines.