Skip to main content

How to Combine WIM images

One of the neat features of Microsoft WIM format is Single Instancing and the ability to hold more than 1 image in a single WIM file.  In Single Instancing, you only need to have one copy of a file for multiple images.  Let’s say I have 3 Windows 7 images.  Each one has 3 different configurations.  They all have windows in common.  Why keep a single copy of Notepad.exe?  The first image will contain every file that it needs.  Each additional image will contain a reference to identical files in the first image. Anything the previous images do not have will be contained in the image.  This will greatly reduce your image storage requirements.

This blog article looks at combining two separate images into one.  For this example, I have two images.  One called Lab1.wim, which is my base image for a Windows Server 2008 R2. The second is the setup for course 10215 called Lab1-10215.wim.  The base image is 2.90 GB and the class setup is 64.6 GB.  OK, we will not see much of a space savings here but you will get the idea.

We are going to apply the smaller image to the larger one to save some time.
To do this we need to mount one of the images.  First create an empty folder to mount the image in.  For my example, I am going to use a folder called MountedWim on the M: drive.

Open a command prompt with administrative rights.

We will mount the image using Deployment Image Servicing and Management command line tool.
DISM /mount-wim /wimfile:M:\lab1.wim /name:”Basic Image” /mountre:M:\Mount


Now that we have mounted the image, we can append it to the larger image. I copied the ImageX program from the Windows Automated Installation Kit to my M: drive.  If you have images to work with, you more than like already have a copy of ImageX.

Imagex /append m:\Mount m:\Lab1-10215.wim “Lab1 Images”


The imaging process will begin.
image
Once the process is completed, type ImageX /info Image_file_name. You will see the XML file for the WIM file.  It now will show two image indexes (In green below)

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.

WIM Information:
----------------
GUID:        {52583ec7-4f82-4810-84a6-c91532d045a9}
Image Count: 2
Compression: LZX
Part Number: 1/1
Attributes:  0x8
             Relative path junction

Available Image Choices:
------------------------
<WIM>
  <TOTALBYTES>69394622319</TOTALBYTES>
  <IMAGE INDEX="1">
    <NAME>10215 Setup</NAME>
    <WINDOWS>
      <ARCH>9</ARCH>
      <PRODUCTNAME>Microsoft« Windows« Operating System</PRODUCTNAME>
      <HAL>acpiapic</HAL>
      <PRODUCTTYPE>ServerNT</PRODUCTTYPE>
      <PRODUCTSUITE>Enterprise</PRODUCTSUITE>
      <LANGUAGES>
        <LANGUAGE>en-US</LANGUAGE>
        <DEFAULT>en-US</DEFAULT>
      </LANGUAGES>
      <VERSION>
        <MAJOR>6</MAJOR>
        <MINOR>1</MINOR>
        <BUILD>7600</BUILD>
        <SPBUILD>16385</SPBUILD>
      </VERSION>
      <SYSTEMROOT>WINDOWS</SYSTEMROOT>
    </WINDOWS>
    <DIRCOUNT>14732</DIRCOUNT>
    <FILECOUNT>65989</FILECOUNT>
    <TOTALBYTES>188740921939</TOTALBYTES>
    <CREATIONTIME>
      <HIGHPART>0x01CBABBE</HIGHPART>
      <LOWPART>0x26D4A429</LOWPART>
    </CREATIONTIME>
    <LASTMODIFICATIONTIME>
      <HIGHPART>0x01CBABBE</HIGHPART>
      <LOWPART>0x2709027F</LOWPART>
    </LASTMODIFICATIONTIME>
  </IMAGE>
  <IMAGE INDEX="2">
    <NAME>Lab1 Images</NAME>
    <WINDOWS>
      <ARCH>9</ARCH>
      <PRODUCTNAME>Microsoft« Windows« Operating System</PRODUCTNAME>
      <HAL>acpiapic</HAL>
      <PRODUCTTYPE>ServerNT</PRODUCTTYPE>
      <PRODUCTSUITE>Enterprise</PRODUCTSUITE>
      <LANGUAGES>
        <LANGUAGE>en-US</LANGUAGE>
        <DEFAULT>en-US</DEFAULT>
      </LANGUAGES>
      <VERSION>
        <MAJOR>6</MAJOR>
        <MINOR>1</MINOR>
        <BUILD>7600</BUILD>
        <SPBUILD>16385</SPBUILD>
      </VERSION>
      <SYSTEMROOT>WINDOWS</SYSTEMROOT>
    </WINDOWS>
    <DIRCOUNT>14472</DIRCOUNT>
    <FILECOUNT>64628</FILECOUNT>
    <TOTALBYTES>11788310784</TOTALBYTES>
    <CREATIONTIME>
      <HIGHPART>0x01CBAC92</HIGHPART>
      <LOWPART>0xB243BD59</LOWPART>
    </CREATIONTIME>
    <LASTMODIFICATIONTIME>
      <HIGHPART>0x01CBAC92</HIGHPART>
      <LOWPART>0xB366183B</LOWPART>
    </LASTMODIFICATIONTIME>
  </IMAGE>
