Deploying WIM files is different than deploying
binary-based images used by some other vendors. Binary images contain
drive and partition information, which is needed to successfully start
an operating system. WIM files are file-based images and do not include
partition information. The file-based nature of the WIM files allows it
to be applied in a nondestructive manner. For example, you may re-image a
problematic machine without deleting the locally stored data. However,
it is not a very practical solution because with the registry as part of
the image, it will be necessary to reinstall any applications. That
said, the lack of partition information in the image does mean that it
is necessary to properly prepare the hard drive before applying the
image.
1. Preparing the hard disk
Although any
drive partitioning and formatting software may be used, DiskPart is
included with Windows and is included with Windows PE by default.
DiskPart is an interactive command line utility which can perform even
more tasks than the graphical Disk Administrator. For the purposes of
imaging, it can be used to create partitions, make partitions active,
and format partitions.
DiskPart is a very
powerful utility. Its most significant power comes from its ability to
run its commands from an input file and thus be run from a script. The
process of automating DiskPart begins with first creating a text file
with all necessary DiskPart commands and secondly running DiskPart with
the /s option to specify the text file (referred to as a DiskPart script
file). In the following walkthrough, you will create and store the
script file on the network share, along with the customized WIM file.
The advantage is that any necessary modifications can be made in a
single location, which makes this a much more manageable solution.
To properly prepare a disk to receive an image, you must perform the following tasks within DiskPart:
Select disk 0
The first step is
to select the disk you wish to operate against. Disks begin numbering
with 0, which would be the most common option. If necessary, you may use
list disk to show the available drives for selection (if your system
has a hidden OEM image partition you may find it listed as disk 0).
Clean
An optional step is to clear any existing partitions from the drive. This is a destructive option and should be used with care.
Create partition primary [size=XXXX]
If the drive has been
cleaned or is new, a partition must be created. This command will create
a primary partition which will extend to the full size of the drive.
The size in megabytes of the partition may be specified by using the
size option.
Active
This will simply
mark the newly created partition as active. This is required if you wish
to boot an operating system from this partition.
Format fs=ntfs
The format
command in DiskPart will format the partition with the specified file
system. This task may also be performed with the standalone format
command.
Exit
Exit the user interface and close the DiskPart utility.
2. Walkthrough: Preparing a hard disk for an image
To use DiskPart to prepare a target computer's disk for imaging, follow these steps:
From your deployment server, open Notepad and enter the following text in a new document:
select disk 0
clean
create partition primary
active
format fs=ntfs
exit
Save the document on your images share (i.e. w:\images) as single_partition.txt.
Boot the target computer to Windows PE.
Once
Windows PE successfully starts, map a network drive using the following
command as a guide. When prompted for credentials, supply a user name
and password with read permissions to the share.
net use y: \\deploysvr\images
Execute the following command on the target computer to prepare the local disk.
diskpart /s y:\single_partition.txt
3. Applying the image
Once the disk of your
target computer has been properly prepared, there are two methods to
apply the image. One is to use the ImageX command line utility with the
/apply option. The other is to use setup.exe
from the Vista DVD. Both methods imply that the computer has been
booted to an operating system which supports them, typically Windows PE.
Deploying with ImageX
ImageX provides a
very efficient and simple method to apply images to a prepared disk. As a
command line utility, ImageX may be scripted to perform a customized
installation and provides the most flexibility and efficiency. The most
significant downside to using ImageX is that it does not provide a
method to perform in-place upgrades. However, when combined with other
tools, such as Windows Easy Transfer or User State Migration Tool, user
data and accounts can be maintained during the imaging process.
To apply an image with ImageX, simply specify the /apply option. The first parameter after the /apply
option is the name of the WIM file which contains the image you want to
apply. The second parameter is the image number or name. Keep in mind
that a single WIM file may contain multiple images, so it's necessary to
specify the image to be applied. If you chose to use image numbers, the
image numbers begin with 1. Lastly, specify the location to apply the
image. Typically, this would simply be a drive letter, but in some
circumstances you may want to apply an image to a subfolder. For an
example, see the section "Walkthrough: Applying an image with ImageX."
NOTE
If you don't know
(or just can't remember!) which images are stored within a WIM file, the
/info option of ImageX will list the images in a WIM file. Not only
does it list the image names, but also their indexed numbers within the
WIM file along with other information about the WIM file.
Deploying with Setup
Setup, the replacement for winnt.exe and winnt32.exe,
may also be used to deploy images. Setup only accepts a few options as
parameters. The one needed for the automated deployment process is the
/unattend option, which allows an unattended answer file be specified.
The unattend answer file specifies the image to use and the target drive
to prepare. Setup may be used to perform a clean installation or an
upgrade.
4. Walkthrough: Applying an image with ImageX
To apply a customized WIM
file to a prepared hard drive with ImageX, complete the following step.
Be sure that you have booted to Windows PE, prepared the hard drive,
and mapped a network drive, as per the previous Walkthrough.
From the target computer, use ImageX with the /apply option, using the following command as a guide:
y:\imagex.exe /apply n:\images\vista_custom.wim 1 c:\
5. Automating the deployment
At this point you may be concerned about the amount of effort required to successfully deploy a captured image. You must:
Map a network drive, if applicable.
Partition and format the local drive if necessary.
Run ImageX with appropriate parameters.
If you only plan to deploy
one or two images per week, this may not seem like a significant amount
of work. If you plan to deploy hundreds or even thousands of
workstations, the process will need to be more automated. A simple
technique to automate the process is to use a batch file.