Reaper's Edge‎ > ‎

WIM files - Why you should use them for more than just Windows 7

posted Sep 26, 2010, 1:06 PM by Michael Wilson   [ updated Sep 26, 2010, 1:44 PM ]
WIM files came out along with the Windows AIK as part of the release of Windows Vista. That said I've used them with Windows XP as well and they work great, provided you can deal with their one... hinderance.

WIM files do a lot of things well. They're fast, they compress extremely well, you can have multiple images in one file with only small increases in file size, and they can be easily worked on offline. The one pseudo downside to them is that they only capture one partition at a time, so if you want to image a system with more than one partition, you're going to have to do some extra work.

First, lets talk about their compression. It's amazing. WIM files make use of single-instancing and can pack a large system install into a small file. Furthermore, they only grow slightly when additional images are added, because they only save the differences between the images. Let me give you an example. When I first started using WIMs for Windows XP my unsealed image took up 5.2GB of disk space. When I added a sealed image to the same file it grew to 5.25GB. Realizing I made a mistake I reloaded the unsealed image, tweaked it, and added a new unsealed image to the WIM. By the time I was done all done I had a WIM file of 5.8GB containing 9 different images. Cool huh.

Now for the catch, you knew there'd be one. The file doesn't just grow with added images, but deleted ones as well. When I was all done I used Gimagex to delete some of the bad images I'd made along the way. After reducing the number of images from 9 to 2 my WIM file had gone from 5.8 to 6.1 GB. Apparently it doesn't understand the concept of deletion and simply keeps adding changes, even if the changes are deletions. Now the good news, there's a simple workaround. Create a new text document and rename it Image.wim. Then, using Gimagex, export the image files you want out of the large WIM file and in to the new empty one. When I did that the image size of the new WIM file was back down to 5.2GB. The easiest way to think of it is as having a rough draft WIM (with a bunch of comments and edits) and a final draft WIM.

The next thing to look at is offline servicing. For that you first need to decide what you want to do. If it's something simple like adding or deleting a file from the image, then just mount it using gimagex, make the change, and unmount it saving changes. But what if you want to do something more complicated, like adding drivers. You do add new drivers to your images to keep them ready for new hardware, right?

For that there are two resources I highly recommend you look at:
Getting drivers from the Widnows Update Catalog: http://support.microsoft.com/kb/323166

Now I know what you're thinking. He didn't just say we should rely on Windows Update for drivers, did he? No, I didn't. Think of the second link as a last resort destination. Whenever possible get drivers from the manufacturer, but sometimes they don't put them out in a form you can use. An example of this would be a graphics driver that only assembles itself after an exe is run on the system with that particular hardware. In those cases the Windows Update Catalog can provide you with functional drivers to get, atleast until the PC is finished installing an image.

If you don't feel much like reading their documentation let me give you the command line highlights for adding drivers:
Find the name of the image within the WIM:
    Dism /Get-WimInfo /WimFile:C:\test\images\install.wim
Mount the image:
    Dism /Mount-Wim /WimFile:C:\test\images\install.wim /Name:"Windows 7 HomeBasic" /MountDir:C:\test\offline
Add a single driver:
    Dism /Image:C:\test\offline /Add-Driver /Driver:C:\drivers\mydriver.INF
The big one, add all the drivers from a folder and it's subfolders:
    Dism /Image:C:\test\offline /Add-Driver /Driver:c:\drivers /Recurse
Make Windows add an unsigned driver:
    Dism /Image:C:\test\offline /Add-Driver /Driver:C:\drivers\mydriver.INF /ForceUnsigned
Save changes to the Image:
    Dism /Unmount-Wim /MountDir:C:\test\offline /Commit

Keep in mind that those commands add drivers to only one image from a WIM file. If you want to add drivers to multiple images within a single WIM file you have to do them each one at a time.

One more little thing about WIM files. Do you hate backing up all your data? Keep in mind that adding new images of a system to an exitsting WIM file only makes it grow a little bit. It almost reminds me of incremental backups. Of course, WIM files are easy to open and pull files out of onsie twosie. But you'd never need to do that, right? Enjoy.
Comments