I’ve talked in the past about the new Features on Demand option in Windows 8 and Windows Server 2012. However, let’s say you build out an image, remove some roles and features and then patch the overall install. If you attempt to add back in roles and features previously removed, the operation will fail because it needs updated source files (RTM+patch level) to complete this operation.
My colleague Ben Herila from the Server Core team has some information about this on their team blog: http://blogs.technet.com/b/server_core/archive/2012/11/05/using-features-on-demand-with-updated-systems-and-patched-images.aspx
This post is to show you how you can update a recovery source to match that of your environment so it can successfully be used later to install roles and features. For the purposes of this discussion, I’ll use KB2756872 (http://support.microsoft.com/kb/2756872) as most people received this package during the initial Windows 8 release.
First, you want to download the contents of the needed updated from the Microsoft Update Catalog (http://catalog.update.microsoft.com/v7/site/Home.aspx). In this case, you’d just type in the KB number and get the following results:
Choose the appropriate downloads needed for your environment to a local computer, in this case we’ll use the 2012 update. When the updates are downloaded, they will look like this in explorer. These are the files we’ll need to use to update the source
Once you have the files downloaded, mount an install.wim for the operating system you need to update as a source. On a Windows 8 or Windows Server 2012 machine, this can all be done from an elevated command prompt using the IMAGEX commands. In the commands below, we’ll walk through the steps to mounting the install.wim to a temporary location and updating it to be a new source directory.
Copy install.wim from DVD to a temp directory
copy d:\sources\install.wim z:\install.wim
Make a mount directory for the install.wim
Remove the Read-Only attribute from the copied file so we can modify its contents
attrib.exe -r z:\install.wim
Get index information from the WIM file so we can verify the proper source index we wish to modify
dism.exe /get-wiminfo /wimfile:z:\install.wim
Mount the ‘2’ index of install.wim to our mount location
dism.exe /mount-wim /WimFile:z:\install.wim /index:2 /mountDir:c:\mountdir
I highlighted the image index above because you’ll want to ensure you’re updating the proper index when performing these operations. The Server WIM contains 4 indexes (typically) and indexes 2 and 4 contain the full operating system binaries where indexes 1 and 3 contain only the Server Core binaries. We’ll also need to make sure we know which index we updated so we can later use it for adding the roles and features back to the OS.
With the WIM mounted, you’ll need to use DISM to add the package to the index you’d previously mounted. The command for this if you’d downloaded the files above to your C:\ folder would be:
dism.exe “/Image:c:\mountdir” /Add-Package “/PackagePath:C:\2756872\Update for Windows Server 2012 (KB2756872)”
NOTE: We use the source folder for this command and not an individual MSU inside the folder
Once this step is completed, commit the changes you’ve made to the WIM and unmount it:
dism.exe /Unmount-Wim /MountDir:c:\mountdir /commit
Now you have a new source directory that can be used to add roles and features back to your patched images. So, if you were on Server Core and wanted to add back the shell components using your updated index 2 source, the command would be:
Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell –Source:wim:z:\install.wim:2
Organizations will need to determine how often they need to update their source recovery media. Any time an update is released, the source is potentially invalid for reinstallation or repair operations.
Hope that helps.