In the last post I covered DISM for the purpose of changing/upgrading the version of Windows, and we found that the DISM tool has existed since 2008, however in 2012R2 they added much improved, usable functionality. Did you know DISM is also responsible for things such as Windows updates?
Under the hood DISM is the tooling being used to install and maintain those wonderful Windows Updates you get every month on Patch Tuesday (is that still a thing?) Which also means we can use the toolset to also tidy up afterwards. Remember Disk Clean up (cleanmgr)? Well it’s a nicer CLI version of the Updates clean-up in there.
There are 3 levels of update clean up via DISM
- Component Clean up – this cleans up updated components i.e. removing the packages used to install the updates
- Reset Base – same as above, but means all deletes all superseded versions of every component in the component store, meaning you won’t be able to uninstall service packs/updates applied before this point in time
SPSuperseded – removes all backup components needed to uninstall the service pack, also you cannot remove the service pack anymore after using this command.
In short doing 2 and 3 will free up more space but makes rolling back very difficult, option 1 is a nice way to keep the system tidy:
Example on Windows Server 2012R2
Disk is at 37.1GB free after being fully updated and having key applications installed
Component cleanup is run and takes quite a while… (I had to go out and check 3 hours later, suspect it took ~1 hour)
Following the cleanup run we can see around 7GB has been freed up on the system
From this quick demonstration above it’s clear to see that significant disk space is used up by irrelevant, outdated files. The only reason to keep these is if you want to remove an update and reapply later, but surely not all 7GB worth…
I’ve started using the dism cleanup commands during my build process, so that before I start using a server in anger, I get it to as clean a state as possible, fully updated but tidy!
The full commands for DISM cleanup are:
- dism /online /Cleanup-Image /StartComponentCleanup
- dism /online /Cleanup-Image /StartComponentCleanup /ResetBase
- dism /online /Cleanup-Image /SPSuperseded