In “Creating Bootable VHDs with Disk2VHD” (InstantDoc ID 125422), I talked about how to boot a system from a VHD file and mentioned that you need some kind of tool to create an image from which you can make that VHD. I gave you an overview of Sysinternals' Disk2VHD tool and suggested that other tools were available, as well. This month, let's take a look at a personal favorite: ImageX.
Since the mid-1990s, IT pros needing to perform quick OS installs/reinstalls have relied on disk imaging, which lets you configure a "reference" Windows system just the way we want it, then preserve all of that hard disk's files, folders, and metadata into one large file: the disk image file. You can then use a tool to quickly copy that image onto the troubled PC and restore it to service. The premier tool in that arena has been Symantec’s popular Ghost. A few years ago, however, Microsoft began giving away a command-line replacement for Ghost called ImageX, which is part of Microsoft's Windows Automated Installation Kit (WAIK).
Suppose you've spent a week or two creating the perfect Windows 7 system, including service packs, hotfixes, applications, and application settings, and you want to make dozens, hundreds, or thousands of PCs run just like that system. First, you've got to generalize that system with Sysprep, as I discussed in “Get Ready for Imaging with Sysprep” (InstantDoc ID 125532). After that, your reference system's hard disk is almost ready to be imaged. Most imaging tools can’t image an OS while that OS is running, so you'll need to boot the reference system from some other OS before you can fire up ImageX. Now, you could do that by putting a second copy of Windows on the reference image and booting from that, but that's sort of cumbersome. Microsoft's answer is the simple, streamlined Windows Pre-installation Environment (WinPE). You get WinPE in the WAIK, so your next task is to set up a bootable copy of WinPE on either a CD or USB stick. For detailed instructions, see the Microsoft article "Walkthrough: Create a Custom Windows PE Image" (technet.microsoft.com/en-us/library/dd744533%28WS.10%29.aspx).
Once booted to WinPE, you'll need access to the imagex.exe program file because the base WinPE image doesn't include imagex.exe. Probably the easiest way to get imagex.exe onto your WinPE system is to grab it from a WAIK-enabled system, then copy it to X:\Windows on your WinPE system. (WinPE doesn't store any changes from boot to boot, so you'll need to re-copy that imagex.exe file to X:\Windows every time you need to do some imaging.)
Because disk image files are pretty big, you'll also need a place to copy the imaged hard disk to, although if you have a lot of free space on your C drive, ImageX—unlike most disk-imaging tools I've worked with—will let you image the C drive onto itself. For the purpose of this article, let's assume that I've booted into WinPE on my reference system and then either mapped to a network share or connected an external USB drive to my reference system and called that drive G.
You'll find when you boot your system under WinPE that you're running from drive X. Your goal is to capture an image of drive C from the reference system onto G, resulting in a file on G that you can deploy to other systems. Now, when booted from WinPE, your system might rearrange its drive letters, so what was drive C on your reference system when it was booted in Windows 7 might have changed under WinPE. So, take a moment to ascertain which drive letter you want to image. (I'll assume that it's drive C for this example.)
Now you're ready to capture a disk image. The basic ImageX command to create a new image is
imagex /capture <sourcedrive> <targetdrive:\filename>.wim "<description>"
For example, to capture the C drive onto G, creating a file named baseimage.wim, you’d type
imagex /capture c: g:\baseimage.wim "Base Win 7 image for our organization"
The result will be a file named G:\baseimage.wim. The file will be big but not as large as your initial C drive—for a couple reasons. First, ImageX doesn't bother copying your page file, which as you know can be quite large, and second, ImageX by default applies a little compression to the image. As you'll see next month, you can control the level of ImageX's compression and a whole lot more with ImageX's many options.