Automating Windows 7 Installation
Images are an important topic to master when learning about Windows 7 deployment. All deployments of Windows 7 deploy images. The basic installation DVD includes images, and you can also use several tools to capture, manage, and deploy your own images in a production environment. Basic images include virtual hard drive (VHD) images, boot images, and install images. You can create a Windows 7 installation on a VHD image. Boot images boot into the Windows Preinstallation Environment (WinPE), and install images provide a fully functional installation of Windows 7.
This article shows you how to use the WinPE to create bootable media, add additional tools such as ImageX, and then capture an image. The Windows Automated Installation Kit (WAIK) provides you with several tools to capture, manage, and deploy images. You can use the Deployment Image Servicing and Management (DISM) tool to service these images offline by mounting the image and then adding drivers, packages, or features. The great strength of DISM is that you can service the image without deploying it to a computer. The WAIK also includes the Windows System Image Manager (WSIM), which you can use to create unattended answer files.
In this article, you will learn to:
- Create a dual boot system using a VHD
- Prepare a system to be imaged
- Capture an image
- Modify an image offline
- Apply an image
- Create an unattended answer file
Microsoft Images
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. While this article focuses on using stand-alone tools such as the WAIK to install images. You can capture an image using the WAIK, and then copy it to the WDS server to deploy it to multiple systems using multicasting. You can also capture images with WDS.
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. The section "Creating a Bootable VHD Image" later in this article shows you the process. 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. The section "Creating Bootable WinPE Media" later in this article shows you how to create your own customized 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.
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.
VHD Limitations
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.
Creating a Bootable WinPE Image
WinPE images are not intended to be a primary operating system. Instead, WinPE provides an interface for the user with enough access to the hardware to complete a full installation. You can boot to a WinPE image using a bootable CD, a USB flash drive, or a hard disk, or you can use a preboot execution environment (PXE) client to connect to a WDS server.
When you start the Windows 7 installation, Setup will load WinPE from the boot.wim file located in the \sources\ folder of the installation DVD. While the WinPE meets the needs of most users, you can customize it. For example, you can create your own bootable USB drive or CD and includes extra files like the ImageX utility to capture an image after booting to the WinRE.
Creating Operating System Images
Operating system images are also known as install images. They include a full operating system. A thin image (also called a basic image) is just the default operating system and nothing else. Thick images (also called custom images) include the operating system along with any customization and applications you may need.
A WIM file can hold multiple images. For example, install.wim on the installation DVD typically holds images for multiple editions of Windows 7. You can query the contents of an image file by issuing the following command at the WAIK Deployment Tools command prompt:
ImageX /info targetImageFile
The target is the location of the image file. For example, if your installation DVD is in the E: drive, the target location is e:\sources\install.wim and the command would look like this:
ImageX /info e:\sources\install.wim
Listing below shows a partial output from this query. We left all the details in for the first image (IMAGE INDEX="1") but included only the index number and name for the remaining four images.
Listing-ImageX information included on the install.wim file
ImageX Tool for Windows Copyright (C) Microsoft Corp. All rights reserved. Version: 6.1.7600.16385 WIM Information: ---------------- Path: e:\sources\install.wim GUID: {4db440bc-7222-4651-9192-1798c4b29bcb} Image Count: 5 Compression: LZX Part Number: 1/1 Attributes: 0xc Integrity info Relative path junction Available Image Choices: ------------------------ <WIM> <TOTALBYTES>2188572852</TOTALBYTES> <IMAGE INDEX="1"> <DIRCOUNT>9044</DIRCOUNT> <FILECOUNT>45608</FILECOUNT> <TOTALBYTES>7936340784</TOTALBYTES> <CREATIONTIME> <HIGHPART>0x01CA0443</HIGHPART> <LOWPART>0x6568BDF8</LOWPART> </CREATIONTIME> <LASTMODIFICATIONTIME> <HIGHPART>0x01CA045F</HIGHPART> <LOWPART>0x905A47C2</LOWPART> </LASTMODIFICATIONTIME> <WINDOWS> <ARCH>0</ARCH> <PRODUCTNAME>Microsoftr Windowsr Operating System</PRODUCTNAME> <EDITIONID>Starter</EDITIONID> <INSTALLATIONTYPE>Client</INSTALLATIONTYPE> <HAL>acpiapic</HAL> <PRODUCTTYPE>WinNT</PRODUCTTYPE> <PRODUCTSUITE>Terminal Server</PRODUCTSUITE> <LANGUAGES> <LANGUAGE>en-US</LANGUAGE> <DEFAULT>en-US</DEFAULT> </LANGUAGES> <VERSION> <MAJOR>6</MAJOR> <MINOR>1</MINOR> <BUILD>7600</BUILD> <SPBUILD>16385</SPBUILD> <SPLEVEL>0</SPLEVEL> </VERSION> <SYSTEMROOT>WINDOWS</SYSTEMROOT> </WINDOWS> <NAME>Windows 7 STARTER</NAME> <DESCRIPTION>Windows 7 STARTER</DESCRIPTION> <FLAGS>Starter</FLAGS> <HARDLINKBYTES>3070770507</HARDLINKBYTES> <DISPLAYNAME>Windows 7 Starter</DISPLAYNAME> <DISPLAYDESCRIPTION>Windows 7 Starter</DISPLAYDESCRIPTION> </IMAGE> <IMAGE INDEX="2"> ... <NAME>Windows 7 HOMEBASIC</NAME> ... </IMAGE> <IMAGE INDEX="3"> ... <NAME>Windows 7 HOMEPREMIUM</NAME> ... </IMAGE> <IMAGE INDEX="4"> ... <NAME>Windows 7 PROFESSIONAL</NAME> ... </IMAGE> <IMAGE INDEX="5"> ... <NAME>Windows 7 ULTIMATE</NAME> ... </IMAGE> </WIM>
When working with images using either ImageX or DISM, you'll frequently need to know either the index number or the name. The index number is much easier to enter, but you may want to use the name to ensure you're working on the correct image.
While you probably won't have a need for an image file with multiple editions of Windows 7, you may want to create an image file with multiple versions of Windows 7 installations. For example, you can create one image that includes the software and configuration needed by sales people and name it Windows 7 Sales. You can create another image needed by personnel working in IT and name it Windows 7 IT.
A benefit of storing multiple images in a single WIM file is that the imaging format uses single file storage for efficiency. That way, if five images in a WIM file have an identical application named Notepad.exe, it is stored only once instead of five times.