181

A Vista virtual machine I use only has a 10 GB virtual hard disk -- and I'm worried about it running out of space over time.

I used TreeSize to check for the culprits..

enter image description here

And the primary culprit is that /winsxs or "Windows Side-By-Side" folder.

enter image description here

What is the Windows Side By Side folder? Well, that's explained pretty well here.

All of the components in the operating system are found in the WinSxS folder – in fact we call this location the component store. Each component has a unique name that includes the version, language, and processor architecture that it was built for. The WinSxS folder is the only location that the component is found on the system, all other instances of the files that you see on the system are “projected” by hard linking from the component store. Let me repeat that last point – there is only one instance (or full data copy) of each version of each file in the OS, and that instance is located in the WinSxS folder. So looked at from that perspective, the WinSxS folder is really the entirety of the whole OS, referred to as a "flat" in down-level operating systems. This also accounts for why you will no longer be prompted for media when running operations such as System File Checker (SFC), or when installing additional features and roles.

That explains why the folder starts off big, but not why it gets larger over time – the answer to that question is servicing. In previous versions of Windows the atomic unit of servicing was the file, in Windows Vista it’s the component. When we update a particular binary we release a new version of the whole component, and that new version is stored alongside the original one in the component store. The higher version of the component is projected onto the system, but the older version in the store isn’t touched. The reason for that is the third part of why the component store gets so large.

Lots of other people complaining about the size of the /winsxs folder, too:

A coworker recently received his every two year work laptop refresh and was in the middle of loading his new laptop with Vista. For some reason, his hard drive C: was partitioned to only 25GB and the rest of the space reserved for a much larger drive D:.

Anyway, after loading many Windows Updates, he was left with hardly any drive space left on C:, and for some reason, the WinSxS directory had ballooned to over 8GB.

While I knew what the WinSxS (Windows Side-by-Side) directory was for, I wasn't quite sure why that directory would explode in size so fast with normal operating system updates.

I don't really care about having all these duplicate files for safety, but I do care about the VM exploding due to an out of disk space error. So.. can /winsxs be safely pared down in any way? It doesn't seem that it can be..

Administrators should not, for any reason, take it upon themselves to clean out the /winsxs directory - doing so may prevent Windows Update and MSI from functioning properly afterwards. Preventing accidental deletion from the directory is accomplished by putting a strong security descriptor on the directory that inherits to its children.

If this /winsxs folder gets any larger, I'm going to have to re-image this virtual machine.. which I really don't want to do!

11
  • 26
    TreeSize Free... I use windirstat.info for this purpose ;-) Jul 15, 2009 at 7:45
  • 6
    Can't you grow the VM and extend the main partition? Jul 15, 2009 at 8:52
  • 1
    You could use this: windowsfixup.com/2009/05/… personally I would stay away from it unless I could find the source code Jul 27, 2009 at 8:03
  • 12
    There are a lot of hard links in winsxs, so the size is also frequently over-reported.
    – Greg D
    Jul 31, 2009 at 13:58
  • 7
    First Question on SuperUser
    – puretppc
    Jan 31, 2014 at 16:52

12 Answers 12

106

There is a nice command that cleans up after a Windows 7 SP1 installation (it saved me around 3 GB):

DISM /online /cleanup-Image /spsuperseded

Must be executed from an elevated command prompt

15
  • 2
    excellent, I was just thinking of cleaning up Windows 7 SP1 Mar 9, 2011 at 22:21
  • 6
    are there other commands for Windows 7 that can also remove non-SP update backups? Apr 24, 2011 at 3:42
  • 8
    Alternatively you can use the "Cleanup system files" option in the Disk Cleanup tool and delete the Service Pack backup files.
    – Michał T
    Mar 30, 2012 at 14:16
  • 5
    @Pies, I ran Disk Cleanup first and DSIM still got rid of an extra ~3GB (measuring %free disk space, not folder size). So it's worth doing both. Nov 2, 2012 at 21:00
  • 3
    @UpTheCreek, you sure? After doing Disk Cleanup, Clean up system files, i get C:\Windows\system32>DISM /online /cleanup-Image /spsuperseded Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Service Pack Cleanup can't proceed: No service pack backup files were found. The operation completed successfully. Jun 5, 2013 at 14:59
50

TL;DR

winsxs actually contains hard links. It does not take up as much additional data as you think.

A hard link is like a 'shortcut' or 'pointer' to an actual file located somewhere on your disk. A hard link does not take up any hard drive space by itself: it merely serves as a redirect.

Because winsxs consists of hard links, deleting these links will not free any space. The actual files will continue to remain in various locations on your disk.


winsxs is not a problem