</WIM>

Now, let’s look at the file sizes. The original WIM file sizes is 2.90 GB and 64.4 GB.  A file combination of those two files without Single Instancing is 67.3 GB.  The new, combined WIM file is 64.6 GB.  Only a .2 GB increase in files size.  Again, this is a very basic demo but it goes to show the hard drive savings that storing more than one image in the same WIM file can bring to your storage system.
Do not forget to unmount the wim file.

dism /unmount-wim /mountdir:m:\Mount /commit

Comments

Dustin said…
Your unmount command won't save the new WIM file with the changes. You need to use /commit instead of /discard.
Thanks Dustin. I made the correction.
Martin B said…
I don't think you need to commit as you are saving any changes to the lab1.wim.

Probably best to discard to make sure that it is unchanged.
Martin, Thank you. You are correct.
Taylor said…
- DISM /mount-wim /wimfile:M:\lab1.wim /name:”Basic Image” /mountre:M:\Mount
+ DISM /mount-wim /wimfile:M:\lab1.wim /name:”Basic Image” /mountdir:M:\Mount
Taylor said…
- DISM /mount-wim /wimfile:M:\lab1.wim /name:”Basic Image” /mountre:M:\Mount
+ DISM /mount-wim /wimfile:M:\lab1.wim /name:”Basic Image” /mountdir:M:\Mount

Popular posts from this blog

How to list all the AD LDS instances on a server

AD LDS allows you to provide directory services to applications that are free of the confines of Active Directory.  To list all the AD LDS instances on a server, follow this procedure: Log into the server in question Open a command prompt. Type dsdbutil and press Enter Type List Instances and press Enter . You will receive a list of the instance name, both the LDAP and SSL port numbers, the location of the database, and its status.

How to run GPResult on a remote client with PowerShell

In the past, to run the GPResult command, you would need to either physically visit this client, have the user do it, or use and RDP connection.  In all cases, this will disrupt the user.  First, you need PowerShell remoting enabled on the target machine.  You can do this via Group Policy . Open PowerShell and type this command. Invoke-Command –ScriptBlock {GPResult /r} –ComputerName <ComputerName> Replace <ComputerName> with the name of the target.  Remember, the target needs to be online and accessible to you.

Error icon when creating a GPO Preference drive map

You may not have an error at all.  Take a look at the drive mapping below. The red triangle is what threw us off.  It is not an error.  It is simply a color representation of the Replace option of the Action field in the properties of the drive mappings. Create action This give you a green triangle. The Create action creates a new mapped drive for users. Replace Action The Replace action gives you a red triangle.  This action will delete and recreate mapped drives for users. The net result of the Replace action is to overwrite all existing settings associated with the mapped drive. If the drive mapping does not exist, then the Replace action creates a new drive mapping. Update Action The Update action will have a yellow triangle. Update will modify settings of an existing mapped drive for users. This action differs from Replace in that it only updates settings defined within the preference item. All other settings remain as configured on the mapped drive. If the