Bill Detwiler: Windows 7’s graphical defragmentation utilityis adequate for most users, but IT pros often need a defrag tool with a littlemore power.
I'm Bill Detwiler, and during this episode of TR Dojo, I'llshow you how to use the Windows 7 defragmentation command line tool to keepyour drives running smoothly. And I’ll show you a hidden switch that lets you
For nearly as long as there have been traditional, platterand spindle hard drives, IT pros and end users have been defragmenting thosedrives – to reduce the delay retrieving related data.
And unless you’re using a solid-state drive, defragmentationshould be part of your normal PC maintenance procedure. In fact, the built-inWindows 7 and Vista Disk Defragmenter utility is configured to run once a weekby default.
If you’d rather not wait for Windows to automatically defragyour drive, you can always launch the tool and manually start the process. Youcan also select which volumes are defragmented, how often the automaticprocedure runs, and at what time of day it will run.
Now, the Windows 7 Disk Defragmenter has a fairly intuitiveinterface, which should be sufficient for most end users. But what if you’re anIT pro, and you prefer working from the command line. Or, you want to create ascript that defragments the machine you support.
Well, that’s where the defrag.exe tool can help. And, notonly will it let you defragment your drive from the command line, but it caneven speed up the defragmentation process.
To use the defrag.exe utility, you’ll first need to open acommand prompt with elevated privileges. So, Click the Start button and typecmd in the Search box. Navigate to the cmd.exe menu item, right-click it, andthen click Run as administrator. After answering the UAC, you should see awindow like the one shown here.
Using defrag.exe is pretty straightforward, simply enterdefrag at the prompt, followed by the letter of the volume you want todefragment.
For example, this command would defragment volume c:.
You can further control of the process by using the toolsvarious parameters. Let’s look at each the ones found in the version ofdefrage.exe included with Windows 7.
The /C option will tell the tool to defragment all localvolumes on the computer
The /E option tells the tool to defragment all local volumeson the computer except those specified
Using the /A option displays the fragmentation analysisreport for the specified volume – without defragmenting it.
The /X option consolidates the volume’s free space duringthe defragmentation process.
/T lets you track a defragmentation operation that’s alreadyin progress on the specified volume
Using the /H option runs the defragmentation process atnormal priority--instead of low, which is the default. This consumers moresystem resource than running the process in low priority, which is the default.But, it can make the process run more quickly.
The /M option lets you defragment multiple volumessimultaneously, in parallel. This is primarily useful for computers that canaccess multiple disks simultaneously; such as those using SCSI or SATA drives.
With the /U switch, the tool will print the progress of theoperation on the screen.
And last on the list of official defrag.exe options is /Vwhich runs the operation in verbose mode.
With all these various options, the defrag.exe utility givesyou more control over the defragmentation process than the graphical interface.
For example, to give the defrag operation for drive C:higher priority, display the progress, and provide the most description duringeach step, you would use a command like this:
Defrag C: /H /U /V
Before I let you go there’s one last defrag.exe switch worthmentioning—that hidden switch I mentioned at the beginning of the show.
If you run defrag against the Windows boot drive, usually c:and include the /B switch, Windows will perform a “boot optimization”. Duringthis process, the tool moves Windows program code to the outside of the disk,making it more efficient to load during startup.
Now, Windows should perform this optimization during thenormal defragmentation operation. But sometimes this option isn’t set in theRegistry and sometime you may just want to defrag just the boot files withoutrunning a full disk defragmentation.
Well that does it for this edition of TR Dojo. Thanks toTechRepublic editor Mark Kaelin, who put this tip together.
And as always, for more teachings on YOUR path to becomingan IT Ninja, visit trdojo.techrepublic.com, sign-up for our newsletter, orfollow me on Twitter.
Thanks for visiting the TR Dojo.