Now that your reference computer has been customized
and generalized, it is ready to be captured to an image. There are
numerous third-party utilities for capturing images and most use a
proprietary imaging format that each vendor claims is superior. However,
everyone can leverage ImageX, which is used here to capture a WIM file.
1. Windows PE
When powered on
normally, your reference computer proceeds to run Windows Welcome and
prompt for any needed information, so you must be careful to not start
the locally installed copy of Windows on the reference computer. To
capture the image, you will need to start the computer from an alternate
operating system with access to imaging tools, and most likely it will
need network access.
Windows PE is the Microsoft-supplied answer to this need .
You will need bootable Windows PE media and an imaging utility.
Microsoft supplies the tools necessary to build a customized Windows PE
environment. They are shipped as part of the Windows Automated
Installation Kit. If you have been following along, you should already
have installed the WAIK on your deployment server, which can now be used
to create a Windows PE boot image, and in turn, boot media.
2. Walkthrough: Creating Windows PE boot media
Before
completing the following walkthrough, ensure that you have successfully
installed the Windows Automated Installation Kit. To create a basic
Windows PE boot image, follow these steps:
Right-click
on the Windows PE Tools Command Prompt shortcut from its program folder
on the start menu and choose Run as administrator.
To
establish the file structure needed to customize a Windows PE image,
run the CopyPE script with two arguments: the first is the target
architecture (x86, ia64 or amd64), and the second is the target
directory where you will manage your image.
If you are working with multiple architectures, it is a good idea to
include it in your target folder name. However, this is a path that
needs to be typed for most commands so keep the path short to save some
typing. For the tasks documented in this section the following arguments
are used:
copype.cmd x86 c:\winpe_x86
If you are working
with a VMware virtual machine as a client system, you must add its
network driver to the image. Additionally, the same process (Steps 2 and
3) may be used to add any network driver if your physical machine is
not natively supported by Windows PE. To add the VMware network driver
to a Windows PE image, follow the steps below:
Mount the Windows PE image for read/write updates:
imagex /mountrw c:\winpe_x86\winpe.wim 1 c:\winpe_x86\mount
One way to obtain any of the VMware drivers is to start up a VMware session and choose the Install VMware Tools option.
Don't worry if you already have them installed — all this does is mount
a VMware Tools installation CD (which may automatically start the
installation wizard). In the virtual CD that appears in your session, go
to E:\Program Files\VMware\VMware Tools\Drivers\vmxnet\win2k\ and copy these files to your host system.
Copy D:\program files\VMware\VMware Tools\Drivers\vmxnet\
win2k\*.* \\server\drivers\network\vmware\
Install the driver using its INF file with the PeImg INF command:
peimg /inf=\\server\drivers\network\vmware\vmware-nic.inf c:\
winpe_x86\mount\windows
When done editing your image, be sure to commit the changes back to the mounted image by using the ImageX Unmount command:
Imagex /Unmount /Commit c:\winpe_x86\mount
With your WIM file ready
to go, the final step is to make a bootable disk image in the form of
an ISO file. Using a virtual machine, you may easily attach the virtual
machine to the ISO file, and it will be treated as a CD-ROM. If you are
using physical machines, you may either burn the ISO file to CD/DVD or
make a bootable USB flash drive (UFD). If you make a bootable CD or DVD,
make sure to burn the contents of the ISO file to CD or DVD and not the
actual file itself. Successfully booting to a UFD can depend highly
upon the UFD and the BIOS of the computer you are booting. To create the ISO, simply run the following two commands:
Copy
the updated Windows PE image over the existing boot.wim in the ISO
sources directory (answer yes if asked to confirm the overwriting of the
file):
copy c:\winpe_x86\winpe.wim c:\winpe_x86\iso\sources\boot.wim
Use the OSCDImg command line tool
to generate the ISO:
oscdimg -n -bc:\winpe_x86\etfsboot.com c:\winpe_x86\ISO c:\
winpe_x86\winpe_x86.iso
3. ImageX
After booting to
Windows PE, you will need an imaging utility to capture the local hard
drive to a file. Microsoft provides a utility for working with WIM
files, which includes capturing them. The utility is named ImageX and is
completely command line driven. You can customize the Windows PE disk
to include ImageX, but in most situations it is more flexible to place
the imaging utility on a network share. If new versions of ImageX are
released, you will be able to update the network share without having to
update all of your boot media. If you are using an imaging utility
other than ImageX, it will most likely function from a network share as
well. Windows PE also supports USB external drives if you prefer.
ImageX is provided as
part of the WAIK and may be copied from the deployment server to a
network share. In addition to capturing images, ImageX may also append
an image to an existing WIM file, export images to new WIM files, mount
images for viewing or editing, or split large WIM files into smaller,
manageable files.
Standard options
If you are saving to a
network location, the first thing you need to do is establish a network
connection by supplying the necessary credentials. The easiest way to do
this is with a simple NET USE command:
net use N: \\server\files /USER:mydomain\myname
The above will prompt
for a password. Once established, you may make use of the N drive or use
a UNC path. As long as you have taken this action and established
credentials for accessing the share you need not actually use the mapped
drive letter.
If you only plan to use
ImageX for capturing and applying images, the only options you need to
specify are /capture, a destination WIM filename, and a friendly name
for the captured image within the file (remember that WIM files may
contain multiple images!). If you plan to use Setup, which can also
apply images, you need to specify the edition of Vista you are capturing
with the / flags option. This is a relatively undocumented and annoying
feature. Be aware that the Microsoft Deployment Toolkit (MDT) and
Windows Deployment Services (WDS) both use Setup to apply your images,
so if you plan to use either of these tools as part of your deployment
process, be sure to specify a Windows edition. Because it doesn't hurt
to specify an edition when it's not needed, always specify an edition
with the /flags option when capturing an image. A common capture command
looks something like the following:
N:\imagex.exe /flags "Enterprise" /capture c: N:\images\vista_
custom.wim "Standard"
The preceding command
would capture the local C drive to a new file named vista_custom.wim.
This image would have the friendly name of Standard. If you wished to
capture the local C drive and add it to an existing WIM file, simply use
the /append option instead of /capture.
Compression
Another useful
option of ImageX is its compression settings. The WIM file format
supports three different compression types, all of which may be
performed with ImageX. The first compression type is actually no
compression at all. If space is of no concern, you may capture your
image using no compression, in which case each file of the image is
stored in its original format. This is configured by using the /compress
none option with ImageX.
If space is the
primary concern, the compression can be set to maximum, which uses LZX,
with the /compress maximum option. This type of compression is very
effective and can significantly reduce the size of the image. LZX
compression, however, is very resource intensive, requiring significant
CPU time to ensure that each file is compressed as much as possible.
The default behavior is to
use fast compression, which uses XPress compression. This option
provides a significant space savings over using no compression at all
and is faster than maximum compression. When comparing the space saving
of maximum compression to fast compress there is typically little to no
difference in file sizes. However, when trying to squeeze the last 100MB
of an image on a single DVD, fast compression may not be suitable. For
most scenarios, however, it is the compression type of choice. If no
compression type is specified or a /compress fast option is used, then
fast compression will be used.
Be careful when planning
which images to store in a single WIM file and also when appending an
image to a file for testing. ImageX has a /delete option which will
remove an image from an image file, but it only removes the file
metadata. File data and contents will not be removed from the WIM file.
If several images are sharing the same files, then there is little need
for concern because most of the files will still be used by other
images. If images for different operating systems are stored in the same
WIM file, there may be considerable wasted space after deleting an
image from a WIM file. To optimize the WIM file after deleting an image,
you may use the /export option to export the valid images into a new
WIM file, where only the necessary file data is stored.
|
|
4. Walkthrough: Capturing a WIM file with ImageX
To use Windows PE and ImageX to capture the reference computer to a WIM file on a network share, perform the following steps:
Create
two new groups on the deployment server or in the Active Directory
Domain Services (ADDS). Name the first group Image Readers and name the
second group Image Writers. Put any accounts that will be used to apply
images into the Image Readers group. Put any accounts that will be used
to capture or modify images into the Image Writers group.
Create a network imaging share if you don't have one already prepared to store images. For the following examples, a share named Images has been created for a new folder named w:\images.
Configure the share to allow the Image Readers group read permissions and the Image Writers group modify permissions.
Boot the reference computer to Windows PE.
Once
Windows PE successfully starts, map a drive to imaging share using the
following command as a guide. When prompted, provide credentials for an
account in the Image Writers group.
net use n: \\deploysvr\images
Capture
an image of the reference computer C drive with the following command.
If you are not using Enterprise Edition, change Enterprise to Business
or Ultimate. The following command should be entered on a single line, although it is wrapped here due to length:
n:\imagex.exe /flags "Enterprise" /capture c: n:\images\vista_
custom.wim "Base Image"
Wait.
It usually takes between 15 and 45 minutes to capture an image based on
the speed of the computer, network speed, and the size of the image to
be captured.