Scott Hanselman

Guide to Freeing up Disk Space under Windows Vista

October 20, 2008 Comment on this post [55] Posted in Tools
Sponsored By

I've got a smallish C: drive, about 140G, but noticed that in the last week or so I'd had only 200megs free. Not cool. A few hours later, I have 84.4G free. Here's now:

  • vsp1cln.exe - After you install Vista SP1, it leaves around the original files so you can uninstall the Service Pack if you want. After a few months with the Service Pack, I've decided for myself that it's a good thing and decided I don't need the option.
    Open up an administrative command prompt. That means, click the Start Menu, type cmd.exe, then right-click on it and click "Run as Administrator." Alternatively, you can press Ctrl-Shift-Enter to run something as Administrator.
    Next, type "vsp1cln" at the command prompt. If you select yes, you'll get back around 2 to 3 gigs. The only thing, again is that you can't uninstall SP1.

    VSP1CLN
  • Disk Cleanup - It's amazing to me the number of people who DON'T run Disk Cleanup. It's even better in Vista. Just run it. Often.
  • Disable Hibernate - I have a desktop, and I prefer just three power states, sleeping, on or off. I don't use Hibernate. Plus, I have 8 gigs of RAM, and hibernation uses as much disk space as you have RAM. From an administrative command prompt, type "powercfg -h off" to get that space back. Got me back 8gigs.
  • %TEMP% Files - Even though Disk Cleanup is great, sometimes for whatever reason it doesn't get stuff out of the TEMP folder. I recommend you try to delete the TEMP folder. I do this from the command line. Open up an administrative console, type "cd /d %TEMP%" (without the quotes, of course). Then, go up one folder with "cd .." and type "rd /s temp"
    Do be warned, this command says to TRY to delete the whole folder and everything underneath it. It's very unambiguous. If you don't feel comfortable, don't do it. If you feel in over your head, don't do it. If it screws up your computer, don't email me. Next, I do a "dir temp" to see if the folder really got deleted. It usually doesn't because almost always some other program has a temp file open and the command can't get remove everything. If it DOES remove the folder, just "md temp" to get it back fresh and empty. This got me back 2.5 gigs. I'm sure you'll be surprised and get lots back.
  • System PropertiesClean up System Restore - Vista keeps backups of lots of system files every time something major (driver installation, some software installations, etc) happens, and after a while this can take up lots of space. It uses a service/subsystem called ShadowCopies and can be administered with a tool called vssadmin.
    Now, the EASIEST way to handle this is just to run Disk Cleanup, then click More Options and "Clean up…" which will delete all but the most recent System Restore data. That's what I did. That got me back lots of space back on my C: drive.
    Alternatively, you can use the vssadmin tool from an admin command prompt to to do important things. One, you can set a max size for the System Restore to get. Two, you can set an alternative drive. For example, you could have the D: drive be responsible for System Restore for the C: drive.
    You can use the commands like this. Note that you can put whatever drive letters you have in there. I ran it for each of my three drives. Note that this isn't just used for System Restore, it's also used for the "Previous Versions" feature of Vista that keeps some number of Shadow Backups in case you delete something and didn't mean it. Kind of a mini, local time machine. Point is, this isn't a feature you probably want off, just one you want kept to a max.
    vssadmin Resize ShadowStorage /On=C: /For=C: /MaxSize=15GB
  • Check Folder Sizes with WinDirStat - I've used a large number of Windows Folder Size checkers, and the one I keep coming back to is WinDirStat. It used to be OverDisk, but OverDisk isn't smart about NTFS Junction Points and tends to get confused in Vista generally. Plus, it's been on version 0.11 for something like 4 years. WinDirStat is actively developed, it's Open Source, and it works great in Vista. It's wonderfully multi-threaded and is generally fabulous. It'll help you find those crazy large log files you've forgotten about deep in %APPDATA%. It saved me 5gigs of random goo.
  • CVSRepo Properties NTFS Compression - That's right, baby, Stacker (kidding). This is a great feature of NTFS that more people should use. If you've got a bunch of folders with old crap in them, but you don't want to delete them, compress. If you've got a folder that fills up with text files or other easily compressed and frequently access stuff, compress 'em. I typically compress any and all folders that are infrequently accessed, but I'm not ready to toss. That is about 30-40% of my hard drive. Why bother to compress when Disk Space is so cheap? Well, C: drive space usually isn't. I've got a 10,000 RPM drive, and it's small. I'd like to get as much out of it as I can without the hassle of moving my Program Files to D:. More importantly, Why the heck not? Why shouldn't I compress? It's utterly painless. Just right click a folder, hit Properties, then Advanced, then Compress. Then forget about it. As long as you're not compressing a bunch of ZIP files (won't do much) then you're all set. You might consider defragging when you're done, just to tidy up.
  • Remove Old Stuff - Just go into Add/Remove Programs or Programs and Features and tidy up. There's likely a pile of old crap in there that's taking up space. I removed some Games and Game Demos and got back 5 gigs.
  • Wasteful TempFiles/ScratchFiles Settings in Popular Programs - Most programs that need scratch space have a way to set a ceiling on that Max Space. Go into Internet Explorer or Firefox, into the options and delete the Temporary Internet Files. Set a reasonable size like 250 megs or 500 megs. I've seen those cache sizes set to gigs. If you've got a speedy connection to the internet, that's just overkill.
  • Find Fat Temp File Apps and squash them - Google Earth and Microsoft Virtual Earth 3D are really fast and loose with the disk space. You can poke around for a while and next thing you know you're down 2 gigs or more. If you don't use the app a lot, delete the caches when you exit, or better yet, make the cache size for each app small.
  • works-on-my-machine-starburst ADVANCED: Use Junction Points/Hard Links/Reparse Points to move temp file folders - This is an advanced technique. If this technique kills your beloved pet cat, don't email me. You have been warning. Also, note that I'm only saying it works for me.
    I use my Zune all the time, and like many portable media players, it transcodes (squishes) video that it downloads from the web to its preferred size and codec. For example, if I download an ABCNews Podcast, it might be 600 megs, but then Zune automatically squishes it to say, 300 megs. It puts that in %AppData%\Local\Microsoft\Zune\Transcoded Files Cache. I'm not sure how to move that folder, and I've looked all over the Zune app. I know I can set the Max Size, but I want it off my drive. So, I make a SymLink. This is a way to fake out apps (Unix people know this) by making a folder POINT to another place.
    From an admin command prompt, I went into the Zune temp folder and deleted that Transoded Files Cache directory. Then I typed:
    mklink /d "Transcoded Files Cache" "d:\Zune Transcoded Files Cache"
    So that directory really points to one on my D: drive. I can confirm it with dir:
  • Directory of C:\Users\Scott\AppData\Local\Microsoft\Zune

    10/19/2008  02:24 PM    <DIR>          .
    10/19/2008  02:24 PM    <DIR>          ..
    10/19/2008  02:25 PM    <DIR>          Art Cache
    07/15/2008  08:56 AM    <DIR>          DeviceInbox
    10/19/2008  02:24 PM    <SYMLINKD>     Transcoded Files Cache [d:\Zune Transcoded Files Cache]


    Again, this is really dangerous, especially if you forget you did it. Also, not every application understands these and older disk management or directory management apps can get confused. You have been warned. I like it for me. This got me back 8 gigs of space.

