Windows 7 / Getting Started

A Defragmentation Crash Course

The best way to ensure maximum performance from your drive is to regularly-weekly or biweekly-defragment it (also called optimizing).

Windows 7 is supposed to defragment your drives automatically; by default, it's scheduled to run at 1:00 a.m. every Wednesday morning from now until the end of time. (Your PC off in the middle of the night? Missed tasks are deferred until the next boot.) Unfortunately, this may never happen until you run the program yourself at least once.

To start Disk Defragmenter, open Windows Explorer, right-click your hard disk, select Properties, choose the Tools tab, and click Defragment Now (or run dfrgui.exe). Click Defragment disk (Figure below) to begin the process.

Disk Defragmenter

Disk Defragmenter should run automatically, but a manual checkup every now and then will make sure it never misses a beat.

Disk Defragmenter does its job by rearranging the files on your hard disk to make them contiguous (not broken into pieces). It also defragments the free space by consolidating your files as much as it can. When run automatically, it has no interface to speak of, but rather runs invisibly in the background.

From Windows 95 all the way to Vista, Microsoft had a habit of further burying Disk Defragmenter in each successive version. But Windows 7 takes a step in the right direction and actually shows the percentage complete of each drive it's queued to defragment. Unfortunately, the severely minimalist design prevents most advanced defragmenting tasks.

For instance, there's no way to defragment the swap file (virtual memory), the hibernation file (hiberfil.sys), the registry, or any other unmovable files. There's no disk map, so there's no visual feedback to tell if there's a large file that won't defragment. If you have more than one hard disk (or partition), there's no way to automatically defragment each of your drives in succession; you either do them all at once, or one at a time by hand. And the scheduler is flaky; don't be surprised if it says "Never run" in the Last Run column, despite the assurance that "Scheduled defragmentation is turned on" at the top of the window.

Now, to be fair, these are some pretty niche features. If you miss the map, advanced settings, reliable scheduling, or detailed reporting of the old-school defragmenters, check out PerfectDisk. It's not free, but there's a time-limited demo on the website.

There's not a whole lot in the way of free defragmenters, but Auslogics Registry Defrag promises to improve Windows performance by shrinking and optimizing your Registry.

Command-line defragmenter

As it turns out, Windows 7's Disk Defragmenter isn't quite as feeble as it first appears. Although it doesn't offer anything close to the usability of Perfect- Disk, there is a little-known command-line version (defrag.exe) that gives you a little more freedom than the one you access through Windows Explorer.

Open a Command Prompt window in administrator mode (right-click the Command Prompt icon in the Start menu and select Run as administrator), and then type the following at the prompt:

defrag c: /a /v

and press Enter to generate a report.
To perform a full defragmentation on a single drive, type:

defrag c: /u

or to defragment all volumes, type:

defrag /c /u

The engine used by defrag.exe is the same as that used by the GUI version (dfrgui.exe). This means that if you start defrag from the command prompt and then press Ctrl-C, it'll stop the operation.

For a quick and dirty defragmentation of a drive (wherein it just groups together all the free space), type:

defrag c: /x

For more options, type defrag -? at the prompt and press Enter. See the next section for an undocumented defrag option.

[Previous] [Contents] [Next]