Hello dear readers
I already posted an article about How to Clean up the WinSxS Directory and Free Up Disk Space on Windows Server 2008 R2.
Today, you'll find hereunder the extra bonus part 2 for those want to clean more and need to get extra free space!
Wish you a nice reading!
I already posted an article about How to Clean up the WinSxS Directory and Free Up Disk Space on Windows Server 2008 R2.
Today, you'll find hereunder the extra bonus part 2 for those want to clean more and need to get extra free space!
Wish you a nice reading!
In this article we will talk about the WinSxS folder in Windows 8, the reasons of its constant growth and means of cleaning. The directory C:\windows\WinSxS is the storage of Windows components. This directory contains DLLs, binary and XML files necessary for installation and operation of any of Windows roles. When installing the OS updates, the new version of the updated component is installed in the system, while the old one is stored in the WinSxS storage (according to Microsoft, it is necessary to provide compatibility and make it possible to roll back to the old versions of components).
Another feature of the WinSxS folder is a huge amount of hard links in it. A hard link is a peer file pointer. 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. It is due to hard links, taken into consideration when calculating the total size of the folder, that the file managers (including Windows Explorer) show a bit exaggerated size of the WinSxS folder. You can find out the real size of the WinSxS folder using du (small utility from Sysinternals):
Many users commonly ask if they can delete files from the WinSxS folder manually. The answer is categorically NO! These actions are likely to result in injuring the Windows 8 health. Though some attempts to remove files from the WinSxS folder can be successful, this means cannot be recommended due to its potential danger to the system.
Let’s dwell on the less harmful means of cleaning up the WinSxS folder in Windows 8. These are:
- Disk Cleanup Tool
- Features on Demand, that allow to remove the unused Windows 8 components from the disk
- Compressing files in the WinSxS folder — the means to reduce the size of the WinSxS directory due to NTFS compression
To reach the best result, you can use all three ways simultaneously.
Disk Cleanup Tool
Disk Cleanup Tool (cleanmgr) - which allows to delete deprecated updates (updates which were replaced with the newer ones).
Features on Demand in Windows 8
In the article «Safe Clean Up of the WinSxS Folder in Windows Server 2012» we considered the new option Features on Demand, that allowed to remove binary files of the unused roles from the WinSxS folder. To remove the unused roles from the disk, there is a special PowerShell cmdlet – Uninstall-WindowsFeature. However, it’s not all as easy as it sounds in Windows 8. The thing is that there is no Uninstall-WindowsFeature cmdlet in Windows 8. Features on Demand technology is based either on DISM or DISM PowerShell cmdlet. Moreover, it’s important to know that DISM command in contrast to Uninstall-WindowsFeature cmdlet doesn’t analyse package dependencies. So, after removing a Windows package using DISM only the component specified in the command will be removed and all dependent packages will stay in the system. This is the reason why DISM shouldn’t be used to remove roles from the disk in Windows Server 2012, since there is a more convenient and functional way to do it.
You can get the complete list of available functions in Windows 8 with the command:
Let’s suppose, for instance, that we won’t need TelnetServer role. Let’s delete it from the disk (from the WinSxS directory) completely using the command:
If you display the list of all functions available in Windows 8, you can see that the component status has changed to Disabled with Payload Removed.
Thus, Windows 8 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 advanced users, who know what this or that component does in Windows 8.
Compressing the Contents of the WinSxS Folder in Windows 8
Another way to reduce the size of the WinSxS directory in Windows 8 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
- Let’s back up the access lists (ACLs) assigned to the files and folders in the WinSxS directory (this backup will become necessary when recovering original ACLs)
- Assign yourself as an owner of the WinSxS folder and all its subfolders
- Grant your account full rights on the WinSxS directory
- Compress the WinSxS directory and its contents with the command compact. Some files can be used by the system, so if you run this command without /i, 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 (CTRL+F) and stop it with Process Explorer. Thus you can achieve maximum compression ratio. We will confine ourselves to the compression of the unused files.
- Change the WinSxS directory owner back to TrustedInstaller
- Recover original ACLs to the WinSxS directory
- Recover the startup of Windows Installer and Windows Module Installer
Now check the size of the WinSxS folder:
As you can see, in our example after the compression the size of the WinSxS folder has reduced from5.8GB to 4GB (approximately by 1/3). Not bad, especially taking into consideration that the compression took place for a small SSD with free space highly appreciated.
What Can WinSxS Reduction Influence on?
Windows 8 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. But the modern CPU performs these processes almost instantaneously, so a user can see no difference in speed. On top of that, if a hard drive is slow and a CPU is fast enough, you can observe even the increase in the speed of operation! 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.
These commands can either be run separately (then it is much easier to control 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 command 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.
No comments:
Post a Comment