What did I miss, Dear Reader? I'm sure I missed something.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
October 20, 2008 9:08
Thanks for these tips! Very helpful in recovering a few 10s of GBs for me :)
October 20, 2008 9:23
The only thing I'd add would be to empty your recycle bin. I often find that I'll "delete" something just to find it and another 10Gb of stuff still hanging around in my recycle bin a few months later.
You can also set the recycle bin to automatically delete forever... but that also has it's drawbacks.
October 20, 2008 9:42
+1 for disk cleanup in vista. I tweak my hardware quite often, so I get lots of crashes...vista disk cleanup deletes all the debug dumps, which can get into the 10's of gigs in size.
October 20, 2008 9:42
@Darryl:
IIRC that's one of the things disk cleanup does :)
October 20, 2008 9:49
Thanks Scott, I was just doing some cleaning up of my vista machine when I saw your post. Very handy tips. Its easy to run out of space when your not watching everything all the time :)
October 20, 2008 10:17
OMG! I used some of your tips and I freed up about 20 GB. Thank you Scott!
October 20, 2008 10:39
Hi Scott,

I used to do all of what you suggested...and then I found CCleaner. Works great on Vista x64
October 20, 2008 11:44
Excellent post!

I would just like to add "Delete the thousands and thousand of old emails" to the list.

