Installation of Windows changed quite a bit
with Windows Vista, and Microsoft improved this imaging technology with
Windows 7. Previously, you installed the operating system by copying
individual files, often from the i386 folder of the installation disc.
However, now the installation disc includes images in the form of a
single file that you'll use for the installation of Windows 7.
Additionally, you can modify any installation of
Windows 7 and create your own image. You can then use tools to deploy
the images that you create.
1. Image Types: VHD and WIM
There are two overall types of images within Windows 7: virtual hard drive (VHD) images have a filename extension of .vhd, and Windows Imaging Format (WIM) images have an extension of .wim. You can boot to both VHD and WIM images.
A VHD image is a Windows 7 operating system with
applications. You can create a VHD image when you begin an installation
of Windows 7, install Windows 7 on the VHD, and then boot into VHD.
Once the VHD is started, it works just like a normal installation. Only the Windows 7
Enterprise and Ultimate editions support booting from VHDs. Although
most features are available in a VHD image of Windows 7, there are some
limitations. For example, a VHD image doesn't support BitLocker or
dynamic disks.
The WIM images have two types: Windows
preinstallation images (also called boot images) and operating system
images (which include the full installation of Windows 7).
Preinstallation Images
A preinstallation image boots into WinPE. This
is a minimal Windows environment with limited services running. The
installation DVD includes the boot.wim file that boots into WinPE.You can also create a Windows Recovery Environment (WinRE)
bootable disc that extends the WinPE.
Operating System Images
You can have either thin or thick operating system images. A thin image has only the operating system installed. The install.wim
file on the installation DVD includes thin images of various editions
of Windows 7. A thick image is a fully configured installation and has
applications installed.
2. Creating a Bootable VHD Image
A VHD image is simply a VHD file that includes a
fully functioning operating system. This is the same VHD image type
used by Microsoft Virtual PC and Microsoft's Hyper-V virtual program
(which is available on Server 2008 and Server 2008 R2). Windows 7 can
also boot directly into a VHD file or use a VHD file as a dual-boot
system. Because the VHD image is a single file, you can easily back up
the entire operating system environment by copying the file. This
approach has several benefits; you can:
Test application compatibility.
You can install applications on the VHD image
and test them for compatibility. If the application corrupts the
operating system, you can simply shut it down, delete the corrupted VHD
image, and copy your original VHD image back.
Create an isolated development environment.
Application developers often need an isolated
environment to develop, test, and debug applications. Bugs can
sometimes affect the stability of the operating system. However, if an
errant application corrupts the operating system, it can easily be
restored by copying the original VHD image.
Test malware or other vulnerabilities.
Security professionals often need an isolated
environment to test the effect of malware. It's not a good idea to do
this in a live environment, but a system running on a virtual image can
be isolated for testing.
While bootable VHDs have a lot of benefits, there
are some limitations. First and foremost, you can create a bootable VHD
with only Windows 7 Enterprise and Ultimate editions. Other Windows 7
editions don't support it. Other limitations include the following:
BitLocker is not supported on Windows 7 VHD images. VHD images do not support hibernation. Bootable VHD images can't be compressed. The VHD can't be bigger than 2 TB. The VHD file must be located on an NTFS drive.
|
Follow these steps to create a bootable VHD image on
an existing installation of Windows.
Place
the installation DVD into the system and restart it. The system will
automatically load WinPE and you'll be presented with the first Windows
7 installation screen.
Press Shift+F10 to access the command prompt.
At the command prompt, enter DiskPart and press Enter. The DiskPart program will start and the prompt will change to DISKPART>.
Enter the following command to create a virtual disk file named MasterWin7.vhd:
Create vdisk file = c:\MasterWin7.vhd maximum=40960 type=expandable
The command creates a file about 2 MB in size, but
it is dynamically expandable to 40 GB (40,960 MB). You can adjust the
size based on your needs and available hard drive space. After the file
is created you'll see a message indicating that DiskPart successfully
created the virtual disk file. You can name the file something
different but you must include the .vhd extension.
You can't manipulate the file until you select it, so select the virtual disk (vdisk) file with the following command:
Select vdisk file=c:\MasterWin7.vhd
If desired, you can view the selected disk by issuing the List Vdisk command. However, since the disk is not attached, it can't determine the type of the disk and it will be listed as Unknown.
Attach the vdisk file with the following command:
Attach vdisk
You can now view details on the vdisk with the List Vdisk command and it will show the file as Expandable.
Enter List Disk
and press Enter. You'll see all your disks on the system. The 40 GB
disk is listed with an asterisk (*) indicating it's selected; it has a
status of Online, and it has 40 GB free.
Enter Exit to exit DiskPart.
Complete
the Windows 7 installation. When prompted to select a disk, select the
40 GB disk you created with DiskPart to install Windows 7 on the VHD
file. When you select the VHD disk file, the installation program
presents a message telling you that "Windows cannot install to this
disk." Don't believe it. It will.
Now you have a multiboot system. If desired, you can modify the boot configuration data (BCD) store to modify the boot options.
If you boot into Windows 7 normally, you'll see the file named MasterWin7.vhd
at the root of C. If you want to use this image for any type of
testing, first make a backup of this file. You can do so by simply
copying the file. If future actions corrupt the file, you can copy the
original back. Note that any data you store on this image will be lost
if you haven't backed up the data somewhere else.
It's often valuable to convert a full operating
installation into a VHD. Using the different VHD tools, you can easily
create snapshots and roll back all changes to an installation, but this
simply isn't possible with a regular installation.
For example, you may want to test the effect of an
upgrade on a live system. You can create the VHD, apply the upgrade,
and then perform testing. Once you've completed the testing, you can
undo the changes to the VHD file to return it to the pre-upgrade status.
Mark Russinovich and Bryce Cogswell have written
several utilities for Sysinternals, including one named Disk2vhd that
you can use to create a VHD version of a physical disk. In other words,
you can have a regular version of Windows 7 running and then use this
tool to create a VHD file. You can then use the VHD file with Windows
Virtual PC or Microsoft's Hyper-V virtual program.