In this article we will talk about the WinSxS folder in Windows 10 and Windows 8.1, the reasons of its constant growth and ways to clean up it. The C:\Windows\WinSxS directory is the repository of Windows components. This directory contains DLLs, binary and XML files necessary for installation and operation of any Windows roles or features. When installing the Windows updates (usually this happens every month), the new version of the updated component is installed in the system, while the old one is saved to the WinSxS folder (it is necessary to provide compatibility and make it possible to roll back to the old versions of the components when you uninstall the problematic update).
Over time, the WinSxS directory is constantly increasing, and its size is not limited by anything (although in practice the size of the WinSxS folder in Windows 10 / 8.1 rarely exceeds 15-20 GB).
The easiest way to reduce the size of the WinSxS folder in Windows 10 and Windows 8 is to remove the old versions of the components remaining after the system update. To do this, you can use the standard disk cleanup wizard (cleanmgr.exe) or special options of the DISM command (see below).
How to Check the Actual Size of WinSxS Folder in Windows 10 / 8.1
Another feature of the WinSxS folder is a huge amount of symbolic hard links in it. A hard link is a pointer to a file that is completely equal to the original. That means that a pointer and a source file can have different names and are located in different directories of the same volume, but they point to the same object. The file managers (including Windows Explorer) show a bit exaggerated size of the WinSxS folder. The fact is that when calculating the size of a folder, they take into account hard links that are located in the directory. You can find out the real size of the WinSxS folder-using du utility from Sysinternals:
du -v c:\windows\winSXS
You can also analyze the size of the component storage (WinSxS folder) using the DISM command:
Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore
Deployment Image Servicing and Management tool
Component Store (WinSxS) information:
Windows Explorer Reported Size of Component Store : 7.00 GB
Actual Size of Component Store : 6.86 GB
Shared with Windows : 4.58 GB
Backups and Disabled Features : 1.86 GB
Cache and Temporary Data : 419.85 MB
Date of Last Cleanup : 2018-08-02 03:15:12
Number of Reclaimable Packages : 1
Component Store Cleanup Recommended : Yes
The operation completed successfully.
As you can see, in this case, I can reduce the size of the WinSxS directory by (1,86 + 0,42) Gb.
Many users often ask: if it’s possible to manually delete files from the WinSxS folder? The answer is categorically NO! These actions are likely to result in injuring the Windows image health. Though some attempts to remove files from the WinSxS folder can be successful, this method cannot be recommended due to its potential danger to the system.
Let’s dwell on the most safety ways of cleaning up the WinSxS folder in Windows 10 and 8.1. These are:
- Removing old versions of components from component store (remaining after installing updates);
- Features on Demand – that allow to remove the unused Windows features from the disk;
- WinSxS folder compressing – a way to reduce the size of the WinSxS directory using the NTFS compression.
To reach the best result, you can use all three ways together.
Clean Up Component Store (WinSxS folder) in Windows 10 / 8.1
In my opinion, the fastest and easiest way to clear the component store (the WinSxS folder) is to run the DISM command:
Dism.exe /Online /Cleanup-Image /StartComponentCleanup
The /StartComponentCleanup option has an additional /ResetBase option that allows you to remove all previous versions of components (after that you will not be able to remove installed updates or Service Packs, and the Uninstall button will disappear from the Uninstall an Update Control Panel item). The command looks like this:
Dism.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase
You can also remove old update files using the “Disk Cleanup” wizard:
- Run the cleanmgr command as an administrator;
- Select the disk and in the next window, click the “Clean up system files” button;
- Then select the “Windows update cleanup” option. The Disk Cleanup utility will show how much space you can free up by deleting old Windows update files. In my example, this is 324 MB. Click OK to start the clean up.
In addition, in the Windows 10 task scheduler there is a special automatic maintenance task that performs the same operation as DISM with the StartComponentCleanup option. This task removes all outdated updates older than 30 days. This task, named StartComponentCleanup, is located in the \Microsoft\Windows\Servicing section.
Features on Demand in Windows
In the article «Safe Clean Up of the WinSxS Folder in Windows Server 2012» we looked at the new option Features on Demand, that allows to remove binary files of the unused roles files from the WinSxS folder. To remove the unused roles from the disk, there is a special PowerShell cmdlet – Uninstall-WindowsFeature. The thing is that there is no Uninstall-WindowsFeature cmdlet in Windows 10 and 8.1. You can implement Features on Demand technology only using DISM or DISM PowerShell cmdlet. Moreover, it’s important to know that DISM command doesn’t analyze package dependencies comparing to Uninstall-WindowsFeature cmdlet. So, after removing a Windows package using DISM only the component specified in the command will be removed and all dependent packages will remain in the system. This is the reason why DISM shouldn’t be used to remove role files from the disk in Windows Server 2012/R2, since there is a more convenient and functional way to do it.
A complete list of available features in a Windows 10 /8.1 image can be obtained using the command:
DISM.exe /Online /English /Get-Features /Format:Table
Let’s suppose, for instance, that we won’t need TelnetClient feauture. Remove this component from the disk (essentially from the WinSxS directory) using the command:
DISM.exe /Online /Disable-Feature /Featurename:TelnetClient /Remove
If you display the list of all functions available in Windows, you will see that the component status has changed to Disabled with Payload Removed.
Thus, Windows allows to significantly reduce the size of the WinSxS folder by removing the unused components from the disk. The only thing is that this cleanup method suits only for the advanced users, who are familiar with the Windows 10 components and their purpose.
How to Enable NTFS Compress on WinSxS Folder in Windows 10 and 8.1?
Another way to reduce the size of the WinSxS directory in Windows 10/8.1 is to compress the directory contents on the level of the NTFS file system.
- Open the command prompt as administrator;
- Stop and disable Windows Installer and Windows Module Installer services:
1 2 3 4
sc stop msiserver sc stop TrustedInstaller sc config msiserver start= disabled sc config TrustedInstaller start= disabled
- Let’s back up the access lists (ACLs) assigned to the files and folders in the WinSxS directory using the icacls utility. A backup copy of an ACL is a plain text file that lists all files and directories and the NTFS permissions assigned to them (this backup will become necessary when recovering original ACLs):
icacls "%WINDIR%\WinSxS" /save "%WINDIR%\WinSxS_NTFS.acl" /t
- Assign yourself as an owner of the WinSxS folder and all its subfolders:
takeown /f "%WINDIR%\WinSxS" /r
- Grant your account full control permissions on the WinSxS directory:
icacls "%WINDIR%\WinSxS" /grant "%USERDOMAIN%\%USERNAME%":(F) /t
- Compress the contents of WinSxS directory using the compact command. Some files can be used (locked) by the system, so if you run this command without /I parameter, the compression will stop at the first file currently used by the system. You can find the name of the process that has opened this file using the Process (CTRL+F) and kill it. We only limit ourselves to compressing unused files (in Windows 10, you can use more advanced LZX compression):
compact /s:"%WINDIR%\WinSxS" /c /a /i *
- Restore the owner of the WinSxS directory back to TrustedInstaller:
icacls "%WINDIR%\WinSxS" /setowner "NT SERVICE\TrustedInstaller" /t
- Restore original ACLs to the WinSxS directory from the ACL backup file:
icacls "%WINDIR%" /restore "%WINDIR%\WinSxS_NTFS.acl"
- Restore the startup of Windows Installer and Windows Module Installer services:
sc config msiserver start= demand sc config TrustedInstaller start= demand
Now check the size of the WinSxS folder:
As you can see, in our example the size of the WinSxS folder after the compression has reduced from 5.8GB to 4GB (about a third). Not bad, especially for a small-sized SSD-drive, the place on which is quite expensive.
These commands can either be run separately (then it is much easier to monitor the results of each of them) or used in a single script file. If you run it, the described compression procedure of the WinSxS folder will start. You can download the ready-to-use batch file here: winsxs_ntfs_compress.bat
This script can be used regularly during system operation, because after new updates or applications have been installed, new uncompressed files will appear in the WinSxS folder.
What may affect the NTFS compression of the WinSxS directory?
Windows works with compressed files in the transparent mode. However, it can take some extra time to compress/decompress it, which means that the component or update installation processes can become somewhat slow. However, on modern CPU, the file compression / decompression is performed almost instantly, so the user may not even notice a real performance reduction. Moreover, if your HDD is slow, and the processor is fast enough, with compression you can even notice an increase in the speed of working with the disk! We should note that when the whole contents of the WinSxS folder is compressed, a number of files in some other system directories will also turn to be compressed due to the hard links.