WinSXS and Windows Server 2012 cleaning methods

Άρθρο από Lefteris Karafilis Wed, 09/01/2013 - 10:38

WinSXS folder is the component store of Windows vista and later operating systems. Windows OS stores all its core components to WinSXS directory. The WinSXS folder is the only location that the core system components found on the system and all the system files you see in their usual locations, in the windows directory structure, are hard linked back to the WinSXS folder. WinSXS folder is the only location that OS stores its components; everything else are just hard links. To prove the later point you can use the fsutil to check the hardlinks of a system file.

So, WinSXS starts large! But why is growing larger? The answer is updates. Every time a binary updates, a new version of the whole component is released and the old version is retained for reliability reasons in the component store. The updated version of a component is projected to the system (hardlinked) but the old version is retained with no hardlinks. This is the reason an update can be safely uninstalled from the system. If you uninstall an update from the system the next higher version of the component is used and other component changes may also be triggered as a result of dependencies.   

Note, that WinSXS folder sometimes is perceived to be much larger than actually is. This misconception is because windows explorer and dir command are not aware of the difference between actual files and hardlinks. To have a better view of the disk space consumed by WinSXS you can use the SysInternal's du utility (du -v c:\windows\winSXS).

It is obvious that you cannot delete WinSXS folder files manually because this will cause problems to the OS. You can take advantage though of some features Windows 8 and Windows Server 2012 have introduced to cleanup some files.

Features on Demand

Windows 8 and windows Server 2012 introduced a new feature called "features on demand". Features on demand are simply a feature that allows you to remove role and feature payloads from the OS to conserve diskspace. By default, windows OS stores under %windir%\WinSXS folder all feature and role payloads, either installed or not, making an OS able to add features and roles without the need of an installation source.

In windows Server 2012 you can remove those payloads by using the powershell command uninstall-windowsfeature with the -remove switch. In case you want later to install a feature of which you previously removed its payload from the system; you can use the install-windowsfeature command. Install-windowsfeature will try to install a windows feature from the following source locations: local winSXS store or Windows Update in case of a payload removal from the local WinSXS store. You can also specify the -source switch to instruct the command to seek payloads from the alternate source path specified instead of windows update.

To cleanup any windows feature payload from the system you currently don't use execute the following command:

Get-WindowsFeature | where-object{$_.Installed -eq 0 -and $_.InstallState -eq 'Available'} | uninstall-windowsfeature -remove

The first part of the command gets the windows features that are not installed on the system and have its payloads available and pipes it in the uninstall-windowsfeature command for removal.

   

Clean up the WinSXS folder from superseded components

You can remove any backup files created during the installation of a service pack by using the following command:

dism /online /cleanup-image /SPSuperseded


Note that after you execute that command you will no longer be able to uninstall the service pack.

To further cleanup any superseded components and reduce the size of the component store execute:

dism /online /cleanup-image /StartComponentCleanup

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options