Over time, as your Windows Server runs longer, more and more disk space is eaten. Simply gone! Investigating the disk usage leaves you clueless; there are no large log files, crash dumps, or there is no software to be removed. Where did that space go?
The answer: Windows Updates, Service Pack, and hotfix installations.
Protip: this post also shows you how to move the Windows Server SoftwareDistribution folder and user’s Documents folder to a different partition.
The Windows disk cleanup utility cleanmgr is not available in Windows Server 2012 if the Desktop Experience-feature is not installed. This makes cleaning up used disk space a bit harder. You can utilize your
cmd.exe or PowerShell command-line, and use Deployment Image Servicing and Management (DISM) to clean up the Windows Component Store (WinSxS) in Windows Server 2012 and up.
The WinSxS folder is located in the Windows folder, for example C:\Windows\WinSxS. It’s the location for Windows Component Store files.
The Windows Component Store contains all the files that are required for a Windows installation. And, any updates to those files are also held within the component store as the updates are installed (source: KB 2795190 – and do read Manage the Component Store). The WinSxS folder will become large…
Let’s clean up WinSxS!
Dism disk cleanup: Deployment Image Servicing and Management (DISM) is a command-line tool that allows you to install, uninstall, configure, and update Windows features, packages, drivers, and international settings. The
/Cleanup-Image parameter of
dism.exe provides advanced users more options to further reduce the size of the WinSxS folder.
Dism.exe /Online /Cleanup-Image has a few extra parameters (or switches):
Throughout this article, I assume you’ll read help options, just add
dism.exe /Online /Cleanup-Image /?.
If you enjoyed this, you might also enjoy the following post summing up 5 extra ways to clean up disk space in Windows Server!
First you can use the
/AnalyzeComponentStore parameter. This analyzes the size of the Component Store in Windows. The AnalyzeComponentStore option is available in Windows 8.1 Windows Server 2012 R2, and it’ll notify you whether a Component Store Cleanup is recommended or not.
dism.exe /Online /Cleanup-Image /AnalyzeComponentStore
Dism.exe removes superseded and unused system files from a system with the
dism.exe /Online /Cleanup-Image /StartComponentCleanup
There is also a registered scheduled task called StartComponentCleanup. You can start this task from the command line:
schtasks.exe /Run /TN "\Microsoft\Windows\Servicing\StartComponentCleanup"
/StartComponentCleanup parameter is supported on Windows 8 and Windows Server 2012.
/ResetBase switch with the
/StartComponentCleanup parameter of
dism.exe, all superseded versions of every component in the component store is removed.
dism.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase
All existing service packs and updates cannot be uninstalled after this command is completed. This will not block the uninstallation of future service packs or updates.
/ResetBase parameter is supported on Windows 8.1 and Windows Server 2012 R2.
/SPSuperseded parameter removes any backup components needed for de-installation of a service pack. The service pack cannot be uninstalled after this command is completed.
dism.exe /Online /Cleanup-Image /SPSuperseded
The Service Pack cannot be uninstalled after this command is completed.
/SPSuperseded parameter is supported on Windows 7 or Windows Server 2008 R2 Service Pack 1, 2012, 2012 R2.
/AnalyzeComponentStoreoption is available in Windows 8.1 and Windows Server 2012 R2. Use this to analyze the size of the Component Store (WinSxS folder) in Windows.
As said at the beginning of this article, the Disk Cleanup Tool is available in Windows Server 2012, if you install the Desktop Experience-feature.
In some versions of Windows Server, you can simply copy
C:\Windows\system32\en-Us from an old Windows 2008 R2 server, if you don’t want to install the Desktop Experience feature.
The following steps to install (copy) cleanmgr may not work on all versions of Windows Server. Try for yourself.
Disk Cleanup Wizard addon on Windows Server 2008 R2
Microsoft KB2852386 adds a Disk Cleanup option on Windows Server 2008 R2, similar to the Windows 7 update. I’ve tested this on Windows Server 2012. It may not clean up everything, but at least a lot.
Here’s how to make
cleanmgr.exe available on Windows Server 2012 Standard (Windows version 6.2.9200) without installing the Desktop Experience feature:
Microsoft Windows [Version 6.2.9200] (c) 2012 Microsoft Corporation. All rights reserved. PS C:\Users\jan> $osversion = [System.Environment]::OSVersion.Version PS C:\Users\jan> write-host $osversion 6.2.9200.0 C:\Windows\System32>cd .. C:\Windows>copy WinSxS\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.2.9200.16384_en-us_b6a01752226afbb3\cleanmgr.exe.mui \Windows\system32\en-US 1 file(s) copied. C:\Windows>copy WinSxS\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.2.9200.16384_none_c60dddc5e750072a\cleanmgr.exe \Windows\system32 1 file(s) copied. C:\Windows>system32\cleanmgr.exe C:\Windows>
Unfortunately, this no longer works on Windows Server 2012 R2 (6.3.9600), probably due to KB2821895. As Aaron pointed out in the comments, the above solution to copy over the cleanmgr.exe and cleanmgr.exe.mui files doesn’t always work well, and therefore I removed this information for Windows Server 2012 R2.
Fortunately, the Disk Cleanup functionality is back in Windows Server 2016 (at least TP5).
After cleaning up the disk, a server reboot is required. Don’t forget to reboot your computer – or server – afterwards! The actual cleanup of the WinSxs directory occurs during the next reboot.
Error 0x800f0906 with DISM /Online /Cleanup-Image, PowerShell Install-WindowsFeature and SFC /scannow
Some reports are available explaining Microsoft Security Bulletin MS14-046 broke DISM /Online /Cleanup-Image /RestoreHealth, PowerShell Install-WindowsFeature with
-Source parameter, and
SFC /scannow. Yes, it broke a lot…
An update is made available by Microsoft: KB3005628
Update for the .NET Framework 3.5 on Windows 8, Windows 8.1, Windows Server 2012, and Windows Server 2012 R2. This update resolves an issue that prevents the optional Microsoft .NET Framework 3.5 feature from being enabled after you install security update 2966827 or 2966828 (described in Microsoft Security Bulletin MS14-046) for the Microsoft .NET Framework 3.5.
Over time, your Windows Updates SoftwareDistribution folder in
c:\Windows\SoftwareDistribution can become quite large, for example when multiple updates were not installed successfully.
Windows Update files are downloaded to this folder and removed after successful installation. When you find yourself in a situation where your
C: partition is rather small, and SoftwareDistribution folder eats up too much disk space, follow these steps to move the SoftwareDistribution folder to a different location.
All in a
cmd.exe shell (Start > Run >
cmd and press enter). In this example the new location is
- Stop the Windows Update service:
net stop wuauserv
- Rename the folder
rename c:\windows\SoftwareDistribution SoftwareDistribution.old
- Create a link using Windows Sysinternals Junction, or Windows mklink
- Create the new directory:
- Create the Junction:
c:\>junction C:\Windows\SoftwareDistribution "D:\Windows-SoftwareDistribution", or:
c:\>mklink /J C:\Windows\SoftwareDistribution "D:\Windows-SoftwareDistribution"
- Create the new directory:
- Restart the Windows Update Service:
net start wuauserv
When, after a while, everything seems to run and update fine, delete your SoftwareDistribution.old folder.
Another way for you to gain some extra free space is to move the User Documents folder (and others, like Downloads), for instance from
D:\User\$USER$\Documents (substitute $USER$ with the username whose Documents folder you want to move). Here are the steps for you to follow (screenshots taken from Windows Server 2016 TP5):
- Open Explorer and right click on the Documents folder and then Properties
- Choose Location
- Change the location where files are stored
- When the destination does not exist, Windows asks to create the folder for you
- After completion, files are moved to their new location.
Yes, the Windows component store (WinSxS folder) can become large, very large. But fortunately, Microsoft provides us the tools to monitor, manage and clean up the WinSxS folder to regain that used disk space.
If you are comfortable with installing the Desktop Experience Windows feature on your system, you can have the Disk Cleanup utility on your system. Otherwise, you can use the DISM (Deployment Image Servicing and Management) command for various clean up tasks.
To gain some extra free space, you can also move the Windows SoftwareDistribution folder to a different partition.
My name is Jan. I am not a hacker, coder, developer or guru. I am merely a systems administrator, doing my daily thing at Vevida.
If you feel a post has helped solve your problem, or has saved you time, please consider making a donation. You can transfer a direct donation through Paypal or via bank wire-transfer IBAN: NL31 ABNA 0432217258 (Jan Reilink). Thanks!