ITs Food

Tech: How to Defrag in Windows Vista

Wednesday, 30 January 2008 · 34 Comments

Hey, one of our very rare TECH articles. I think we post so little about tech because we deal with it all day so we tend to avoid blogging about it!

Last night I wanted to find out whether my gaming machine required defragging. Are you now wondering what “defragging” is? If you are the best way I can explain it is that over time your computer files get stored all over your hard drive, mostly in bits. The more bits, the more work the computer has to do when you want to use the file. Defragmenting (or defragging) your hard drive collects all (well most) of the bits and sticks them back together thus speeding up the time the computer takes to access them. It’s a good thing to run!

My desktop runs Windows Vista Ultimate so I was expecting a decent “pro” defragging tool. No chance! Just the bog standard Vista defrag utility. The easiest way to find it is bring up the Start menu and type “defrag”, the link to Disk Defragmenter will appear.

Defrag dialogue box for Windows Vista

Now, I don’t leave the machine on 24/7 so an early morning scheduled defrag was no good to me. I clicked the “Defragment now” button but nothing seemed to happen. What about my 3 drives? Where were my statistics??

It seems Microsoft in their “wisdom” has decided to dumb-down the defrag interface and remove some of the tools you may have been used to in Windows XP. Don’t worry though, the functionality is still there. The key is to run it from the command prompt.

How to defrag your drives in Windows Vista

  1. Open a Command Prompt as Administrator .
    Go to Start – All Programs – Accessories, right click on the Command Prompt and choose “Run as administrator”. Obviously you need admin privileges to do this.
  2. Type the following see how much your hard drive is fragmented (in this example, your C drive):
    defrag c: -a
  3. Vista will tell you a “Percent file fragmentation” and, at the bottom, if you need to defragment the drive or not.
  4. To fully defragment your C drive type the following:
    defrag c: -w
  5. Give it time to run (best to leave the computer alone) and then you’re done!

More Advanced Defrag Options

Obviously there are more command line parameters you can specify to output more info, defrag all drives, just defrag fragments smaller than 64Mb, etc. To get help just type:
defrag /?

To help you out here is the output:

Description: Locates and consolidates fragmented files on local volumes to improve system performance.

Syntax:
defrag <volume> -a [-v]
defrag <volume> [{-r | -w}] [-f] [-v]
defrag -c [{-r | -w}] [-f] [-v]

Parameters:

Value Description

<volume> Specifies the drive letter or mount point path of the volume to
be defragmented or analyzed.

-c Defragments all volumes on this computer.

-a Performs fragmentation analysis only.

-r Performs partial defragmentation (default). Attempts to
consolidate only fragments smaller than 64 megabytes (MB).

-w Performs full defragmentation. Attempts to consolidate all file
fragments, regardless of their size.

-f Forces defragmentation of the volume when free space is low.

-v Specifies verbose mode. The defragmentation and analysis output
is more detailed.

-? Displays this help information.

Examples:

defrag d:
defrag d:\vol\mountpoint -w -f
defrag d: -a -v
defrag -c -v

So last night I did the following.

  1. Checked the fragmentation of my three drives with extra detailed output:
    defrag c: -a -v
    defrag e: -a -v
    defrag f: -a -v
  2. As it turned out only drives E and F were fragmented so I fully defragged them and outputted the results to a text file:
    defrag e: -w -v > c:\temp\defrag_e_300108.txt
    defrag f: -w -v > c:\temp\defrag_f_300108.txt
  3. I therefore now have two text files with the output of my defrags so I can keep track of what I did when.

I hope this helps some of you out. I know I’ve skipped a bit of the detail but I think the basics are covered. Let me know what you think in the comments. Did this help you out? Do I need to change anything? If we helped you out and you want to say thanks :D you can always buy something at Amazon UK through our Shop link at the top of this page or you can always bung us a few £ or $ or € via paypal to our email address:

ITs Food Email Address

Categories: Tech · Wine
Tagged: , , , ,

