Reduce Server image size

A useful feature of Server 2012 R2, to reduce the size of an image (such as a template), is to compress the manifest files and inactive payloads, i.e. uninstallation data for updates. Reducing the size of an image can be useful, especially on Server Core, where Disk Cleanup isn’t readily available, as this reduces the time needed to deploy a VM. Having tested this recently, the image size was reduced by 10 %. Be warned that this command can take several hours to run.

dism /Online /Cleanup-Image /StartComponentCleanup

If you would like to go further, the binaries for disabled features can be removed completely, but this removes both the features and any associated updates, which means that installing the features again will necessitate access to the installation media and the relevant updates.

Get-WindowsFeature | ? { $_.InstallState -eq Available } | Uninstall-WindowsFeature -Remove

Source: TechNet.

Leave a Reply

Your email address will not be published. Required fields are marked *