Why does the /winsxs folder grow so large, and can it be made smaller?
Solution 1:
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
Solution 2:
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:
- 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
- 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
- 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.
Solution 3:
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.