34 responses so far ↓

  • Data Recovery Blog // Thursday, 31 January 2008 at 11:50 am | Reply

    Even though Vista is an advanced operating system, there hasn’t been much update on the file system either in FAT or NTFS.

    There is still the problem of files being stored in fragmented fashion, increasing the seek time.

    I would always recommend Native Windows Defrag tool compared to third party tools.

    Nice peice of information, Kudos to the writer

    • MANNY GUTIERREZ // Friday, 15 May 2009 at 2:20 am | Reply

      I never got a status on my “c” drive how fragmented it is at any particular time during the defrag and how much longer it will be. Thanx

  • itsfood // Thursday, 31 January 2008 at 2:41 pm | Reply

    Cheers, thanks a lot :)

  • Kangaroo_Steak // Thursday, 31 January 2008 at 4:16 pm | Reply

    I simply installed Diskeeper Pro 2k8 on the Vista PC after a week. It’s far better than Vista’s defragger in terms of speed, performance and eas of use. Highly recommended! I like to control what defrag mode to use on what drive (I have 3) and Vista’s defragger did not really win me over.

  • itsfood // Friday, 1 February 2008 at 9:41 am | Reply

    Yes, it’s an option for the PRO user but if you don’t want to spend any money, stick with Vista Defrag.

  • Matt // Monday, 19 May 2008 at 3:17 pm | Reply

    cool thanks for this. I was just trying to figure this out. someone else had said use -b to defrag prefetch folders as well.

  • Firefox 3 released June 17th « ITs Food // Friday, 13 June 2008 at 9:43 am | Reply

    [...] 13 June 2008 · No Comments As our most popular post currently is “How to defrag in Windows Vista” I thought I’d post this for our tech happy [...]

  • baffo // Thursday, 4 September 2008 at 5:40 pm | Reply

    If windows defrag does not give you the power you want and your budget is tight, a free open source windows defragger is jkdefrag, http://www.kessels.com/Jkdefrag/ . Can consolidate files to fastest portions of the drive, consolidate free space, sort files by access, run as a screen saver, etc.

  • John // Tuesday, 23 September 2008 at 6:22 am | Reply

    I have a laptop with windows vista that only came with 1Gig of ram. I notice that a lot new pc’s are coming with 2gig. I was thinking of buying a 2gig upgrade. Good idea yes or no? I also have System Mechanic on board defrager say 30% files fragmented but vista in comand prompt -a say 0%. which one is telling the truth.

  • itsfood // Tuesday, 23 September 2008 at 7:28 am | Reply

    John, thanks for the comment. Yes I’d say Vista requires a minimum of 2Gb to run sweetly. If you install Vista Service Pack 1 it will recognise up to 4Gb.
    As for the fragmentation, 30% to 0% is a big difference! I’d suggest the freeware Jkdefrag mentioned above your comment and see what that says, post a comment and let us know.

  • elleira // Tuesday, 23 September 2008 at 9:00 pm | Reply

    John, I also ran the analysis through command prompt, and it told me that both of my drives were at 0%. However, I noticed that it said if your drives are formatted as NTFS, it will not include file fragments larger than 64mb in the analysis. I have a lot of large files, so I’m going to try out jkdefrag to see what it says. Just thought I’d pass on the information. :)

  • TheTooleMan // Friday, 26 September 2008 at 4:08 pm | Reply

    The command line defrag looks interesting and worth a try. But since the Windows interface doesn’t have any parameters, what does it actually do? You say, “-r Performs partial defragmentation (default). Attempts to consolidate only fragments smaller than 64 megabytes (MB).” Is that what we get through the Windows interface?

  • itsfood // Friday, 26 September 2008 at 4:59 pm | Reply

    I agree, it’s confusing but looking around I think you’re right, the -r action is the default option.

  • BryGUy // Saturday, 29 November 2008 at 5:36 am | Reply

    I was baffled when I originally tried to use the Vista Defragger. I wasn’t sure if it needed defragging and when I ran it I wasn’t even sure if it did anything or was even successful.

    For all I knew my screen saver interrupted the process and nothing was done at all.

    Thanks for the article. I never even thought of using Command Prompt.

  • matt // Tuesday, 30 December 2008 at 8:22 pm | Reply

    why in all the computer manufacturers infinite *joke* wisdom did they ship hundreds of thousands of pcs and laptops with only 512mb ram. this means that with vista running more and more background processes ie. the genuine advantage tool, windows defender, etc on top of laptop processes like touchpad, display smoothing, drive acoustic silencers, etc it all makes for a very slow and jerky vista experience, i for one am going back to xp. it would be linux if i didnt like gaming so much….

  • Dean // Friday, 9 January 2009 at 2:20 am | Reply

    John, I tried to defrag my vista laptop from the command promt but keeps telling me that i need an administrator’s permission and I am the Administrator, what’s wrong with this?

  • itsfood // Friday, 9 January 2009 at 10:05 am | Reply

    You need to right click on the shortcut for Command Prompt and choose “Run as administrator”.

  • sam // Thursday, 15 January 2009 at 11:05 pm | Reply

    When I try to put in defrag c: -a and press enter, It just says some copyright information.. how do I do this?

  • itsfood // Friday, 16 January 2009 at 9:37 am | Reply

    Sam, it’s working but takes some time to run, be patient!

  • sam // Friday, 16 January 2009 at 4:50 pm | Reply

    i thought that was an analysis.. not an entire scan..
    when I defragged using the normal one it tok at least 7 hours and I really don’t see a difference in my computer’s performance.

  • sam // Friday, 16 January 2009 at 5:20 pm | Reply

    oh, nevermind, I got it to work. I’m at 2% now

  • Allen // Wednesday, 25 February 2009 at 6:11 am | Reply

    Easy to use guide!

  • Daniela // Sunday, 1 March 2009 at 7:47 pm | Reply

    Hello John, thanks for your article.
    I still have a question though: I just defragged my laptop and when I opened C, it kept telling me I had only 9.25 gigas left, but I had 15.5 gigas BEFORE defragging, what on earth just happened here??
    I’ll be terribly thankful if you can shed some light on this problem of mine.

  • Roxanne // Wednesday, 4 March 2009 at 5:39 am | Reply

    Thank you thank you thank you! I spent much of my day trying to defrag not knowing if it was doing anything at all. I started searching for other ways to defrag and found this post! Awesome! This worked great!

  • Adam // Thursday, 16 April 2009 at 2:41 pm | Reply

    Hey, could you send to this e-mail some stuff for cmd prompt regarding defragging? Thanks a bunch.

  • Adam // Thursday, 16 April 2009 at 2:50 pm | Reply

    Scratch that e-mail… try this one. I put it in the “Mail” box on the “Leave a Comment” thing. Thanks again.

  • george // Thursday, 7 May 2009 at 2:16 pm | Reply

    Im trying to defrag my vista laptop but it keeps coming up with “he volume is marked as dirty, you must run chkdsk on the volume to correct any problems before you attempt to defragment it again” can someone please tell me wat in the hell it means
    Thanks

  • itsfood // Thursday, 7 May 2009 at 2:54 pm | Reply

    Go to Windows Explorer, right click in the “dirty” drive, choose Properties, Choose the Tools tab, then pick “Check Now” under Error-checking, start this checking and it will tell you this needs to be scheduled for the next reboot. Reboot the PC and it will run CHKDSK for you.

  • DAVE // Sunday, 7 June 2009 at 4:37 pm | Reply

    hello there i`m still having problems when i try anything all i ever get is this error even in the cmd prompt and it says the following
    the volume is marked as dirty you must run chksdk on the volume to correct any problems before you attempt to defrag this is all i ever get and my disk defrag in vista bacic will not work and talk about a dial up slow computer when i have high speed
    thanks please reply to my address if you`d like thanks very much dave in halifax canada

  • itsfood // Monday, 8 June 2009 at 8:47 am | Reply

    Dave, have you followed the instructions in the comment above yours?

  • Willie // Friday, 24 July 2009 at 8:43 pm | Reply

    Your example for deragment my Windows Vistahard drive, does not work for me

  • Philip // Wednesday, 29 July 2009 at 6:59 pm | Reply

    nice guide

  • StreetFrog // Thursday, 13 August 2009 at 10:28 pm | Reply

    Thanks. I was really disappointed with defraging in vista.

    For ease of use and so I don’t have to remember command lines, I put the analysis lines for my two drives into notepad then saved it as a batch file (.bat) on my desktop. Just make sure to run as admin or it won’t work.

  • Mr Anti-Vista // Sunday, 20 September 2009 at 11:43 pm | Reply

    A nice article and work around for defragging in Vista, I also wrote an article about some of the other nagging problems in Vista, you can find it here: http://southernzombie.com/why_windows_vista_sucks.html

    I hope that the next OS is a step up.

Leave a Comment