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

Adding a Comment to a GPO with PowerShell

As I'm writing this article, I'm also writing a customization for a PowerShell course I'm teaching next week in Phoenix.  This customization deals with Group Policy and PowerShell.  For those of you who attend my classes may already know this, but I sit their and try to ask the questions to myself that others may ask as I present the material.  I finished up my customization a few hours ago and then I realized that I did not add in how to put a comment on a GPO.  This is a feature that many Group Policy Administrators may not be aware of. This past summer I attended a presentation at TechEd on Group Policy.  One organization in the crowd had over 5,000 Group Policies.  In an environment like that, the comment section can be priceless.  I always like to write in the comment section why I created the policy so I know its purpose next week after I've completed 50 other tasks and can't remember what I did 5 minutes ago. In the Group Policy module for PowerShell V3, th

Return duplicate values from a collection with PowerShell

If you have a collection of objects and you want to remove any duplicate items, it is fairly simple. # Create a collection with duplicate values $Set1 = 1 , 1 , 2 , 2 , 3 , 4 , 5 , 6 , 7 , 1 , 2   # Remove the duplicate values. $Set1 | Select-Object -Unique 1 2 3 4 5 6 7 What if you want only the duplicate values and nothing else? # Create a collection with duplicate values $Set1 = 1 , 1 , 2 , 2 , 3 , 4 , 5 , 6 , 7 , 1 , 2   #Create a second collection with duplicate values removed. $Set2 = $Set1 | Select-Object -Unique   # Return only the duplicate values. ( Compare-Object -ReferenceObject $Set2 -DifferenceObject $Set1 ) . InputObject | Select-Object – Unique 1 2 This works with objects as well as numbers.  The first command creates a collection with 2 duplicates of both 1 and 2.   The second command creates another collection with the duplicates filtered out.  The Compare-Object cmdlet will first find items that are diffe

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.