Tech: How to Defrag in Windows Vista

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.

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


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.


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 😀 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


About itsfood

An IT Manager with an interest in tech (because he's a geek who enjoys his job too much) and food & wine (because he enjoys eating and drinking when not working).
This entry was posted in Tech, Wine and tagged , , , , . Bookmark the permalink.

61 Responses to Tech: How to Defrag in Windows Vista

  1. 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


      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

  2. itsfood says:

    Cheers, thanks a lot 🙂

  3. Kangaroo_Steak says:

    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.

  4. itsfood says:

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

  5. Matt says:

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

  6. Pingback: Firefox 3 released June 17th « ITs Food

  7. baffo says:

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

  8. John says:

    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.

  9. itsfood says:

    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.

  10. elleira says:

    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. 🙂

  11. TheTooleMan says:

    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?

  12. itsfood says:

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

  13. BryGUy says:

    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.

  14. matt says:

    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….

  15. Dean says:

    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?

  16. itsfood says:

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

  17. sam says:

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

  18. itsfood says:

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

  19. sam says:

    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.

  20. sam says:

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

  21. Allen says:

    Easy to use guide!

  22. Daniela says:

    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.

  23. Roxanne says:

    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!

  24. Adam says:

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

  25. Adam says:

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

  26. george says:

    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

  27. itsfood says:

    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.

  28. DAVE says:

    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

  29. itsfood says:

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

  30. Willie says:

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

  31. StreetFrog says:

    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.

  32. Mr Anti-Vista says:

    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:

    I hope that the next OS is a step up.

  33. Paul Sandford says:

    Before defraging using the Piriform degraggler, the fragmentation was 44%, after it was 40%. I removed old system restore points, which dropped it to 20%. I ran the Vista defragger from the command prompt with administrator privileges, but Vista reckoned there were no fragmented files, while Piriform found them scattered all over the hard drive.
    Bearing in mind that the engine for Windows 7 is based on Vista, should I go back to XP, for which defragging works?

  34. Tucker says:

    trying to defrag vista: under command prompt I see C:\Windows\system32> When I put in defrag c:-a or any other code, it tells me “This volume identifier is not valid. The volume identifier must be a valid local drive letter or mount point” Please tell me what i am doing wrong??!! Thanx Alot!

  35. itsfood says:

    You need to make sure there is a space between the “c:” and the “-a”.

  36. Pingback: Keep vista running smoothly | Manderso Consulting, LLC

  37. saurabh gupta says:

    hey, thanx for the info about defragging windows vista. can u tell me how much time does it take for defragmentation of a typical 160 GB hard drive (80% full).

  38. itsfood says:

    Depends on other hardware in your PC but allow a few hours I reckon!

  39. saurabh gupta says:

    tx for ur reply. can i get any info on how much defragging is complete or how is the progress . i have started fragmentation with the command “defrag c: -w -v”.

    another question i wnated to ask was “does defrag helps in managing ur space more effectively. my hard drive capacity is 140 GB. the total space occupied by all data is 80 GB , but it shows only 20 GB of free space instead of 60 GB. can u shed any light on this. tx.

    • REEKO says:

      The answer could simply be shadow volume files….. to remove excess volume shaddow files try this…….

      1. Click on the windows start button.. all programs.
      3. Select Accessories.
      4. Select System Tools.
      5. Select Disc Cleanup.

      On the Clean up tool select More Options Tab…From here you can remove software via control panel.. or remove any old restore point and shadow volume info. from your drive…This frees up many, many Gigs of space but leaves only the latest or last restore point…It WILL free up most if not all of your lost or unaccounted for drive space

  40. saurabh gupta says:

    another question i wanted to ask was how can i exit defragmentation once i have started. (i started defrag with following command in user prompt “defrag c: -w -v”. and if it causes any problem.

  41. itsfood says:

    Hi, try ctrl-d or ctrl-c to exit, can’t remember which it is off the top of my head. Also, for hard drive sizes remember that formatted size is never the same as the manufacturers stated size, there are lots of articles on this on the web (e.g. ). Although the amount you’re reporting is quite a lot different. I recommend you find a good techy forum and ask the question there.

  42. REEKO says:

    Reply to:
    another question i wnated to ask was “does defrag helps in managing ur space more effectively. my hard drive capacity is 140 GB. the total space occupied by all data is 80 GB , but it shows only 20 GB of free space instead of 60 GB. can u shed any light on this. tx.

    The answer could simply be shadow volume files….. to remove excess volume shaddow files try this…….

    1. Click on the windows start button.. all programs.
    3. Select Accessories.
    4. Select System Tools.
    5. Select Disc Cleanup.

    On the Clean up tool select More Options Tab…From here you can remove software via control panel.. or remove any old restore point and shadow volume info. from your drive…This frees up many, many Gigs of space but leaves only the latest or last restore point…It WILL free up most if not all of your lost or unaccounted for drive space……It’s a lil long winded but hope it helps 🙂

    Post your results when you have cleaned!!!

  43. Eric Bader says:

    Fan-tastic blog. Thank you.

  44. Eric Bader says:

    Fantastic blog. Very helpful! Thank you

    • REEKO says:

      Glad i could help, hope these ramblings may be of use to more people, all i ask is you post a comment, let me know if it works for you or maybee i can help with something else…

      You knowing how to do stuff is useless, unless it is shared! 🙂


  45. Pingback: Some changes are on their way… | ITs Food

  46. Patrick says:

    Thanks so much for the info regrading this, seems to work much better than scheduled Defrag, i do leave my system on 24/7, but i never knew if the Scheduled one was doing it’s job or not, and now with this command line option–i really know if it is or not.

    In fact i’m gonna run it again tonight–been a while since i ran it, been so busy lately. Gonna Defrag the XP Systems later on tonight as well

  47. Alex DeJesus says:

    Why did they do away with the XP style defragger? It was so easy to use and you could instantly see what was going on. Do they not want you to defrag in Vista?

    I tried the command prompt way, but it said my drive is 0% fragmented and does not need it.

    I installed a 3rd party “Defraggler” that’s pretty easy to use, but for some reason it does not defrag the drive all the way. As a matter of fact, I just performed a defrag that was 27% fragmented. By the way, it’s the same drive that Vista said was 0% fragmented. Afterwards, it was 31% fragmented!!! How can a defrag make my drive more fragmented?

    In the analysis in Defraggler, the list of files include some very large files I assume are shadow volumes. They get as large as 12 GB, fragmented, and cannot be defragged. Disk cleanup would not even see these files.

    • qno1 says:

      To Alex DeJesus (re comment post of 08-01’10): Wow. I’ve been surfin’ & jumpin’ all over the place tryin’ like hell to find some kinda answers to a couple of MAJOR issues I’ve had with my Vista system for like forever_since long before I got internet even_and while your comment didn’t really give answers, you’re the ONLY person/website I’ve come across thus far that realizes, relates to, and comes really, really close to my own dilemna(s)…so- Kudos!, and I think you may well relate to my problems as well. Two heads are better than one as they say, and maybe with both of our most-similar comments being read by -?-, we might just get a solution or two…cuz I for one am and have been at a complete dead end. I’m self-taught on ‘puters, and know a bit about ’em, but by no means a lot..I wish! But, I do totally relate to the XP (my crashed-n-down laptp_still dunno the cause) vs. Vista (my currently used desktop, which i HATE the vista part of) defrag issue…Vista SUCKS! Anyway, my main problem/gripe(s) are: 1) major disk space_GB’s worth_ getting gobbled up constantly/often exponentially by god knows what (or amt. of free space going up/down/up/down- never steady, no matter what you may or may not have been doing on it lately), and 2) the whole defrag thing in general_or rather, the lack of being able to effectively. I just got linked with this particular site today, through one of my countless Bing searches, and didn’t know before about the command prompt way of running the Vista defragger. It’s an idea, but at the same time, somethin’ I probably won’t even bother with because, quite simply, Vista has its own ideas and ways of doin’ things that never end up solving anything anyway, period…so why bother, ya know? I’ve actually just turned it off, and am using a third party defragger that’s workin’ pretty good so far. I’ve pieced together enough to know that certain individual factors are often combining to cause even larger headaches, but which I’m defeated by & haven’t the slightest of how to fix (sigh). For instance, my latest opponent in the system seems to be one of your own- the shadow volume copies of god kows what files_I just know that some of them, and others besides, are huge (GB’s, like you say), refuse to defrag, and by the time all is said and done, even more space gets lost somehow. The “others” I refer to are always for the largest part System Volume Information files. I dunno if shadows/duplicates are being made of these as well (probably), but in any case, you’re told that they’re “in use” files and can’t/won’t defrag, no matter what–ARGGHH!! (bet a stick o’ dynamite would do the trick…heh-heh) BUT, for example, day-before-yesterday, & thanks only to a third-party defragger, I found one file that was 16.11 GB big, with 873 fragments in it…ONE file! There are others as well, and they can’t even be defragged, much less gotten rid of. HOW CAN I GET RID OF THEM!?? They’re takin’ up untold amounts of space, and won’t even pay rent- jeez! (ha_a poor attempt at a joke in the face if dire circumstances) If you only knew how many cleaners/defraggers I’ve tried, for both disk and registry_and a coupla optimizers, which took 6 and 7 GB respectively afterthey ran. I’m pretty sure it’s cuz everything gets backed up first, with each tool..but where to, and how the hell do ya get rid of it all!? I even got an “Easy Duplicate Finder” to try and help. Well, it found thousands of duplicates alright, but the interface is of no help as far as telling which ones can be 86’d. Do I just keep all the newest copies, and ditch the rest, or what? Also, all these third party products are always so focused on improving performance and such– that part I have no problems with…nothing that just ‘nother gig of ram wouldn’t help with. And oh, btw, I’ve been seeing a bit about the whole page file thing also today_something I’ve thought ’bout tryin’ to do somethin’ with, but…-?- Would it help any of the whole defrag part if it was done in safe mode?_or would that even work? For the record, I’m running the Vista Home Premium w/SP2, 32-bit, 3.33 gHz Intel processor, 1 GB RAM (pathetic, I know, but can’t afford more), and the total cap. of the hard drive is 111 GB with 42 GB (but who knows, really) currently free. Of the total space, I can account for maybe 50-or-so GB of it (being generous). Besides 35 GB of music & a few other piddly things, I keep everything on other external drives_mainly cuz I never have a clue as to how much real space I’m gonna have on the main drive at any given hour almost. So…what’s with the almost 20 GB of unaccounted-for space- hmm?? And no, there are no viruses or anything similar going on– like I said, it’s always been this way…even months before I got internet. It’s Just Vista being its own f***ed up self. mmm… Well, I think ya get the idea what all I’m up against for the most part, so ANY help_that’s H-E-L-P_ I could get from anyone would be beyond appreciated.

  48. Pingback: How to keep Windows Vista running smoothly | Manderso Consulting's Blog

  49. vakantiehuis says:

    Leuke site!. Er zijn nog weinig goede sites over dit onderwerp te vinden.
    Ben blij met jullie post!
    Ik kan helaas geen bookmark aanmaken naar in Firefox. 😦 Weten jullie hoe dit komt?

    Groetjes Barbara

  50. Tabitha says:

    So how long does it take for the defrag process? Mine has been running for 4+ hours. Am not sure it even needed defragging as it only had 1% fragmentation.

  51. Bill R TechSpec says:

    Wow!! There’s a lot going on here!

    First, let me say this is an excellent article and the procedure to defrag via the command line is first-rate!

    As for the posted comments, many of the frustrations being voiced have to do with the limitations of the built-in defragger.

    Really, if you think about it, the built-in is meant for casual users, yet many of these posts are obviously from more advanced users (some arguably could even be considered “Power Users”).

    Think of the built-in the same way you would think of Word Pad or Paint – good utilities for casual use, but they could never replace a full featured word processor like Word or a professional graphics design program (nor are they meant to).

    It’s the same with the built-in Disk Defragmenter — it simply is not designed to defragment system files (and there are several types of system files). The built-in does take a long time as mentioned in the article and many of the posts and apparently unless you use the command level there is no progress indicator like there was in XP. Yet another draw-back is that you can’t really use the computer while the defragmenter is running as it uses a lot of the system’s resources.

    Basically, if you’re not just a casual user, you should not rely on a tool that is designed for casual users, especially when now there are excellent third party defrag programs most of which will address system files and some of them run automatically with little system drain.

    One in particular, Diskeeper will quickly defrag all your hard disks (including system files) without using your system’s resources (so you can use your PC while it is being continuously defragmented with no slow-down or performance loss). And the current version prevents most fragmentation before it happens so your files are not written or saved in pieces like they usually are. You can get more info at

    It’s a good solution for those of us who want to automate vital PC maintenance so we can just use our computers!

  52. Jennack says:

    Me gusta.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s