Server Core Blog: Minimizing Image Size with Features on Demand and Component Cleanup

We've been working hard over the past year to make Server Core even smaller and leaner than ever before. In Windows Server 2012, we made Server Core the default installation option and enabled 13 roles for installation on Server Core. In Windows Server 2012 R2, we've now enabled all but two roles for installation on Server Core.

 

In Windows Server 2012, an installation of Server with a GUI needs 11 GB of disk space (excluding page file). In Windows Server 2012 R2, that same installation needs just 9.8 GB of space to achieve the same exact level of installation (in terms of the roles and features available on disk). Similarly, we've reduced the footprint of Server Core from 6 GB to 5.2 GB! The decrease in disk space requirements means you can fit more Windows Server 2012 R2 Server Core VHDs on a storage volume of the same size than you could with Windows Server 2012.

 

A significant chunk of disk space is occupied by features that are available for installation but aren't installed. As you install updates on a server, the footprint continues to grow. Some security scanning tools may warn that unpatched files exist within the c:\windows\winsxs directory. In fact, these are not security vulnerabilities. Rather, they are archived versions of updated system files that may be restored in the event you choose to uninstall an update.

 

Microsoft has invested significantly in update technology, and we offer ultimate flexibility in terms of installing updates. Consider:

 

  1. Updates can be installed in any order
  2. You can uninstall any update in any order, even if that order is different from the order in which you installed the updates in the first place
  3. We support sophisticated error detection and recovery to protect the component store from installation failures

 

However, this flexibility results in an increase in disk usage.

 

Introducing Component Cleanup

To reduce the impact of this flexibility, in Windows Server 2012 R2, we are introducing Component Cleanup, which enables administrators to further reduce the disk footprint of their servers while leaving feature installation unaffected. Here's what Component Cleanup does:

 

  1. Compresses all manifest files, so that they take up less disk space
  2. Compresses inactive payloads (i.e. uninstallation data for hotfixes)

 

Component Cleanup takes about 45 minutes to run on our average test hardware and results in a further 1.2 GB savings on a Server with a GUI disk image. It doesn't make features unavailable for installation and it doesn't require computers to have a network connection at all. All compression is done locally and then any decompression, if needed, is done on demand. You can run Component Cleanup by using dism.exe:

 

Dism /Online /Cleanup-Image /StartComponentCleanup

 

 

More information is available in our TechEd presentation which was presented in New Orleans on June 3, 2013. We also presented this content at TechEd in Madrid, Spain on June 25. A link to the recording is available here: https://channel9.msdn.com/Events/TechEd/Europe/2013/MDC-B339#fbid=GgZkc8YUgzu

 

Quick Trick: Remove Disabled Feature Payloads using Features on Demand

In Windows Server 2012, we introduced Features on Demand which enables administrators to remove the file payloads of unneeded features from their Windows Servers, thereby reducing the needed disk space significantly. You can set up a Windows Server however you like and then remove the payloads for any roles that aren't enabled by running just two PowerShell commands:

 

  1. $L = Get-WindowsFeature | Where InstallState -EQ Disabled
  2. Uninstall-WindowsFeature $L -Remove

 

Here's what each line does:

 

  1. first, get the list of features that aren't installed but have payloads present on disk
  2. remove the payloads from that list

 

Once a feature's payload is removed in this way, the features files and any patches related to it are removed from the local disk. As a result, the feature can't be installed without an external, remote source. By default, Windows can download missing or corrupt features from Windows Update. The path to a Windows image that contains the desired features can also be specified on the command line. For example:

 

PS> Install-WindowsFeature –FeatureName Server-Gui-Shell –Source wim:x:\sources\install.wim:4

 

(x:\sources\install.wim is the path to the install.wim file on a retail Windows Server DVD-ROM or mounted ISO)