I used to just let emails stick around, but having a better achiving strategy saves alot of space.

Thanks..!
October 20, 2008 11:45
Hi,
About WinDirStat, you say that it's "beautifully multi-threaded". Maybe I'm missing something, or I'm using an old version (1.1.2.80 on Windows XP), but for me it is "uglily single-threaded". Don't get me wrong, it is a great free application, but I wouldn't call it multi-threaded.
It does, actually, have multi-threaded parts, like the drive selection dialog. But the most important part, drive scanning, is single-threaded (seen with Process Explorer). Just start a scan and click on a menu. The animations stop and so does the scanning process. So it is not so beautifully multi-threaded.
Anyway, great article.
October 20, 2008 11:57
Very cool article, thanks :)

Random idea: a public wiki that any Microsoft employee can edit, with useful stuff like this.
October 20, 2008 13:55
I recovered about 6gb the other day. Well it actually happened about 3 months ago but I only realised last week. I deleted my pictures folder after thinking I had moved it to my new media drive. 8 years of photos gone. I really dislike recovering files only to be told they're corrupted!

Sorry, off topic. When I used to game, my screen shots and demos folder would fill up extremely quickly.. make sure to get all those.
October 20, 2008 14:06
if you are doing asp.net development

than C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

it can grow quite a lot if you are working on multiple projects and trying out different samples.

thanks for the tip on removing SP1, great work

Cheers !!!

Deepesh
October 20, 2008 14:14
If you care enough about this stuff, you can get a cleaner seperation of your data from your applications by doing an install with the user profile directory sitting on your data drives (I'm anal enough that I reinstalled simply to get this structure going, but on the plus side, I know all my data is automatically on the data drive, and my C: drive disk usage remains fairly constant).

Install Vista/Server 2008 using unattend.xml, configuring the Users directory and ProgramData to be on one of the data drives. Start out from http://support.microsoft.com/kb/949977

There are some gotchas:

* You probably still want to create junctions for ProgramData and Users pointing from C: to the new locations on D:, for badly behaved programs that may hardcode these paths.
* Your first Windows Update run after a fresh install may have some "issues", at the time I did this Windows Update couldn't handle the location of ProgramData for some updates, but that may since have been fixed. The KB article above refers to a servicing stack update which may or may not address this.
* Doing this will also block upgrades using the Windows installer. This is not a problem for me since I always install a new OS release from scratch, but it may be for you.

October 20, 2008 14:21
Update: Here's a post on how to worked around the Windows Update issue when moving Users/ProgramData to a different drive. May be irrelevant now but if not may be useful to get all your updates applied and system into a "green" state:

http://www.tech-archive.net/Archive/Windows/microsoft.public.windowsupdate/2007-09/msg01074.html
October 20, 2008 14:22
Question: Does the 'vsp1cln.exe' trick work with slipstreamed Vista SP1 installs?

Thanks for the tips, Scott :o)
October 20, 2008 14:29
Before
Space free: 17GB

After
Space free: 35.9GB

Very cool Scott, I very like this blog.
October 20, 2008 14:43
dwn.exe (Desktop Window Manager) and sidebar.exe

It's very very used memory, you have the same problem ? and i want to resolve this problem :(