...it's a solution! (Well, mostly.)

A summary, "Marked As Answer by Ronnie Vernon, MVP, Moderator", says here:

Wow, long discussion about hardlinks and winsxs. Anyway here are some summarized points of what I understood about how all of it works.

To start by answering the OP's question with the perfect answer posted above by Andre.Ziegler, you don't touch winsxs. Maybe some of the files can be trimmed like the mp3's, avi's, etc but the rest of the system files should be left alone. I too am using Link Shell Extension as posted above by Ronnie Vernon, easy way to see which are hard linked (red arrow) and which are simple files.

Before getting here I saw in a lot of places people asking for the cleanup tool after installing SP1 for Windows 7 like vsp1cln. There is no dedicated tool, it all got integrated into the Disk Cleanup service. One note that I would make here is that even if the option says it will remove a few hundreds of MB after I cleaned up my drive the service removed around 3GB of excess files, so it varies from system to system. Funny, now I have even more space than I had before installing SP1. Nice one, MS.

Regarding the hard links, I got amused by the confusion created around them. I'm not a linux geek, and I usually use only soft links... they're enough for me, but people didn't get how the hard ones work and how size is counted.

A group of selected files, links or not, will always be counted as a sum. This means that if I take a 10MB file, and make 2 hard links, the selection of all three of them will have 30MB and this is the correct size, because unlike the soft links which are related to the file's original Master File Table entry and have 0 bytes, hard links are related to the data itself, have their own entry in MFT but point to the same data address, obviously having as size the size of the actual data, same times, attributes and so on. Why, below.

How much is left on the drive? Simple: exactly as much as the drive's own properties reports. Don't go selecting all the files, hidden and non hidden on C and making comparisons, or using tools that do that automatically because it won't show the actual HDD usage. Why? Because:

  1. that operation makes a list of all the selected files including hard links as separate files, takes each of them and adds the sizes up, the drives properties counts the actual stored data
  2. not all the files will be counted, folders protected from traversing and files from reading will not be counted and the System Volume Information usually has very large files protected just in this manner
  3. that number is useful only in cases of file transfer, if the files, links, etc need to be copied to DVD or NAS, that's how much they would occupy, and the links will not be preserved since they are NTFS specific features, not available or available in different forms under ISO, UDF, NFS and other file systems, but they will be cloned.

Make a test... copy a 10MB file, a.exe, from a different drive and notice how the free space drops by the 10MB. Make a hard link (mklink /H b.exe a.exe). Now these two files selected will "use" 20MB in the selection properties, but actually only 10MB verified at the drive's properties, which will have the same free space as it did/does after the file copy. Delete one, either one, the free space will remain the same. Now delete the last one and the space will increase by 10MB. Was there any harm done? NO.

What is winsxs? A much better dllcache. Where with the dllcache in XP we had copies of files that actually added to the size usage since they were cloned, this actually improves usage but not total protection (against viruses). If a rogue uninstaller thinks it has to remove some runtime libs from System32, it would only delete the links, but not the data, then the links would be recreated while keeping data space usage at lowest possible, better than archiving winsxs in cabs and having the cabs along side the original files. Also winsxs bring serialization, compartmentalizing files with the same name but different version, for the dev's sake, which is a good thing / bad thing, it makes them lazy to code properly but it helps when they don't want to code anymore.

I did this to help anyone that lands here out of the same reasons I did... excessive "usage of space" by winsxs after SP1. And I hope it was helpful.

1
  • Is this answer not an extremely important aspect which is completely missing in the accepted answer?
    – mafu
    Aug 13, 2015 at 11:24
34
+450

These duplicates and backups are extremely annoying when having limited disk space.

Being in that place, the only way I found that would not jeopardize the OS stability was to generously use the "Compress contents to save disk space" setting.

By compressing all those backup directories under the Windows directory, I was able to reduce the directory size from 6.5 GB to 5 GB, with no recognizeable side effects. Using it on some of your stuff outside the Window directory would stretch your 10 GB even more.

12
  • 2
    I tried compressing it and i says "Access denied" to the folder and then poqexec.log. Assumed it was a read lock. Anything to bypass this? Sep 15, 2009 at 6:41
  • 1
    Actually, you're still jeopardizing your OS's stability. The WinSxS folder should NOT be compressed. In fact, it's quite a bad idea. Just google 'compress winsxs' and you'll find out.
    – Hello71
    Jun 13, 2010 at 15:15
  • 6
    I'm not sure that this technique is a good idea -- many files in the winsxs tree are hard-links. Will enabling compression on these files compress all instances of the file? There could be some unintended performance consequences. Dec 9, 2011 at 17:41
  • 3
    @FiascoLabs, have you noticed this is a 4 year old question, which specifically refers to a 10GB drive? You could just as well state that "nobody uses Vista". It might be true now, but wasn't so at the time the question was asked.
    – Eran
    Jun 22, 2013 at 14:01
  • 1
    @eran Yet all Win7 questions about winsxs get closed as duplicate of this question Jul 17, 2013 at 12:29
