Quantcast Defragmenting boot files under Win7

Closed Thread
Page 1 of 5 12345 LastLast
Results 1 to 10 of 44
  1. #1
    NBR Vaio Team Curmudgeon
    Join Date
    Jun 2007
    Posts
    6,028
    Rep Power
    41

    Default Defragmenting boot files under Win7

    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:



    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 Attached Files

  2. #2
    Notebook Consultant
    Join Date
    Jul 2008
    Posts
    139
    Rep Power
    12

    Default Re: Defragmenting boot files under Win7

    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. #3
    NBR Vaio Team Curmudgeon
    Join Date
    Jun 2007
    Posts
    6,028
    Rep Power
    41

    Default Re: Defragmenting boot files under Win7

    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. #4
    Notebook Deity
    Join Date
    Nov 2007
    Location
    Zagreb, Croatia
    Posts
    973
    Rep Power
    17

    Default Re: Defragmenting boot files under Win7

    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. Clevo W860CU - 720QM, 4GB DDR3, GF GTX 285M, 320GB, 15.6" 1920x1080
    4. Compal JFL92 T9300 2.5GHz,8600M GT 512MB,2GB DDR2,100GB,15.4" 1680x1050
    3. Compal HEL80 T7200 2.0GHz,7600M GT 256MB,2GB DDR2,120GB,15.4" 1280x800
    2. Gericom Supersonic Pentium M 740 1.73GHz,Go6600 128 MB,1GB RAM,80GB,15,4" 1280x800
    1. Gericom Hummer P4 3.06GHz,FX5600 128MB,512MB RAM,60GB,15" 1024x768

  5. #5
    Notebook Prophet
    Join Date
    Jun 2007
    Posts
    4,653
    Rep Power
    33

    Default Re: Defragmenting boot files under Win7

    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. #6
    NBR Vaio Team Curmudgeon
    Join Date
    Jun 2007
    Posts
    6,028
    Rep Power
    41

    Default Re: Defragmenting boot files under Win7

    Were you monitoring it with TaskManager and Resource monitor as suggested?

    Gary

  7. #7
    Notebook Prophet
    Join Date
    Jun 2007
    Posts
    4,653
    Rep Power
    33

    Default Re: Defragmenting boot files under Win7

    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. #8
    Titles Shmm-itles
    Join Date
    Aug 2007
    Location
    Austin, TX
    Posts
    6,372
    Rep Power
    42

    Default Re: Defragmenting boot files under Win7

    Anyone notice a difference after doing this? I need a boot timer program....
    Dell Inspiron 1420 HP tz2500 Tablet PC Lenovo X200T Dell XT2 x 2
    Too close for missiles/ Switching to guns
    Jack Daniels/ Jim Beam/ Johnnie Walker/ Jose Cuervo

  9. #9
    NBR Vaio Team Curmudgeon
    Join Date
    Jun 2007
    Posts
    6,028
    Rep Power
    41

    Default Re: Defragmenting boot files under Win7

    Quote Originally Posted by surfasb View Post
    Anyone notice a difference after doing this? I need a boot timer program....
    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. #10
    Notebook Deity
    Join Date
    Oct 2008
    Posts
    767
    Rep Power
    15

    Default Re: Defragmenting boot files under Win7

    Just ran this on my clean install (Sony FW285). Improved about 15-20 seconds. Thanks much!
    Rep

 

 
Page 1 of 5 12345 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -4. The time now is 11:57 PM.
Powered by vBulletin® Version 4.2.0
Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.
SEO by vBSEO 3.6.0