Please help me, I can't wait vista SP2, 3, 4 or 5 :)
October 20, 2008 14:45
I love WinDirStat.
Saved me 60 Gb as few months ago ( no idea what the 60gigs of crap actually were, but windows exploer couldn't see them). Details here: http://rbonini.wordpress.com/2008/08/29/hard-drive-troubles/

WinDirStat FTW!!!!
October 20, 2008 15:03
I like the prompt you get after typing vsp1cln

This operation will make Windows Vista Service Pack 1 permanent on this computer.
Upon completion you will not be able to remove Windows Vista Service Pack 1 from this system.

It sounds more user friendly.

As opposed to something like "You are about to delete original installation files for SP1".

October 20, 2008 15:29
Brilliant, Scott. Thanks.
October 20, 2008 17:38
I second CCleaner. It's an awesome tool that's dead simple to use. Once you've got things setup, you just right-click on your recycle bin and tell it to run!

One of the many great things about it is that you can tell it which cookies you do not want to delete. Once you've got your whitelist setup, it's just that much more beneficial!
October 20, 2008 17:43
Thanks for the tips Scott, really useful. If you're on a desktop and you remove the hibernate file, does this mean you won't be able to use hybrid sleep?
October 20, 2008 18:24
Cool,

Scott... now you just need to write a powershell script that does all this for you/us and put it up on your blog.

BOb
October 20, 2008 18:26
October 20, 2008 18:50
I would recommend to defragment Your disk after every cleanup, in order to use the claimed space so move your fragmented files to a clean space and to set them to continuous secotrs: thi will lead to more performance in subsequent use of the system.
October 20, 2008 19:23
I'm still trying to wrap my head around the idea of 140 GB as being 'smallish' :-)
October 20, 2008 19:26
You forgot to mention going into IE and setting the default amount of space down from 10% of your drive to a reasonable number (like 1%). I think they reduced it on Vista, but on XP you definitely want to do that.
October 20, 2008 19:41
There is one little problem with NTFS compression; if you do it on a directory where you are accessing files often, and they change often then NTFS ends up marking them in such a way that defragmentation of those files is a real problem.

There's also a shed load of log files in c:\windows\logs

Now if only we could clean down WinSXS safely.
October 20, 2008 19:43
Great post - I have a MacBook Air and dual boot Vista on it, this gives me a Vista partition of 30Gb and with Vista installed, not a lot of spare space, but a little more after reading this.
October 20, 2008 21:35
Hey Scott,
Thanks for that. Will remember that in future.

Roberto.

PS I really dig the openID. Makes life a lot easier.
October 20, 2008 22:31
Thanks Scott. I managed to remove 43Gb's from my HDD.
October 20, 2008 22:41
Another thing to look for is iTunes, especially when using it for podcasts. Have you ever gotten that little bang '!' symbol next to a podcast? When this happens there is a disconnect between iTunes library and the files that it is *supposed* to manage. I did a WinDirStat session and recovered about 18 gigs of space from orphaned podcast downloads. This was over the span of about a year and half of podcast listening via iTunes so I keep a closer eye on it now...
October 21, 2008 9:03
great article............ thanx
October 21, 2008 9:40
Wow Scott - unbelievable. I have a 140GB 10,000 RPM drive as well that I've been suffering with having <1 GB. Nearly was about to start paving my machine this weekend. These tips just got me back 70 GB. Absolutely crazy - Thanks!
October 21, 2008 11:35
Yeps, got back around 17GB! Who would have imagine thanks pal..be sticking around on your blog for a while Scott. Lots to learn from you here. Take care
October 21, 2008 14:13
Thanks a lot Scott! Yeah abjbaht, CCleaner works great too.
October 21, 2008 14:30
My pet peeve : C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

non movable (except with joins), full of copies (and JIT) of every ASP.Net file you ever launched on your computer in up to 4 versions.

A major pain for developpers, and maybe a big pain for ASP.Net servers with many web sites on it.

Anyone knows HOW to move this to another partition ?
October 21, 2008 16:41
Great article - saved me som gig's too.

Maybe you know about this problem then, because I haven't had any luck googling it or asking about in MS's newsgroups:

Due to company policy, my "Documents" folder gets relocated to a folder on
our SBS server. As far as I can tell, my only option if want to include
these files in my Vista search index is to make these files offline
accessible.

When I do this, Vista makes a local copy of the files somewhere under
c:\users\myusername\AppData.

My problem is, that my main drive is a fairly small 70Gig 10.000rpm WD
drive, and it is filling up with the local copies of the contents of my
Documents folder.

I can relocate almost all other folders in c:\users\myusername, or use
junction points, to point folders to other drives, but i can't find any way
to do this with the AppData folder. (BTW junction points isn't that great
when you're using Photoshop CS - it's file dialogs doesn't understand them)

Is it possible to relocate the AppData folder, or even better c:\users -
on a running Vista install or is it necessary to make a clean install and
relocate c:\users as Leon explains it above?

Regards
Jesper Hauge
October 21, 2008 23:45
Oddly enough, my disk space usage went up after the Disk Cleanup phase (by .1 GB). But the 82 GB I got from the rest more than made up for it.
October 22, 2008 6:39
Use ccleaner...best way to clean up all that crap.....
October 22, 2008 22:14
Man, FolderSizes (a commercial app) blows WinDirStat out of the water. Has multiple graph views (including a tree map), generates all kinds of interesting reports (largest, oldest, temp, and duplicate files just to start). It has an integrated task scheduler, built in search tool, command line interface, scan filtering, and can export reports in XML, HTML, CSV, etc.

WinDirStat is free, and free is always nice. But when you need a professional tool for the job, I think FolderSizes (http://www.foldersizes.com) is the way to go.
JB
October 22, 2008 23:01
My ultimate tool for cleaning up my hds is sequoiaview. It creates a visual representation of all files on your harddisc. It makes it super easy to trace large files.

http://w3.win.tue.nl/nl/onderzoek/onderzoek_informatica/visualization/sequoiaview/

El
October 23, 2008 0:52
I prefer just three power states: sleeping, on or hibernate. Why would you ever use off?
October 23, 2008 21:16
folbec
You can move the temporary aspnet files by modifying the compilation section of your machine config file

%WinDir%\Microsoft.NET\Framework\v2.0.50727\Config\Machine.config

In the <system.web> section find the compilation node and add the tempDirectory attribute


<system.web>
<compilation tempDirectory="E:\temp\Temporary ASP.NET Files\2.0" >
.....
.....
....
</compilation>
......
.......
.....
</system.web>

------------------------------------------------------------------
My pet peeve : C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

non movable (except with joins), full of copies (and JIT) of every ASP.Net file you ever launched on your computer in up to 4 versions.

A major pain for developpers, and maybe a big pain for ASP.Net servers with many web sites on it.

Anyone knows HOW to move this to another partition ?
folbec
October 24, 2008 0:31
Turning off Hibernate on desktop machines is a great option.

However - note to the Windows team - we can do without the "Hibernate is disabled on this machine" alert bubble on every boot. We like Hibernate off - I know it's your pet feature but it really doesn't matter to us as much as it does to you - stop pestering us about it !

October 24, 2008 18:31
If you want really remove programs, don't use the default Vista's "add/remove programs". Try the freeware Revo Uninstaller. That little jewel really cleans the disk and registry when removing programs.
October 24, 2008 19:13
Don't forget all of the Prefetch files in C:\Windows\Prefetch
October 26, 2008 11:24
you don't need to open an administrative prompt, because sp1cln.exe will automatically request the UAC elevation
suc
October 26, 2008 11:25
you don't need to open an administrative prompt, because vsp1cln.exe will automatically request the UAC elevation
suc
October 28, 2008 0:39
Because of it's virtualization features, you don't need any special tricks or tools to relocate most of your user data to a separate drive. Simply drag and drop your Contacts/Desktop/Documents/Downloads/Music/Pictures/Videos/etc folder(s) from their default location at
C:\Users\<username>\
to a new location, for instance:
D:\UserData\<username>\


Vista will automatically virtualize those paths so that any attempts to access files/folders in the original locations will be redirected to the new locations. You can move them pretty much anywhere you want, as often as you want.

There are quite a few how-to's online covering this topic. Here's one: http://blogs.zdnet.com/Bott/?p=215. There are also third-party tools that enable you to accomplish a similar feat under XP.

However, there is no built-in support for virtualizing the AppData folder, so using Junction Points is likely the simplest technique for that.
October 28, 2008 1:04
October 29, 2008 10:13
Thanks for the great articles, and in particular this one, Scott.
November 01, 2008 15:15
Nice .. what is the button before your minize/close button in your window?
November 02, 2008 22:50
Scott begins "I've got a smallish ...". Most males would not begin as sentence with "I've got a smallish ..." unless they were going to say something like "I've got a smallish C: drive, about 140G".

Whenever I start a sentence with something like "I've got a smallish C: drive, about ___" or "I've only got ___ RAM" or "my screen resolution is only ____ x ____", I feel a bit ungrateful. That's because my first IBM XT clone from Zenith had a 10MB (sic) hard drive, 256KB (sic) RAM, and a 16-colour (sic) 320 x 200 (sic) display and cost consumers way back then CDN $8400. Recently, I bought my wife a Compaq laptop (some people call them notebooks) at Future Shop for CDN$500. It's got 2GB RAM, 160GB hard drive, wide monitor, et cetera. Weight: about 2.7Kg (c. 6#) ~~ approximately 60% of the weight of the hard drive alone of my first XT clone.
November 30, 2008 4:14
you've got to be kidding me! i was looking for a way to free up some space... i just couldn't see where it was all going to... and found this blog. did everything that was suggested and somehow was able to free up 130 gb! crazy! thx for the info!

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.