29

If you have Vista and have SP2 installed, you can clean up old system files with the new Service Pack Clean-up Tool.

  1. Click Start>All Programs>Accessories>Command Prompt or click Start>Run and type cmd to open Command Prompt Windows
  2. Execute the command “Compcln.exe”. The path is “c:\Windows\System32 \compcln.exe”.
  3. Users will be prompted a question whether to keep Vista SP2 permanently in the system.
  4. Type “Y” and press enter, the system will start performing the windows components clean.
4
  • I couldn't locate this in my Vista SP1 Feb 16, 2010 at 15:44
  • Yeah it's probably new in Vista SP2. Mar 6, 2010 at 0:48
  • 4
    Didn't save so much for me, but I can confirm that the tool exists and it saved me a G plus
    – itj
    Apr 5, 2010 at 20:45
  • Compcln.exe isn't in W10. Oct 6, 2019 at 7:05
26

In Windows 8 you can reduce the size of the WinSxS folder by removing Windows Features:

DISM.exe /Online /Disable-Feature /Featurename:<name> /Remove

The important thing is the /Remove parameter which is new to Windows 8.

The most space in WinSxS is used the WindowsUpdates which you install over the time. In Windows 8/Windows 10 you can detect and remove Updates which are replaced by newer updates (like newer cumulative IE Updates) be running this command:

dism.exe /online /cleanup-image /startcomponentcleanup

or running the disk cleanup wizard and select "Windows Update Cleanup"

enter image description here

enter image description here

enter image description here

Also make sure you've installed the servicing stack update http://support.microsoft.com/kb/2821895.

This updates run an in deep cleanup of WinSxS and compresses all DLLs/Exe files, from WinSxS which are not currently in use, into smaller delta file:

enter image description here

Look at the different file sizes.

Windows 8.1 adds new DISM commands. The /startcomponentcleanup gets a new parameter /ResetBase which makes your last Update permanent and removes all older files to save more space.

You can also run a new command dism /online /cleanup-image /analyzecomponentstore to analyze the WinSxS folder:

enter image description here

It tells you now when you should run the cleanup to save space.

3
  • 2
    This is now available for Windows 7 SP1 as well: support.microsoft.com/kb/2852386 Oct 9, 2013 at 0:54
  • Here it was 12.4 Gb on disk before StartComponentCleanup on 1809. 6.54 GB on disk after StartComponentCleanup, a massive improvement. 92 pending deletes, no pending renames. Of the 76812 files in WinSXS, 21452 take up 2.90 Gb on disk with dates from Sep to Oct last year, when the computer was updated to 1803. Is this typical of a current W10 install or are we still clogged? Oct 6, 2019 at 12:52
  • 1
    @LaurieStearn I have no idea. I only run Win10 in VM and create a new VM for each new Win10 version on my windows 8.1 host system. Oct 6, 2019 at 14:30
21

You could use VSP1CLN.EXE to make SP1 permanent, which according to this page will free up superseded-by-SP1 components.

1
10

Good news! There is now an officially sanctioned method, from Microsoft, for Windows 7 SP1, to clean out your WinSXS folder.

  1. Install HotFix 2852386 - you can either download manually, or wait for it to come through your Windows Update
  2. This adds a new option to the Disk Cleanup Wizard (Under Clean Up System Files) that you can enable for "Windows Update Cleanup". Tick this option.
  3. Click OK

Caveat: You may be unable to un-install certain Windows Updates after running the cleanup of your WinSxS folder.

0
9

Looks like there is finally a way to do this in Windows 8.1 service pack 1 and Windows Server 2012 R2.

Component store analysis tool:

Dism.exe /Online /Cleanup-image /AnalyzeComponentStore

At the end of the scan, the user gets a report of the results (actual size of the winsxs folder) like this:

analyzecomponentstore results

Component store cleanup:

Today, Component Store Cleanup must be triggered manually by an end-user, either by running DISM, or by using the Disk Cleanup Wizard. In order to make Component Store Cleanup more useful for the average end-user, it will be added into a maintenance task, automatically saving disk space for end-users. To enable this, a change will be made to allow uninstallation of superseded inbox drivers without requiring a reboot (today, all driver installs/uninstalls done by CBS require a reboot).

  1. Dism.exe /online /Cleanup-Image /StartComponentCleanup

  2. Disk Cleanup tool, Clean up system files button.

    disk cleanup tool

  3. schtasks.exe /Run /TN "\Microsoft\Windows\Servicing\StartComponentCleanup"

