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
  • Is there a way to automate this, or at least to tell which patch you need to include reinstall a feature?

    At this point in the 2012 lifecycle it'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.

    You get to either maintain a source image with every patch that you've added to your servers, or you need to go hunting down the right patch when you want to install a feature.

    It seems like this makes features on demand rather unappealing as it now stands.

    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?

  • @Adam,

    Thanks for the comment.  I'll look into amending this post or writing something new that speaks to this.

  • @Adam;

    I added a small blurb at the end of this post to reflect that you'll need to update this anytime a new update is released to keep the source current.  There isnt an automated way to do this in product currently.

  • Joseph, great detail and process - thanks for sharing this as well as Ben!  

  • How would you update the bits that aren't part of the install.wim on the 2012 media, such as the install files for the .Net 3.5 feature?

  • You do this in the same way, just use the sxs path.

  • 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?

  • You would need to update the install.wim and then re-extract it I believe.  

  • 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.  The problem I'm finding is that you end up with packages in an "Install Pending" state and it creates problems for adding more packages.  Here are my steps in an attempt to create an updated local source for Windows Server 2012 Datacenter Core:

    Installed RTM of Windows Server 2012 Datacenter Core.

    Configured system enough to get on the network.

    sconfig, 6, all - to get a list of available patches.

    Downloaded the patches (33) from Windows Catalog: catalog.update.microsoft.com/.../home.aspx

    Installed the patches, rebooted.

    sconfig, 6, all - to get any additional patches

    Downloaded the patches (4) from Windows Catalog: catalog.update.microsoft.com/.../home.aspx  (what a pain...)

    These patches were downloaded to their own folders in path D:\Server2012Patches.

    Start with an elevated command prompt/PowerShell console.

    Mount the Server ISO and copy the \sources\install.wim to a folder (D:\InstallWIM)

    Remove the Read-Only attribute on the WIM file:

    attrib.exe -r D:\InstallWIM\install.wim

    View the images in the WIM:

    Dism /Get-WIMInfo /WimFile:C:\test\images\install.wim  (3 for DataCenter Core, 4 for GUI)

    Mount the WIM choosing the index 3 for Datacenter Core:

    md D:\InstallWIM\MountDir

    Dism.exe /Mount-WIM /WimFile:D:\InstallWIM\install.wim /Index:3 /MountDir:D:\InstallWIM\MountDir

    Add Patch Packages to the mounted WIM:

    Get-ChildItem -Path D:\Server2012Patches | % {Dism.exe /image:D:\InstallWIM\MountDir /Add-Package /PackagePath:D:\Server2012Patches\$_}

    (Or copy all the MSU files to a single folder

    Dism.exe /image:D:\InstallWIM\MountDir /Add-Package /PackagePath:D:\Server2012Patches)

    I had 4 packages fail:

    KB2772501 (it's an EXE... how do you apply that offline?)

    And the last 3:

    KB2822241

    KB2836988

    KB2845533

    They had the error:

    An error occurred applying the Unattend.xml file from the .msu package.

    For more information, review the log file.

    Error: 0x800f082f

    dism.log says:

    CBS    Exec: Cannot finalize session because an exclusive session is pending. [HRESULT = 0x800f082f - CBS_E_EXCLUSIVE_WOULD_MERGE]

    I went ahead and committed the WIM.

    Commit the changes to the WIM

    dism.exe /Unmount-Wim /MountDir:D:\InstallWIM\MountDir /commit

    I then remounted the install.wim and tried applying just one of the failed packages, but got the same error.

    I then listed the installed packages:

    DISM.exe /image:d:\installwim\mountdir /get-packages

    Most came back with "State: Installed", but a number are listed as "State: Install Pending" and one as "State: Staged" (KB2823233).

    I'm not running McAfee :-)  

    kc.mcafee.com/.../index

    And for good measure I uninstalled System Center Endpoint Protection.

    So, what the heck do we had to do to maintain an updated source??  Thanks!

  • The .exe'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).  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.  In other words, you'd need to boot it once to let it clear the pending cache.

  • Thank you for the reply. Guess I'm missing something.

    How do you boot an offline install.wim?

    I'm trying to maintain an updated local source WIM as you have walked us through in the blog posting. I'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.

    Example:

    Error: 0x800f082e

    Package D:\Server2012Patches\kb2822241.msu may have failed due to pending updates to servicing components in the image.

    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.

    Thanks again for your time.

  • After some trial and error, I was able to narrow down problems to 2 patches:

    KB2771431

    This one fails and states:

    Processing 1 of 1 - Package_for_KB2771431: The specified package cannot be added to an offline image.

    Add this package to a running operating system using the /Online option.

    Error: 0x800f082e

    and

    KB2821895

    Once that patch applied, all other adding of packages begin failing with "Cannot finalize session because an exclusive session is pending. [HRESULT = 0x800f082f.]"

    These were successful:

    kb2737084.msu

    kb2742614.msu

    kb2750149.msu

    kb2753842-v2.msu

    kb2756872.msu

    kb2757638.msu

    kb2758246-v2.msu

    kb2761094.msu

    kb2761465.msu

    kb2764870.msu

    kb2765809.msu

    kb2769034.msu

    kb2769165.msu

    kb2770917.msu

    kb2771744.msu

    kb2771753.msu

    kb2771821.msu

    kb2777166.msu

    kb2778171.msu

    kb2779768.msu

    kb2780342.msu

    kb2780523.msu

    kb2782419.msu

    kb2783251.msu

    kb2784160.msu

    kb2785094.msu

    kb2785220.msu

    kb2788350.msu

    kb2789649.msu

    kb2790920.msu

    kb2792009.msu

    kb2795944.msu

    kb2798162.msu

    kb2800033.msu

    kb2800088.msu

    kb2803676.msu

    kb2804583.msu

    kb2805222.msu

    kb2805227.msu

    kb2805966.msu

    kb2807986.msu

    kb2808679.msu

    kb2808735.msu

    kb2811660.msu

    kb2812829.msu

    kb2813430.msu

    kb2815769.msu

    kb2820330.msu

    kb2822241.msu

    kb2823233.msu

    kb2823516.msu

    kb2829173.msu

    kb2829254.msu

    kb2829361.msu

    kb2830290.msu

    kb2836988.msu

    kb2845533.msu

    kb2845690.msu

    kb2850674.msu

    kb2853915.msu

    kb2856758.msu

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

  • Thanks again.  It's sort of funny, in the service stack update of KB2821895, the first listed improvement is "Enables servicing stack updates to be installed offline."   So, I'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.  -Joe

  • Yes, its ironic :)

    We've been working hard to get more and more updates to be offline capable.