Why does the /winsxs folder grow so large, and can it be made smaller?

173

86

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!

Jeff Atwood

Posted 2009-07-15T06:27:46.723

Reputation: 22 108

1

You could use this: http://windowsfixup.com/2009/05/winsxs-folder-taking-up-too-much-disk-space-fix/ personally I would stay away from it unless I could find the source code

– Sam Saffron – 2009-07-27T08:03:18.893

11There are a lot of hard links in winsxs, so the size is also frequently over-reported. – Greg D – 2009-07-31T13:58:02.433

6Can't you grow the VM and extend the main partition? – Sam Saffron – 2009-07-15T08:52:07.610

"Administrators should not, for any reason, take it upon themselves to clean out the /winsxs directory." But you can. If you know Windows very well, it can go well and you can remove components. But it can also give pretty... interesting... results. I had much fun with this in the past. Basically you can remove every single part of the operating system. Windows can endure surprisingly much, especially if you don't reboot, but if you remove the wrong parts, it might become not realistically usable. – Fabian Röling – 2017-11-08T14:27:35.040

@sam: its a bat file. The source is right there... – Quintin Par – 2009-09-15T06:51:52.773

You didn't mention the fact that most of those files are hard-links, so Windows is actually just misrepresenting the size of the folder. See also here and here (the screenshots in the second serverfault answer are of windirstat by the way, +1 to that!)

– BlueRaja - Danny Pflughoeft – 2012-01-12T04:58:46.610

1http://omnicognate.wordpress.com/2009/10/05/winsxs/ – Brad Gilbert – 2009-10-05T17:31:35.280

24

TreeSize Free... I use http://windirstat.info/ for this purpose ;-)

– Steve Schnepp – 2009-07-15T07:45:15.600

A update is released for win7sp1 clients this month which deletes superseded windows updates and saves plenty of disk spaces. Please read this blog http://blogs.technet.com/b/askpfeplat/archive/2013/10/07/breaking-news-reduce-the-size-of-the-winsxs-directory-and-free-up-disk-space-with-a-new-update-for-windows-7-sp1-clients.aspx for more clarity.

– algo-geeks – 2013-10-09T09:24:09.297

4First Question on SuperUser – puretppc – 2014-01-31T16:52:44.260

Answers

7

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"

Jeff Atwood

Posted 2009-07-15T06:27:46.723

Reputation: 22 108

4

already posted way ago: http://superuser.com/a/594216/174557 No need to post the same thing twice ;)

– magicandre1981 – 2014-05-05T04:13:05.413

101

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

GvS

Posted 2009-07-15T06:27:46.723

Reputation: 1 130

@CeesTimmerman the command only works if you have something to remove – Ramhound – 2015-02-15T00:57:56.320

2excellent, I was just thinking of cleaning up Windows 7 SP1 – Jeff Atwood – 2011-03-09T22:21:37.857

6are there other commands for Windows 7 that can also remove non-SP update backups? – galacticninja – 2011-04-24T03:42:39.273

@galacticninja - Unfortunately I don't know any, if they even exist – GvS – 2011-04-24T06:41:12.347

Excellent! Used this on Windows 2008 R2 server and winsxs folder size went from 11GB to 6.5GB. – miha – 2011-10-28T14:09:14.883

Just used this command to reduce my Windows footprint by roughly 3 GB as well. Looks like a good chunk of it was due to a completely unnecessary Ultimate Edition package (I have Home Premium). – Will Bickford – 2011-12-09T03:21:25.017

1+1 this is awesome. Just to make it clear though, running this will remove your ability to roll back the service pack (not that you should be doing that...). – TM. – 2012-01-11T00:08:02.683

I went from 10.1GB winsxs folder to 6.5GB with this (win7 sp1) – TM. – 2012-01-11T03:24:48.343

