Wednesday, January 2, 2013

How to Alleviate Disk Space Pressure Caused By a Large Windows Component Store (WinSxS) Directory



In Windows 7 and Windows 8, there is a new folder under C:\Windows called WinSxS, which basically stores dll and component files. It also stores older versions of all dll and component files and can grow to be quite large. In addition to that, a lot of space is taken up by the backup folder, which gets really big after you install a Service Pack, like SP 1 for Windows 7

The Windows component store (C:\Windows\winsxs) directory is used during servicing operations within Windows installations.  Servicing operations include, but are not limited to, Windows Update, Service Pack and hotfix installations. 

The component store contains all of the files needed for a Windows installation and any updates to those files are also held within the component store as they are installed.  This will cause the component store to grow over time as more updates, features or roles are added to the installation.  The component store utilizes NTFS hard links between itself and other Windows directories to increase the robustness of the Windows platform.

The component store cannot reside on another volume other than the system volume due to the use of NTFS hard links.  Attempting to move the component store will result in the inability to properly install Windows updates, Service Packs, roles or features.  Additionally, it is not recommended that files be manually removed or deleted from the component store.

To reduce the size of the component store directory on a Windows installation you can choose to make the service pack installation permanent and reclaim used space from the Service Pack files.  Doing this will make the Service Pack permanent and it will not be removable


This can be done by running the following command (Start, type CMD):
Note: Run CMD as administrator
dism /online /cleanup-image /spsuperseded /hidesp
If any service pack backup files were found, it will automatically clean them up. In my case, I didn’t install SP1, so there was nothing to remove and hence I didn’t save any space. You can do that on Windows 7 with SP1 and on Windows Vista SP1, you can do the same thing using a different tool. Basically, it removes all the older files, but makes the service pack unremovable.
In Windows 8, there are some nice new features added to the DISM command. You can now remove packages that you no longer want need or want. This is the command:
DISM.exe /Online /Disable-Feature /Featurename:<name> /Remove
So how do you know what features you can disable? Well, you can run the following command to see all the available features:
DISM.exe /Online /English /Get-Features /Format:Table
Now that you have the list, you can disable a feature like SimpleTCP shown below:
DISM.exe /Online /Disable-Feature /Featurename:SimpleTCP /Remove

Cheers,
Vikas Bhat