Follow this blog:
RSS
Email Alert

TR Dojo

Defrag and optimize your hard drive with the Windows defrag.exe command line tool

Takeaway: Bill Detwiler shows you how to defragment a hard drive from the Windows 7 command line, and use defrag.exe’s hidden “boot optimization” switch.

For nearly as long as there have been traditional, platter and spindle hard drives, IT pros and end users have been defragmenting those drives–to reduce the delay retrieving related data.

And unless you’re using a solid-state drive, defragmentation should be part of your normal PC maintenance procedure. In fact, the built-in Windows 7 and Vista Disk Defragmenter utility is configured to run once a week by default.

But what if you’re an IT pro, and you prefer working from the command line. Or, you want to create a script that defragments the machines you support. Well, that’s where the defrag.exe command line tool can help.
During this week’s TR Dojo episode, I show you how to defragment a hard drive using the Windows defrag.exe command line utility, and use the tool’s hidden “boot optimization” switch.

June 15, 2011, 1:27 PM PDT | Length:00:06:04

View Transcript

Have you ever used the Windows defrag.exe command line utility?

Check out the following TechRepublic resources for more defragmentation tips and tools :

For those who prefer text to video, click the View Transcript link below the video player window or check out Mark Kaelin’s article, “Exert control and defrag from the command line in Windows 7,” on which this video is based.

You can also sign up to receive the latest TR Dojo lessons through one or more of the following methods:

Get IT Tips, news, and reviews delivered directly to your inbox by subscribing to TechRepublic’s free newsletters.

Bill Detwiler

About Bill Detwiler

Bill Detwiler is Head Technology Editor of TechRepublic. Previously, he worked as a Support Tech and IT Manager in the social research and energy industries.

Bill Detwiler

Bill Detwiler
Bill Detwiler is Head Technology Editor for TechRepublic. Previously he worked as a Technical Support Associate and Information Technology Manager in the social research and energy industries. Bill is a Microsoft Certified Professional with experience in Windows administration, data management, desktop support, and system security.

Bill Detwiler

Bill Detwiler
Bill Detwiler has nothing to disclose. He doesn't hold investments in the technology companies he covers.

Transcript

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.

9
Comments

Join the conversation!

Follow via:
RSS
Email Alert