My winsxs folder went down by 3.5GB, but my free space (which I'm told is the actual correct number) didn't go up at all. Pointless.

– BlueRaja - Danny Pflughoeft – 2012-01-12T05:05:23.107

8Alternatively you can use the "Cleanup system files" option in the Disk Cleanup tool and delete the Service Pack backup files. – Michał T – 2012-03-30T14:16:26.027

just went from 14gb to 8.61 with this – Maslow – 2012-08-19T15:57:23.000

Saved my 3.6 GB too of my nearly full SSD. – Wernight – 2012-09-04T06:31:49.907

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. – matt wilkie – 2012-11-02T21:00:28.837

@pies, that won't do the same thing. – UpTheCreek – 2013-04-03T14:52:59.643

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.` – Cees Timmerman – 2013-06-05T14:59:13.503

44

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.

Mateen Ulhaq

Posted 2009-07-15T06:27:46.723

Reputation: 3 207

Is this answer not an extremely important aspect which is completely missing in the accepted answer? – mafu – 2015-08-13T11:24:11.337

33

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.

eran

Posted 2009-07-15T06:27:46.723

Reputation: 1 193

1Actually, 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 – 2010-06-13T15:15:18.187

An OS should never need anywhere above 2GB of disk space for its files. Signs of bloat IMHO. And to top it off, MS makes wants to make it hard to opt out of retaining crap and bloat. – user55570 – 2017-10-07T06:44:33.340

@Hello71: Please note that he is compressing the back-up folder only. – Tamara Wijsman – 2011-01-23T00:32:08.197

@Tom Wijsman this is the '/winsxs/backup' folder, right? @eran Will this also work the same way with Windows 7? – galacticninja – 2011-04-24T03:40:06.407

@galacticninja: Yes, it is that folder. Yes, this works on Windows 7... – Tamara Wijsman – 2011-04-24T10:56:46.477

@Tom Wijsman I got the same issue as @Quintin Par (access denied error message). Do you know of any workarounds? This is on Windows 7 Ultimate, on an administrator account. – galacticninja – 2011-04-24T12:17:10.260

@galacticninja: Earn permissions on as much you can get (take ownership first and then recursively gain permissions for you administrator account) and then compress, you don't have to worry for a single log file to not be compressed. – Tamara Wijsman – 2011-04-24T13:40:49.767

6I'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. – duffbeer703 – 2011-12-09T17:41:37.353

2I 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? – Quintin Par – 2009-09-15T06:41:58.457

Compressing to save 1.5Gb of space isn't worth it, drives are cheap. – Fiasco Labs – 2013-06-21T05:39:34.747

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 – 2013-06-22T14:01:02.980

1@eran Yet all Win7 questions about winsxs get closed as duplicate of this question – Tobias Kienzler – 2013-07-17T12:29:41.180

27

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.

Tomas Andrle

Posted 2009-07-15T06:27:46.723

Reputation: 2 892

I couldn't locate this in my Vista SP1 – pencilslate – 2010-02-16T15:44:08.200

Yeah it's probably new in Vista SP2. – Tomas Andrle – 2010-03-06T00:48:16.017

4Didn't save so much for me, but I can confirm that the tool exists and it saved me a G plus – itj – 2010-04-05T20:45:56.553

Compcln.exe isn't in W10. – Laurie Stearn – 2019-10-06T07:05:09.867

21

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.

magicandre1981

Posted 2009-07-15T06:27:46.723

Reputation: 86 560

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? – Laurie Stearn – 2019-10-06T12:52:47.217

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. – magicandre1981 – 2019-10-06T14:30:26.117

2

This is now available for Windows 7 SP1 as well: http://support.microsoft.com/kb/2852386

– Mark Henderson – 2013-10-09T00:54:15.450

20

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

Ben Lings

Posted 2009-07-15T06:27:46.723

Reputation: 1 425

5

These guys shed 7GB with this tool: http://www.bit-tech.net/blog/2009/07/24/winxs-why-my-vista-install-bloated-to-28gb/

– hyperslug – 2009-07-26T17:01:20.507

9

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.

Mark Henderson

Posted 2009-07-15T06:27:46.723

Reputation: 5 956

2

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.

user425154

Posted 2009-07-15T06:27:46.723

Reputation:

1Specific 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 – 2017-02-27T14:47:52.343

1I'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 – 2017-02-28T01:30:42.963

Awesome tool! Unlike WinSXSLite, it worked and freed almost 8Gb of space for me. – Suncatcher – 2017-09-21T12:00:29.297

2

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

maoizm

Posted 2009-07-15T06:27:46.723

Reputation: 739

0

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.

Alexei

Posted 2009-07-15T06:27:46.723

Reputation: 303

-4

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.

Axxmasterr

Posted 2009-07-15T06:27:46.723

Reputation: 7 584

16You can safely remove winsxs files? Are you sure about that?! – UpTheCreek – 2011-01-21T08:53:24.493