How to Perform a Full Manual Defragmentation of Your Hard Disk Under Windows Vista

Using Windows Vista's command line defragmenter to really defrag your hard disk


How to Perform a Full Manual Defragmentation of Your Hard Disk Under Windows Vista

If you have tried doing a defragmentation of your hard disk under Windows Vista, you would have noticed that the defrag utility does not really give you any detailed information about your hard disk fragmentation level, show you the defragmentation progress while defragging, and in certain situations even defragment when you ask it to. This guide shows you how you can perform a full defrag of your hard disk under Vista and get at least a basic report on your hard disk fragmentation before and after defragmentation.

What's Happening Here

There are a number of changes between Windows Vista's defragmenter and XP's defrag tool. In general, Vista's defragger is designed for the average user and is thus tuned for automatic behind-the-scenes work: by default, the defrag utility is scheduled to run weekly. It defragments all the partitions on all your hard disks automatically. Unlike the Windows XP defragmentation tool however, it will only defragment files with fragments smaller than 64 MB on NTFS file systems. The lack of any useful user interface in the Vista defrag utility is consistent with this design decision of having an automated defragger running behind the scenes without user intervention.

Before you get too upset, let me say that this is a generally useful setting for the average user. Let's face it, if you are reading this, you are not an average user. Many users I know don't defragment their hard disks. They don't even know the concept, let alone how to get it done or what use it may serve. The default Vista setting is sensible for such users —a weekly schedule is more than adequate: too frequent and the constant defragmentation causes additional wear and tear on the hard disk for very little additional gain. And for most people, not moving file fragments if they are more than 64 MB is a good compromise —it speeds up the whole defragging process, and the fragments are large enough so that in most cases they don't cause significant slowdowns in the system.

Manual Defragmentation

There are of course reasons why you might want to override this default mechanism. For example, a full defragmentation of the hard disk may speed up certain hard disk backup operations. If you're doing it on a large scale with many computers, the time savings when backing up a properly defragged hard disk compared to one where the files are broken into many fragments may be significant. Another possible reason might be if you are capturing video on your computer and don't want any frames to be skipped; if the disk is fragmented without a contiguous free space for the entire video file, the hard disk head may have to skip over occupied sectors in the middle of recording, causing your recording software to skip frames.

To get Vista's defragger to give you some information about your hard disk, and to control which hard disk or partition it defragments, you will need to use the command line defragmentation utility. It will still not give you any feedback while defragmenting, just as the GUI version of the defragmenter will not, but at least you can get information on the fragmentation level of your hard disk, control whether to defragment even if the file fragments are larger than 64 MB, and control which partition or hard disk to defragment.

To use the command line defrag tool in Windows Vista, you have to run the Command Prompt as an administrator. In Vista, this is not automatic even if you are logged in as the administrator. Click the Windows button (previously the Start button in earlier versions of Windows), the All Programs menu item and the Accessories menu item. Right click the "Command Prompt" button and select "Run as administrator". A command prompt window will appear. Everything you run in this Window will be run with administrator rights.

  1. To view a file fragmentation analysis of (say) your C: drive, type:

    defrag c: -a -v
    

    The "-a" parameter tells the defragger to perform a fragmentation analysis. The "-v" option tells it to be verbose in its report. If you want a report on drive D: or some other drive, substitute that drive letter in place of c:.

    Be aware that defrag may tell you that you have no fragmented files even if you have some. On NTFS partitions, the reporting function of defrag does not consider fragmented files with fragments greater than 64 MB as fragmented. If you need truly detailed information, you may have to consider getting a third party defragmenter such as those listed on the Free Defragmentation Utilities page on thefreecountry.com.

  2. To defragment a particular drive, say C:, type:

    defrag c: -v -r
    

    The "-r" option tells the defragmentation utility to treat files that are fragmented with 64 MB fragments or larger as though they are not fragmented. This partial defragmentation is the default for "defrag", and it's the only way the GUI defragmenter in Vista works.

    You can also force the defragmenter to defragment everything. That is, even if the file fragments are larger than 64MB, the Vista defragmenter will still attempt to put the file into contiguous sectors. To do this, run the defragger with the following options:

    defrag c: -v -w
    

    As you have probably have guessed, "-w" tells the Vista defrag tool to do a full defragmentation. All file fragments will be consolidated where possible.

    You will still not get any feedback as to the progress of the defragmentation with the command line tool, just as you did not with the GUI version. However, at the beginning and the end of the defragmentation, "defrag" with the "-v" option will give a report, much like the old Windows XP GUI defragmentation utility. Again, though, it will not report fragmented files with 64 MB fragments (or larger) as being fragmented.

Conclusion

With the command line version of the Windows Vista defragmentation utility, you have at least a modicum of control over the defragger, and some information about your hard disk file fragmentation. If you need any further details or fine control over the defragmentation of your hard disk, you may have to consider a third party defragmentation tool.

Copyright © 2006-2015 by Christopher Heng. All rights reserved. Get more "How To" guides and tutorials from https://www.howtohaven.com/.

This article can be found at https://www.howtohaven.com/system/vistadefragmentation.shtml

howtohaven™ Site News Feed

Do you find this article useful? You can learn of new articles and scripts that are published on howtohaven.com by subscribing to the RSS newsfeed. Simply point your newsfeed reader or a browser that supports RSS feeds at https://www.howtohaven.com/howtohaven.xml.


Please Do Not Reprint This Article

This article is copyrighted. Please do not reproduce this article in whole or part, in any form, without obtaining my written permission.

Related Pages

Newest Pages

How to Link to This Page

It will appear on your page as:

How to Perform a Full Manual Defragmentation of Your Hard Disk Under Windows Vista


thesitewizard.com: Free Webmaster Tutorials, Scripts and Articles

thefreecountry.com: Free Programmers' Resources, Free Webmasters' Resources, Free Security Resources, Free Software

HowToHaven.com: Free How-To Guides
If you find this site useful, please link to us.