1
7

Dism++ is what you're looking for (https://www.chuyu.me/en/index.html).

You will save gigabytes of space...

You'll need to select "Replaced WinSxS assemblies". If you do this - it'll give you a warning that these installed updates cannot be uninstalled. Click ok, then scan

enter image description here

It'll give you an idea of how much space you'll save. Hit cleanup, and it should clear up that space.

5
  • 1
    Specific instructions on how to use this program should be provided. I am able to get the program from Github but I am unable to visit the link you provided.
    – Ramhound
    Feb 27, 2017 at 14:47
  • 1
    I've tried this on a VM - seems pretty fast and hasn't really broken anything as far as I can tell. I might play with this, since it does seem to have a few nifty post-install features (ooh driver backups!). I've edited your answer with basic steps and a screenshot. You should be, hopefully, seeing the difference, and the upvotes shortly
    – Journeyman Geek
    Feb 28, 2017 at 1:30
  • Awesome tool! Unlike WinSXSLite, it worked and freed almost 8Gb of space for me.
    – Suncatcher
    Sep 21, 2017 at 12:00
  • 2
    THIS answer should be the solution and many hundred more UP votes! I've been searching for days and always found the same crap: Disk Cleanup, DISM, blah. All of them insisted nothing is to be deleted. Yet WinSxS had 10GB (and similarly other directories). Only with this Dism++ I was able to reclaim 7GB (!) on my Win7 Enterprise SP1 VM (whereas the other "solutions" didn't free a single byte)
    – divB
    Apr 17, 2020 at 21:02
  • I ran it on Win7 Pro in VM and it freed about 8Gb mostly from "Replaced WinSxS Assemblies" and "Windows Download Cache". So far the OS seems to be working fine.
    – ruslaniv
    Jul 18, 2020 at 15:19
3

Hope it will be helpful to have one simple oneliner as otherwise great answer of Jeff Atwood misses /ResetBase switch.

Caution: This switch greatly helps to reduce the size of WinSxS folder, but completely deletes previous versions of components, so you will not be able to roll back any updates installed before. But if your system behaves good, you should be safe (especially if you are not in Production environment)

dism.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase

This works in Windows 8.1 and later

2

Besides the aforementioned solutions, one way to gain significant space is to compress the whole folder content. However, this cannot be done using Explorer (proper rights are needed), at least starting from Windows 7.

These instructions show how to achieve this:

sc query msiserver 
sc query TrustedInstaller

sc stop msiserver
sc stop TrustedInstaller

sc config msiserver start= disabled
sc config TrustedInstaller start= disabled

icacls "%WINDIR%\WinSxS" /save "%WINDIR%\WinSxS.acl" /t

takeown /f "%WINDIR%\WinSxS" /r

icacls "%WINDIR%\WinSxS" /grant "%USERDOMAIN%\%USERNAME%":(F) /t

compact /s:"%WINDIR%\WinSxS" /c /a /i *

icacls "%WINDIR%\WinSxS" /setowner "NT SERVICE\TrustedInstaller" /t

icacls "%WINDIR%" /restore "%WINDIR%\WinSxS.acl"
del "%WINDIR%\WinSxS.acl"

sc config msiserver start= demand
sc config TrustedInstaller start= demand

sc start msiserver
sc start TrustedInstaller

Notes / tips:

  1. Grouping marks the recommended way to run these commands, if done manually. Normally, there should be no problems (except from some skipped files, because they are in use), but result for each group should be checked

  2. I have performed these steps on various operating systems installation at home and at work: Win7x64, Win10x64, Windows Server 2008R2 and Windows Server 2012 and I did not see any problems so far.

  3. Some steps take quite some time, especially the compressing time. Most steps will iterate and show processed files. Minimizing command prompt window might gain some speed.

-3

You can remove those files safely. If you ever need them again it will just require you to install a few more things.

Now on to the fix!

  • Open Windows Explorer and navigate to C:\Windows\System32. Look for the file "vsp1cln.exe."
  • Right click this file and select the 'Run As Administrator' option.
  • The Vista Service Pack 1 Cleanup Tool will remove all of the redundant files that it has replaced.

The amount of disk space you gain will depend on the system, what programs are installed, etc.

1
  • 17
    You can safely remove winsxs files? Are you sure about that?!
    – UpTheCreek
    Jan 21, 2011 at 8:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .