The Windows Servicing Guy

Tips and tricks from a Windows support engineer on issues related to servicing

How to update local source media to add roles and features

How to update local source media to add roles and features

  • Comments 24
  • Likes

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:

image

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

image 

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

mkdir c:\mountdir

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.

--Joseph

Comments
  • <p>Is there a way to automate this, or at least to tell which patch you need to include reinstall a feature?</p> <p>At this point in the 2012 lifecycle it&#39;s not too bad, but in a year or two, when there are a couple dozen patches, maybe a service pack, it seems like it would be a big pain in the neck.</p> <p>You get to either maintain a source image with every patch that you&#39;ve added to your servers, or you need to go hunting down the right patch when you want to install a feature.</p> <p>It seems like this makes features on demand rather unappealing as it now stands.</p> <p>Also, if you put the SxS folder in a network share for this same purpose, is there a way to achieve the same thing, or can this only be done on a WIM?</p>

  • <p>@Adam, </p> <p>Thanks for the comment. &nbsp;I&#39;ll look into amending this post or writing something new that speaks to this.</p>

  • <p>@Adam;</p> <p>I added a small blurb at the end of this post to reflect that you&#39;ll need to update this anytime a new update is released to keep the source current. &nbsp;There isnt an automated way to do this in product currently.</p>

  • <p>Joseph, great detail and process - thanks for sharing this as well as Ben! &nbsp;</p>

  • <p>How would you update the bits that aren&#39;t part of the install.wim on the 2012 media, such as the install files for the .Net 3.5 feature?</p>

  • <p>You do this in the same way, just use the sxs path.</p>

  • <p>Also, if we have created a network based side-by-side store, with the winsxs source files extracted from the install.wim, is it possible to update the network sxs store directly, or is the only option going to be to update an install.wim and extract the updated contents of the winsxs directory from the wim each time?</p>

  • <p>You would need to update the install.wim and then re-extract it I believe. &nbsp;</p>

  • <p>Thank you for this post, though while it has been greatly helpful to understanding what is needed to maintain an updated local source, it has also led to great frustration. &nbsp;The problem I&#39;m finding is that you end up with packages in an &quot;Install Pending&quot; state and it creates problems for adding more packages. &nbsp;Here are my steps in an attempt to create an updated local source for Windows Server 2012 Datacenter Core:</p> <p>Installed RTM of Windows Server 2012 Datacenter Core.</p> <p>Configured system enough to get on the network.</p> <p>sconfig, 6, all - to get a list of available patches.</p> <p>Downloaded the patches (33) from Windows Catalog: <a rel="nofollow" target="_new" href="http://catalog.update.microsoft.com/v7/site/home.aspx">catalog.update.microsoft.com/.../home.aspx</a></p> <p>Installed the patches, rebooted.</p> <p>sconfig, 6, all - to get any additional patches</p> <p>Downloaded the patches (4) from Windows Catalog: <a rel="nofollow" target="_new" href="http://catalog.update.microsoft.com/v7/site/home.aspx">catalog.update.microsoft.com/.../home.aspx</a> &nbsp;(what a pain...)</p> <p>These patches were downloaded to their own folders in path D:\Server2012Patches.</p> <p>Start with an elevated command prompt/PowerShell console.</p> <p>Mount the Server ISO and copy the \sources\install.wim to a folder (D:\InstallWIM)</p> <p>Remove the Read-Only attribute on the WIM file:</p> <p>attrib.exe -r D:\InstallWIM\install.wim</p> <p>View the images in the WIM:</p> <p>Dism /Get-WIMInfo /WimFile:C:\test\images\install.wim &nbsp;(3 for DataCenter Core, 4 for GUI)</p> <p>Mount the WIM choosing the index 3 for Datacenter Core:</p> <p>md D:\InstallWIM\MountDir</p> <p>Dism.exe /Mount-WIM /WimFile:D:\InstallWIM\install.wim /Index:3 /MountDir:D:\InstallWIM\MountDir</p> <p>Add Patch Packages to the mounted WIM:</p> <p>Get-ChildItem -Path D:\Server2012Patches | % {Dism.exe /image:D:\InstallWIM\MountDir /Add-Package /PackagePath:D:\Server2012Patches\$_}</p> <p>(Or copy all the MSU files to a single folder</p> <p>Dism.exe /image:D:\InstallWIM\MountDir /Add-Package /PackagePath:D:\Server2012Patches)</p> <p>I had 4 packages fail:</p> <p>KB2772501 (it&#39;s an EXE... how do you apply that offline?)</p> <p>And the last 3:</p> <p>KB2822241</p> <p>KB2836988</p> <p>KB2845533</p> <p>They had the error: </p> <p>An error occurred applying the Unattend.xml file from the .msu package.</p> <p>For more information, review the log file.</p> <p> Error: 0x800f082f</p> <p>dism.log says:</p> <p>CBS &nbsp; &nbsp;Exec: Cannot finalize session because an exclusive session is pending. [HRESULT = 0x800f082f - CBS_E_EXCLUSIVE_WOULD_MERGE]</p> <p>I went ahead and committed the WIM.</p> <p>Commit the changes to the WIM</p> <p>dism.exe /Unmount-Wim /MountDir:D:\InstallWIM\MountDir /commit</p> <p>I then remounted the install.wim and tried applying just one of the failed packages, but got the same error.</p> <p>I then listed the installed packages:</p> <p>DISM.exe /image:d:\installwim\mountdir /get-packages</p> <p>Most came back with &quot;State: Installed&quot;, but a number are listed as &quot;State: Install Pending&quot; and one as &quot;State: Staged&quot; (KB2823233).</p> <p>I&#39;m not running McAfee :-) &nbsp; </p> <p><a rel="nofollow" target="_new" href="https://kc.mcafee.com/corporate/index?page=content&amp;id=KB76867&amp;actp=search&amp;viewlocale=en_US&amp;searchid=1357907921573">kc.mcafee.com/.../index</a></p> <p>And for good measure I uninstalled System Center Endpoint Protection.</p> <p>So, what the heck do we had to do to maintain an updated source?? &nbsp;Thanks!</p>

  • <p>The .exe&#39;s cant be applied offline, they would either need to be run or you could extract the executable to see if it was just a wrapper for an MSU (which you could apply). &nbsp;For the updates that pend a reboot, that installation source would need to satisfy those requirements first before any other updates could be added to the source directory. &nbsp;In other words, you&#39;d need to boot it once to let it clear the pending cache.</p>

  • <p>Thank you for the reply. Guess I&#39;m missing something. </p> <p>How do you boot an offline install.wim? </p> <p>I&#39;m trying to maintain an updated local source WIM as you have walked us through in the blog posting. I&#39;m finding that a number of patches will fail to be applied to the mounted WIM because there are pending updates in the offline install.wim.</p> <p>Example:</p> <p>Error: 0x800f082e</p> <p>Package D:\Server2012Patches\kb2822241.msu may have failed due to pending updates to servicing components in the image. </p> <p>My last attempt was to place all the patches for 2012 Datacenter Core in a single folder and have them applied to the install.wim in order of KB article - earliest first. 9 of 64 fail because of pending update.</p> <p>Thanks again for your time.</p>

  • <p>After some trial and error, I was able to narrow down problems to 2 patches:</p> <p>KB2771431</p> <p>This one fails and states:</p> <p>Processing 1 of 1 - Package_for_KB2771431: The specified package cannot be added to an offline image.</p> <p>Add this package to a running operating system using the /Online option.</p> <p> Error: 0x800f082e</p> <p>and </p> <p>KB2821895</p> <p>Once that patch applied, all other adding of packages begin failing with &quot;Cannot finalize session because an exclusive session is pending. [HRESULT = 0x800f082f.]&quot;</p> <p>These were successful:</p> <p>kb2737084.msu</p> <p>kb2742614.msu</p> <p>kb2750149.msu</p> <p>kb2753842-v2.msu</p> <p>kb2756872.msu</p> <p>kb2757638.msu</p> <p>kb2758246-v2.msu</p> <p>kb2761094.msu</p> <p>kb2761465.msu</p> <p>kb2764870.msu</p> <p>kb2765809.msu</p> <p>kb2769034.msu</p> <p>kb2769165.msu</p> <p>kb2770917.msu</p> <p>kb2771744.msu</p> <p>kb2771753.msu</p> <p>kb2771821.msu</p> <p>kb2777166.msu</p> <p>kb2778171.msu</p> <p>kb2779768.msu</p> <p>kb2780342.msu</p> <p>kb2780523.msu</p> <p>kb2782419.msu</p> <p>kb2783251.msu</p> <p>kb2784160.msu</p> <p>kb2785094.msu</p> <p>kb2785220.msu</p> <p>kb2788350.msu</p> <p>kb2789649.msu</p> <p>kb2790920.msu</p> <p>kb2792009.msu</p> <p>kb2795944.msu</p> <p>kb2798162.msu</p> <p>kb2800033.msu</p> <p>kb2800088.msu</p> <p>kb2803676.msu</p> <p>kb2804583.msu</p> <p>kb2805222.msu</p> <p>kb2805227.msu</p> <p>kb2805966.msu</p> <p>kb2807986.msu</p> <p>kb2808679.msu</p> <p>kb2808735.msu</p> <p>kb2811660.msu</p> <p>kb2812829.msu</p> <p>kb2813430.msu</p> <p>kb2815769.msu</p> <p>kb2820330.msu</p> <p>kb2822241.msu</p> <p>kb2823233.msu</p> <p>kb2823516.msu</p> <p>kb2829173.msu</p> <p>kb2829254.msu</p> <p>kb2829361.msu</p> <p>kb2830290.msu</p> <p>kb2836988.msu</p> <p>kb2845533.msu</p> <p>kb2845690.msu</p> <p>kb2850674.msu</p> <p>kb2853915.msu</p> <p>kb2856758.msu</p>

  • <p>Both of the remaining updates are servicing stack updates which have to be applied while the system is online. &nbsp;You&#39;d need to boot the install.wim to actually apply those because they cant be done offline. &nbsp;That being said, I don&#39;t know that you&#39;d need them for a repair/installation source so you should be fine with the WIM you have now.</p>

  • <p>Thanks again. &nbsp;It&#39;s sort of funny, in the service stack update of KB2821895, the first listed improvement is &quot;Enables servicing stack updates to be installed offline.&quot; &nbsp; So, I&#39;m wondering if I might find it easier to maintain an online system fully patched and just image it to a WIM (mostly a once a month process) and use that image as the source going forward when adding features/roles. I really appreciate your thoughts and time. &nbsp;-Joe</p>

  • <p>Yes, its ironic :)</p> <p>We&#39;ve been working hard to get more and more updates to be offline capable. </p>