Bobcares

WeSupport

Call Us! 1-800-383-5193
Call Us! 1-800-383-5193
Call Us! 1-800-383-5193

Need Help?

Emergency Response Time custom

Our experts have had an average response time of 11.06 minutes in March 2021 to fix urgent issues.

We will keep your servers stable, secure and fast at all times for one fixed price.

Clean Up and Compress WinSxS Folder on Windows Server/Windows 10

by | Apr 27, 2021

Wondering how to Clean Up and Compress WinSxS Folder on Windows Server/Windows 10? We can help you with it.

As part of our Server Management Services, we assist our customers with several Windows queries.

Today, let us see how our Support techs clean up the WinSxS folder on Windows Server 2016/2019.

Clean Up and Compress WinSxS Folder on Windows Server/Windows 10

The WinSxS directory will grow in size over time. Moreover, its size is not limited by anything.

Today, let us see the WinSxS folder in Windows, the reasons of its constant growth and safest ways to clean up the WinSxS folder on Windows Server 2016/2019.

  • Initially, optimize the component store and remove old versions of Windows component files left after installing Windows updates.
  •  Features on Demand – allows us to remove unused Windows components from the disk.
  • Finally, enable NTFS compression on the WinSxS folder – a way to reduce the size of the WinSxS directory using the built-in compression of the NTFS file system.

Steps to Clean Up and Compress WinSxS Folder on Windows Server/Windows 10

Firstly, get the current size of the WinSxS folder on Windows by opening the properties of the %windir%\WinSxS folder in File Explorer (or use a PowerShell script). Most file managers (including File Explorer) show a slightly larger WinSxS folder size than it takes on disk.

We can find out the real size of the WinSxS folder on disk using the du tool from Sysinternals:

du -v c:\windows\winSXS

We can also analyze the size of the component store (WinSxS folder) using the DISM command:

Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore

Deployment Image Servicing and Management tool
[==========================100.0%==========================]
Component Store (WinSxS) information:
Windows Explorer Reported Size of Component Store : 8.44 GB
Actual Size of Component Store : 8.15 GB
Shared with Windows : 5. 74GB
Backups and Disabled Features : 1.97 GB
Cache and Temporary Data : 438.31 MB
Date of Last Cleanup : 2021-02-22 20:37:29
Number of Reclaimable Packages : 1
Component Store Cleanup Recommended : Yes
The operation completed successfully.

As we can see, we can reduce the size of the WinSxS folder by (1,97 + 0,44) GB.

The DISM command also allows us to check and repair our Windows image.

DISM /Online /Cleanup-Image /RestoreHealth

 

How to Clean Up the Component Store (WinSxS folder) on Windows

Initially, clear the Windows Component Store (the WinSxS folder) by optimizing the storage with the command:

Dism.exe /Online /Cleanup-Image /StartComponentCleanup

The StartComponentCleanup DISM option is supported on all Windows versions starting from Windows 8 and Windows Server 2012.

After cleaning is complete, check the current size of the component store:

Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore

After that, we 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). To clean up old versions of components, run:

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

In Windows 7 and Windows Server 2008 R2, an additional DISM option was used to clean up old versions of components that were left over after installing service packs.

DISM /online /Cleanup-Image /spsuperseded

We can also remove old update files using the “Disk Cleanup” wizard:

1. Firstly, run the cleanmgr command as an administrator
2. Then, select the disk and in the next window, click the “Clean up system files” button.
3. Finally, select the “Windows update cleanup” option. The Disk Cleanup tool will show how much space we can free up by deleting old Windows update files. In this example, this is 324 MB. Click OK to start the cleanup.

After we finish cleaning up the component store using DISM, we can check how much disk space has been freed.

How to Enable NTFS Compress on WinSxS Folder on Windows 10

Another way to reduce the size of the WinSxS directory on Windows 10 is to compress the directory contents on the level of the NTFS file system.

As in case of any non-standard intervention into the system configuration, it is strongly recommended to create a full backup of our Windows 10 image.

1. Firstly, open the command prompt as administrator.
2. Then, stop and disable Windows Installer and Windows Module Installer services:

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

3. Let us backup the Access Control Lists (ACLs) assigned to the files and folders in the WinSxS directory using the built-in icacls tool. A backup copy of an ACL is a plain text file that lists all files and directories and the NTFS permissions assigned to them (later this file will be needed to restore the original ACLs):

icacls “%WINDIR%\WinSxS” /save “%WINDIR%\WinSxS_NTFS.acl” /t

4. Assign us as an owner of the WinSxS folder and all its subfolders:

takeown /f “%WINDIR%\WinSxS” /r

5. Grant our account full control permissions on the WinSxS directory:

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

6. We can now compress files in the WinSxS directory using the compact command. Because some of the files can be used by Windows, we need to specify the /i option. Otherwise, compression will stop at the first locked file (in Windows 10, we can use more advanced LZX compression):

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

7. Restore the owner of the WinSxS directory back to TrustedInstaller:

icacls “%WINDIR%\WinSxS” /setowner “NT SERVICE\TrustedInstaller” /t

8. Restore the original ACLs for the WinSxS folder items using the ACL backup file we created earlier:

icacls “%WINDIR%” /restore “%WINDIR%\WinSxS_NTFS.acl”

9. Restore the default startup type for the Windows Installer and Windows Module Installer services:

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

Now check the current size of the WinSxS folder.

These commands can either be run separately (then it is much easier to track the results of each of them) or used in a single script file. If we run it, the described compression procedure for items in the WinSxS folder will start.

[Need assistance? We can help you]

Conclusion

In short, we saw how our Support Engineers Clean Up and Compress WinSxS Folder on Windows Server/Windows 10

Are you using Docker based apps?

There are proven ways to get even more out of your Docker containers! Let us help you.

Spend your time in growing business and we will take care of Docker Infrastructure for you.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF