___________________________________________________________________________________________________________________________
IMPORTANT ANNOUNCEMENT FOR OUR READERS!
AskPFEPlat is in the process of a transformation to the new Core Infrastructure and Security TechCommunity, and will be moving by the end of March 2019 to our new home at https://aka.ms/CISTechComm (hosted at https://techcommunity.microsoft.com). Please bear with us while we are still under construction!
We will continue bringing you the same great content, from the same great contributors, on our new platform. Until then, you can access our new content on either https://aka.ms/askpfeplat as you do today, or at our new site https://aka.ms/CISTechComm. Please feel free to update your bookmarks accordingly!
Why are we doing this? Simple really; we are looking to expand our team internally in order to provide you even more great content, as well as take on a more proactive role in the future with our readers (more to come on that later)! Since our team encompasses many more roles than Premier Field Engineers these days, we felt it was also time we reflected that initial expansion.
If you have never visited the TechCommunity site, it can be found at https://techcommunity.microsoft.com. On the TechCommunity site, you will find numerous technical communities across many topics, which include discussion areas, along with blog content.
NOTE: In addition to the AskPFEPlat-to-Core Infrastructure and Security transformation, Premier Field Engineers from all technology areas will be working together to expand the TechCommunity site even further, joining together in the technology agnostic Premier Field Engineering TechCommunity (along with Core Infrastructure and Security), which can be found at https://aka.ms/PFETechComm!
As always, thank you for continuing to read the Core Infrastructure and Security (AskPFEPlat) blog, and we look forward to providing you more great content well into the future!
__________________________________________________________________________________________________________________________
** If you're looking to free up disk space and reduce the size of the WinSxS directory on Windows 7 SP1, make sure to check out the following blog post on this topic**
** If you're looking to free up disk space and reduce the size of the WinSxS directory on Windows Server 2008 R2, make sure to check out the following blog post on this topic**
————————————————————————————————–
Remember these on Windows 2003 Server?
I cannot count the number of times I’ve been asked how to clean this up.
Apparently I’m not the only one that hates clutter.
And what about that annoying prompt to insert your product CD-ROM now at the most inopportune time? I’ve literally been on mission critical server down situations where no one could locate a CD.
File corruption, repairs, installing features all required the CD.
Introduction of the Component Store
So with Windows Server 2008 and later, we moved from that to the Windows Side-by-Side (WinSXS) directory and there was much rejoicing as it introduced many new features that made the administrator’s job much easier:
- We no longer prompt for the CD when installing a role or feature (unless you’ve completely removed which only applies to Windows Server 2012 or later)
- We automatically repair corrupt files using a good copy from the component store
- Repairs such as System File Checker (SFC) no longer prompt for media
- All the previous versions of the operating system files are still readily available and newer versions (just in case you install a role or feature in the future) are too
But a few nagging questions began to popup…These typically come hand in hand with disk space cleanup.
What is this winsxs directory and why is it so large? See below.
Can I delete winsxs? No.
Can I move winsxs? No.
Can I cleanup winsxs? It depends…
We wrote a blog to get the message out: http://blogs.technet.com/b/askcore/archive/2008/09/17/what-is-the-winsxs-directory-in-windows-2008-and-windows-vista-and-why-is-it-so-large.aspx
The gist, you could uninstall a role/feature, but it was still there…along with all the updates that might ever be needed.
There’s also a good one on how to reclaim space after installing a service pack:
http://blogs.technet.com/b/joscon/archive/2011/02/15/how-to-reclaim-space-after-applying-service-pack-1.aspx and here as well: http://support.microsoft.com/kb/2795190/EN-US or if you’re looking to cleanup disk space on
Windows Server 2012 in general, check this out: http://social.technet.microsoft.com/wiki/contents/articles/15221.enabling-disk-cleanup-utility-in-windows-server-2012.aspx
Windows Server 2012 Features on Demand
Then came Windows Server 2012 Features on Demand with the ability to remove any unwanted role/feature and all is well. So far.
And it’s easy too with 3 simple steps:
1) Open an administrative PowerShell command prompt
2) Use the Get-WindowsFeature command to find the name of the role/feature
3) To uninstall, run the following command:
Uninstall-WindowsFeature –name <name of role/feature> -remove
Tip: Add the –Whatif switch to the end to see exactly what will be removed without actually removing it.
So why do this? I’ll leave you with three reasons:
1) Decrease the footprint of the base server install
2) Reduce the number of potential patches (and reboots)
3) Increase security compliance by removing features not integral to the role of the server
But don’t worry. We’ll let you add them back if you change your mind. 🙂
So what happens if you try to reinstall a role or feature that has been completely removed?
Well, we alert you that the feature or role is missing and we will automatically attempt to retrieve it from Windows Update (or WSUS), a source location specified by Group Policy, or you can manually specify an alternate source path.
What does this look like in PowerShell?
For starters, when you run the Get-Feature command, it will show the role or feature as Removed:
If you still attempt to add the role or feature via PowerShell, here’s what it looks like:
At this point, it’s obvious we do not have the Group Policy configured with the alternate source location. We can either grant the server external internet access and allow it to get the feature from Windows Update, if possible, or we can specify a source location with our Install-WindowsFeature command by specifying the –Source switch. Here’s an example:
Install-WindowsFeature web-server –source {source location and source file}
Here’s what this looks like in the GUI:
If you click on the Specify an alternate source path option, you are presented with the following:
You can specify a share with the install.wim file, but you also need to specify the index of the image within the WIM file. More on that here in a minute.
If you would like to configure this ahead of time through Group Policy, the policy we policy we configure is Computer Configuration\Administrative Templates\System\Specify settings for optional component installation and component repair
Here’s what the policy looks like when we go to enable and configure it:
Notice the options to Never attempt to download payload from Windows Update or Contact Windows Update directly to download repair content instead of Windows Server Update Services (WSUS). These options can come in handy depending on the configuration of your environment.
I personally think it’s cool that we can now point to an install.wim file instead of a share with a flat of the install media.
To do so, we specify the WIM parameter along with a share that contains the install.wim file. We also have to specify which image within the install.wim file we wish to use as our source.
For those of you that don’t know, a .wim file is simply a container that contains one or more images. These can be custom images that you’ve created and captured yourself, modified images that have modifications such as injected security updates, or just the base images contained in the default install.wim file pulled out of the Sources directory on the Windows Server 2012 media.
Therefore, the index number we provide could be different depending on the install.wim we are pointing to as our source.
To find out which image you would like to use, run the dism /get-Wiminfo /wimfile:{location of install.wim} to list out the images contained within the install.wim file. Here’s what this looks like for the default install.wim:
Since I’m deploying mainly Windows Server 2012 Standard in my environment, I need to specify an index of 2. The majority of you are probably deploying Windows Server 2012 Standard as well, unless you’re setting up Hyper-V servers, then its likely Datacenter or potentially Server Core, then it’s one of the Server Core editions. However, there are no edition-specific role differences between Standard and Datacenter edition. So really, I could specify an index of 2 or 4 and be just fine.
The end result is that my alternate source file path is as follows:
wim:\\KMS-2012\2012_Source\install.wim:2
Now when reinstalling my role or feature, it uses this source and works like a champ!
Things to keep in mind when using the install.wim as your source:
- As you apply updates to your servers, you want to keep your source install.wim that you are using for re-adding roles and features updated too. So why is this? If you remove a role or feature after it has been updated, it is possible that the update you applied previously that updated that role or feature spanned multiple roles and features and therefore was not removed. When you attempt to re-add the role or feature back using the install.wim source, if it’s not as updated as the server expects, it will fail to re-add it. If it is newer than expected, that’s fine. It just can’t be older than expected.
- When we remove a role or feature, we do delete the files associated with that role when we remove the role, but we don’t uninstall the updates that have already been applied. When the role is enabled again we need files from any updates that have been applied to it.
- It’s ok for the install.wim to be more up to date than the server that you are enabling the role for. The important part is that the install.wim has the files from all the updates that have been applied to the server affecting the role being enabled. Also note that if the install.wim is more up to date than the server, enabling the role will never install new updates directly from the install.wim. To bring the server up to date, new updates need to be applied in the normal way, such as WSUS or Windows Update.
- If you are attempting to install .Net Framework 3.5 on Windows Server 2012, instead of specifying the install.wim, you need to specify the Sources\SxS directory on the DVD or if providing the source, the files in the SXS directory copied from the DVD are just for .Net Framework 3.5. You can host them on a share and supply them through the GUI or through Group Policy just like any other feature.
If all that is too much to keep up with, just use Windows Update. As long as the service is not disabled, blocked at the firewall, or blocked by group policy; if we don’t find what we need in the specified install.wim or on the server, we’ll automatically search Windows Update. It works like a champ. 🙂
Enjoy!
~ Charity “Will slim base installs be the new wave of the future?” Shelbourne
11-25-13 Spanish version of this post http://blogs.technet.com/b/ask-pfe-latam-plat/archive/2013/09/13/como-reducir-el-tama-241-o-de-la-carpeta-winsxs-y-liberar-espacio-en-windows-2012-con-features-on-demand.aspx -MarkMoro
thanks, I already saw and used the new commands:
<a href="imgur.com/C0Vrah7"><img src="i.imgur.com/C0Vrah7.png" title="Hosted by imgur.com"/></a>
<a href="imgur.com/tbTwuTx"><img src="i.imgur.com/tbTwuTx.png" title="Hosted by imgur.com"/></a>
But someone from MS should still blog about them.
Thank u. i found out the answer to my question
@ deiruch
Great pointer! Thank you!
@Charity Shelbourne
The Update KB2821895 (servicing stack update) offers a new way to save space. The /startcomponentcleanup now converts all files in WinSxS which are not used into diffs (like the diffs which are inside the MSU files). This reduces the WinSxS size a lot.
Before:
dl.dropboxusercontent.com/…/01_WinSxS_vor.png
After:
dl.dropboxusercontent.com/…/02_WinSxS_danach.png
So around 1.7GB of saved space.
Here the example of the smaller files inside WinSxS:
dl.dropboxusercontent.com/…/ntfs_WinSxS.png
I think someone should blog about this important change.
@Andre.Ziegler
Those are excellent results. I completely agree. This needs to be blogged about. Let me see what I can do. Thanks for the great tip and sharing your results!!
@ Andre.Ziegler
Andre,
If you haven't seen these yet, these were released last Wednesday (6/26). I think a blog is still warranted though to get the message out there. These say Win 8.1, but also apply to server.
Manage the Component Store: technet.microsoft.com/…/dn251569.aspx
Determine the Actual Size of the WinSxS Folder: technet.microsoft.com/…/dn251566.aspx
Cleanup the WinSxS Folder: technet.microsoft.com/…/dn251565.aspx
Reduce the Size of the Component Store in an Offline Windows Image: technet.microsoft.com/…/dn251567.aspx
~ Charity
@ Ashely McGlone
Thank you! Glad you learned something new and it was easy to follow. 🙂
@ Ed
That's the entire problem. Yes, the component store made our lives easier in some ways, but more difficult in others (mainly disk space). With 2012, at least you can remove unnecessary roles and features which in turn will mean less updates. It's a step in the right direction, but it would still be nice if functionality were added to disk cleanup or dism that would allow us to cleanup previous file versions superseded by applied hotfixes and security updates like we can do with service packs.
@Charity Shelbourne
"but it would still be nice if functionality were added to disk cleanup or dism that would allow us to cleanup previous file versions superseded by applied hotfixes and security updates like we can do with service packs. "
this is included in Windows 8 😉
http://www.msfn.org/…/page__view__findpost__p__1015509
I learned something today. Well written and easy to follow. Thanks, Charity!
The command was present in the pre-releases and I've used it to force the scavenger to run (after disabling the features). In the RTM I saw that it also removes old Updates. The GUI also compresses files which can't be removed. Now after 6 years and a lot of discussion on connect, MSFT implemented most of my bug reports according to WinSxS.
Great write up!
I am sure many people will find this helpful.
Get-WindowsFeature | ? { $_.InstallState -eq "Available" } | Uninstall-WindowsFeature -Remove
PowerShell command for Remove Windows Features which not installed, and not removed.
Thank for @deiruch.
Good information. The problem has changed form as you've said, but still remains. The recent publicity about the free space on the 64GB Surface Pro is evidence of this.
Speaking of the Surface Pro- the .Net Framework 3.5 install doesn't work from Windows Update – it requires the DVD, which is a little hard to do since the Surface Pro includes neither a DVD drive nor a Windows 8 CD. I suspect the right files are somewhere on a recovery partition, but I had to find a drive and a disk to get this installed.
Is there any way to determine which features consume the most disk space?
@VOID269 That is unexpected. Have you verified that the temp directories are clear?
Nice post.
I love the –Whatif option provides a nice preview of the changes.
I run into size problems quite often and this freeware helps a lot:
http://www.mindgems.com/products/Folder-Size/Folder-Size.html
For those interested, this command removes all not currently installed features (copied from Example 3 technet.microsoft.com/…/jj205471.aspx):
Get-WindowsFeature | Where-Object -FilterScript { $_.Installed -Eq $FALSE } | Uninstall-WindowsFeature –Remove
@ TJ Cornish @ Ed @ Andre.Ziegler
I love community and these sort of discussions!! Andre.Ziegler, I think you made my day and probably TJ Cornish's and Ed's too. 🙂
I actually had not heard of the DISM /startcomponentcleanup switch until now. This blog was focused more on using the Features on Demand to reduce the size of winsxs store, number of updates, etc. that are needed. So I didn't look too much into disk cleanup. So let me look into the /startcomponentcleanup switch further and get back to the three of you. I want to find out more about how it works, if it differs from client vs. server vs. RT, and what all it cleans up (drivers, updates, 3rd party?, etc.).
@ r_haslund
Thank you!! 🙂
Well, I guess that answers part of the question that I have.
On the other hand, if Server 2008 R2/Windows 7 does not get a service pack by the time they go into extended support the winsxs folder will get quite large.
If you just install required updates, the size of the folder is quite huge. Now add a stack of non-security hotfixes and it could become quite huge. I wouldn't be surprised if within a couple of years [and no SP2] that the folder will grow to over 10GB. I can imaging what it will be at EOL.
Compare that to Win Server 2003/Win XP. Don't think you'll need to rollback an update? Kill the update in windows.
Muy buena entrada, todos nos acordamos de esas entradas en Windows 2003.
Thanks, great post.
Great article! Thanks
Can I combine all computers win7 through 8.1 and 2012r2 in one network location? or do I have to cobble some group policy to point to the different operating system folders on MDS?
Great article and very handy update. Count me in for the vote to have this for Server 2008 R2. I know of many servers that could use this especially when you reduce the size of the OS drive and use the remaining disk for data storage.
I would probably do cleanup little bit more aggressively
get-windowsfeature | where installstate -eq available | ForEach-Object -Process {Uninstall-WindowsFeature -name $_.name -remove}
Ups, this is much better.
Get-WindowsFeature | where installstate -eq available | Uninstall-WindowsFeature -Remove
Pingback from The Most Popular Posts of 2013 and Belated Birthday – Ask Premier Field Engineering (PFE) Platforms – Site Home – TechNet Blogs
We are running Server 2012 R2 and after uninstalling all unused Windows Features with the ‘-remove’ switch we have found our C drive actually increases in size by nearly a gig. Why would this be?
I just want to use a simple computer with ONE set of files, not 3000 copies of the same DLL. I want to absolutely disable the WinSxS system. I just want a personal computer to listen to music on and edit a couple of documents once in a while! And I want to do it in a VM with 20GB of disk space in total! Why do you make things so complicated?
Pingback from How to Clean up the WinSxS Directory and Free Up Disk Space on Windows Server 208 R2 with New Update – Ask Premier Field Engineering (PFE) Platforms – Site Home – TechNet Blogs
Pingback from How to Clean up the WinSxS Directory and Free Up Disk Space on Windows Server 208 R2 with New Update – Ask Premier Field Engineering (PFE) Platforms – Site Home – TechNet Blogs
Pingback from How to Clean up the WinSxS Directory and Free Up Disk Space on Windows Server 2008 R2 with New Update – Ask Premier Field Engineering (PFE) Platforms – Site Home – TechNet Blogs
Pingback from How to Clean up the WinSxS Directory and Free Up Disk Space on Windows Server 2008 R2 with New Update – Ask Premier Field Engineering (PFE) Platforms – Site Home – TechNet Blogs
** If you're looking to free up disk space and reduce the size of the WinSxS directory on Windows
Pingback from How to Clean up the WinSxS Directory and Free Up Disk Space on Windows Server 2008 R2 with New Update – Ask Premier Field Engineering (PFE) Platforms – Site Home – TechNet Blogs
Pingback from How to clean up WinSxS folder on SBS 2011 or Windows 2008 R2 | Oxford SBS Guy
How to Reduce the Size of the Winsxs directory and Free Up Disk Space on Windows Server 2012 Using Features on Demand – Ask Premier Field Engineering (PFE) Platforms – Site Home – TechNet Blogs
原文地址:
http://blogs.technet.com/b/askpfeplat/archive/2014/05/13/how-to-clean-up-the-winsxs-directory-and
Thank you very much for this article. Very informative!
But I still have one question regarding "As you apply updates to your servers, you want to keep your source install.wim that you are using for re-adding roles and features updated too."
Is there a way to update my install.wim automatically? The best way would be if it was updated directly by WSUS.
Any hints on how to accomplish that?
@ FI
You can do this with SCCM 2012 R2’s Offline Servicing feature. If you don’t have SCCM, I’m not aware of any built-in WSUS functionality to do this.
That said, you could probably script it using Powershell, and set a scheduled task to run the script once a month. It’d be pretty laborious though I think.
Has anyone actually verified this thing? Because it DOES NOT WORK!
I have removed ALL features and the winsxs is still 10GB+ in size.
Is there similar info available for Windows 10? I only have a 20 Gb solid state hard drive, and the WinSxS directory is over 6 Gb, consuming over 25% of my hard drive. Would love to move it offline, or just download components as-needed. How is it done
on Windows 10?
Thx!
@johny w-
Run cleanmgr.exe, you should have an option to clean up windows update files. You don’t need to go through the additional measures of adding desktop experience, etc for the desktop OSes.
白银小时级别持续上升,短线支撑3240、阻力位置3280一带,晚间数据前预计在该区间震荡的概率较大,晚间需重点关注美国GDP初值和明天凌晨的美联储会议进展.