Windows Native VHD Boot, Deployment Scenarios

Native VHD Boot
Deployment Scenarios
Michael Waterman
Infrastructure Consultant, Microsoft Consulting Services
michael.waterman@microsoft.com
Windows Native VHD Boot, Deployment Scenarios
© 2009 Microsoft Corporation. All rights reserved.. The information contained in this document represents the current view of Microsoft
Corporation on the issues discussed as of the date of publication and is subject to change at any time without notice to you. This
document and its contents are provided AS IS without warranty of any kind, and should not be interpreted as an offer or commitment on
the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented. MICROSOFT MAKES NO WARRANTIES,
EXPRESS OR IMPLIED, IN THIS DOCUMENT.
Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this
document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic,
mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in
this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not
give you any license to these patents, trademarks, copyrights, or other intellectual property.
The descriptions of other companies’ products in this document, if any, are provided only as a convenience to you. Any such references
should not be considered an endorsement or support by Microsoft. Microsoft cannot guarantee their accuracy, and the products may
change over time. Also, the descriptions are intended as brief highlights to aid understanding, rather than as thorough coverage. For
authoritative descriptions of these products, please consult their respective manufacturers.
We will not knowingly provide advice that conflicts with local, regional, or international laws, however, it is your responsibility to confirm
your implementation of our advice is in accordance with all applicable laws.
Page|2
&
Windows Native VHD Boot, Deployment Scenarios
Introduction
This document describes the functionality and usability of native VHD boot, one of the many new
features of Windows 7 and Windows server 2008 R2. Native VHD boot will support Microsoft’s
customers with a way to use a single disk format to service both virtual and physical clients alike.
The scenarios presented in this document will guide you through the steps necessary to gain an
insight into this new technology so eventually you will be able to apply it in a useful and productive
manner within your own organization.
Target Audience
This document has been created for IT professionals who want to familiarize themselves with
Windows Native VHD boot. It will guide them by a series of step-by-step scenarios to get acquainted
with the technique and supporting deployment tools.
Change Record
Date
Author
Version
Change reference
23-05-2009 MW
0.1
Initial draft
05-07-2009 MW
1.0 Draft
First version ready for review
Contributors
Name
Page|3
Version
Position
Date
&
Windows Native VHD Boot, Deployment Scenarios
Introduction............................................................................................................................................. 3
Target Audience ...................................................................................................................................... 3
Change Record .................................................................................................................................... 3
Contributors ........................................................................................................................................ 3
What’s native VHD boot? ........................................................................................................................ 6
Native VHD boot goals ............................................................................................................................ 6
Available VHD disk configurations........................................................................................................... 7
Limitations ............................................................................................................................................... 7
Example scenarios ................................................................................................................................... 8
Scenarios ................................................................................................................................................. 8
Scenario Prerequisites ............................................................................................................................. 8
Tools ........................................................................................................................................................ 9
Scenario 1 - Basic Setup......................................................................................................................... 10
Scenario description: ......................................................................................................................... 10
Step 1 installing the Windows AIK......................................................................................................... 11
Step 2 create the VHD file ..................................................................................................................... 12
Step 3 applying the Windows image to the VHD .................................................................................. 13
Step 4 Change the boot configuration .................................................................................................. 14
Step 5 detach the VHD .......................................................................................................................... 17
Scenario 2 - WDS Deployment .............................................................................................................. 18
Scenario description .......................................................................................................................... 18
Step 1 Initial configuration of WDS ....................................................................................................... 19
Step 2 Add an boot image ..................................................................................................................... 20
Step 3 Create the reference VHD .......................................................................................................... 21
Step 4 apply the image to the VHD ....................................................................................................... 22
Step 5 detach the VHD .......................................................................................................................... 23
Step 6 add the VHD to WDS .................................................................................................................. 23
Step 7 creating the unattended file ...................................................................................................... 24
Step 8 associate the unattended file ..................................................................................................... 28
Scenario 3 - Advanced Deployment ...................................................................................................... 29
Scenario Description: ........................................................................................................................ 29
Step 1 create Windows PE..................................................................................................................... 30
Page|4
&
Windows Native VHD Boot, Deployment Scenarios
Step 2 create boot media ...................................................................................................................... 32
Step 3 copy WIM files ............................................................................................................................ 34
Step 4 USB boot ..................................................................................................................................... 35
Step 5 prepare the system .................................................................................................................... 35
Step 6 diskpart ....................................................................................................................................... 36
Step 7 create the VHD's......................................................................................................................... 37
Step 8 Apply the WIM files to the VHD's ............................................................................................... 38
Step 9 boot configuration data store .................................................................................................... 39
Step 10 Windows Server 2008 R2 VHD ................................................................................................. 41
Step 11 add Windows PE ....................................................................................................................... 42
Step 12 create the RAMDISK ................................................................................................................. 42
Step 13 create the Windows PE entry ................................................................................................... 44
Step 14 thin provisioning for native VHD boot ..................................................................................... 45
Step 15 apply thin provisioning during Windows PE............................................................................. 47
Step 16 detach the VHD's ...................................................................................................................... 48
Step 17 reboot Windows PE .................................................................................................................. 48
Step 18 creating differencing disks ....................................................................................................... 49
Final word .............................................................................................................................................. 50
Page|5
&
Windows Native VHD Boot, Deployment Scenarios
What’s native VHD boot?
Native VHD boot enables a physical machine to be booted directly from a virtual hard disk (VHD) with
no requirement for virtualization software (such as Microsoft Virtual PC or Hyper-V). Native VHD
boot is made possible with the addition of a new mini-port driver within the Windows 7 operating
system which is responsible for all IO operations to and from the disk. Earlier versions of the
Windows operating system such as Windows Vista, Windows XP and Windows 2000 do not support
Native VHD boot and therefore cannot be used to provide the capabilities described within this
document.
With the introduction of native VHD boot, it is now possible to achieve a single image deployment
strategy for physical and virtual machines alike. As long as the operating system that resides on the
VHD is generalized and hosts either Windows 7 Enterprise, Windows 7 Ultimate or Windows Server
2008 R2 (all versions), it can be used in both environments.
Native VHD boot goals
The main goals for the introduction of native VHD boot are:





Use consistency in the deployment of images for both virtual and physical infrastructures.
Use a single set of tools for managing both virtual and physical infrastructures.
Rapid deployment of new machines.
Support multiple boot configurations without the need to create separate partitions.
Create a system with the flexibility of a virtual environment like Hyper-v but still use the
physical system hardware.
Page|6
&
Windows Native VHD Boot, Deployment Scenarios
Available VHD disk configurations
There are 3 types of VHD disk configurations available.
1. Fixed VHD. A fixed VHD file is configured with a disk size that is allocated to its full extent
when the VHD is created. For example, A VHD file with a configured size of a 100 GB will
allocate the full 100 GB at the moment the VHD is created. This configuration is good for
performance and guarantees available disk space as the underlying system must already
have the space available at creation time.
2. Expandable VHD. An expandable VHD is created as a small file with an initial size of around
250 KB. As data is being writen to the VHD it will expand until it reaches its maximum size,
which is configured during creation time. Using expandable disks is good in a thin
provisioning scenario (see scenario 3, step 14).
3. Differencing disks. A differencing disk can be compared to an expandable disk in respects to
its growth pattern. It’s actually a parent - child relationship between the two disks where the
child disk holds the differences and grows when data is written to it. The parent disk will
remain read-only and must not be modified to prevent data corruption. A parent - child
relationship can be established with a fixed, expandable or another differencing disk. The
latter will create a differencing disk chain.
Note! The maximum virtual disk size is 2040 GB (2 TB)
Limitations
The following items are limitations in this release of Windows Native VHD Boot






BitLocker. Although you can place a VHD on a partition that is BitLocker enabled, it will not
be possible to boot from that VHD. Enabling BitLocker on the OS within the VHD is also not a
supported configuration.
Images. Creating VHD images is still a manual process, although you can use the existing
image infrastructure for deployment (if it supports the creation of VHD)’s.
Setup. There is no setup support while deploying the images. You have to apply an image
directly to a VHD. Using setup is not a supported configuration.
Differencing disks. When using differencing disks, all VHD files need to be stored on the
same partition.
SKU’s limitations. Only the Windows 7 Enterprise and Ultimate editions can be used for
Windows Native VHD boot. There is no limitation for the server SKU’s.
Hibernation: You cannot hibernate a system that runs on a VHD, however, sleep is available.
Page|7
&
Windows Native VHD Boot, Deployment Scenarios
Example scenarios
To help gain insight into what can be achieved using Windows Native VHD Boot, a number of stepby-step scenarios are detailed in the sections below. The step-by-step examples range from a simple
setup, to an advanced deployment scenarios utilizing the Microsoft deployment toolset.
Scenarios
The step-by-step guides in this document will address the following scenarios:
Scenario 1- Basic Setup.
In this scenario we will use disk manager on an existing installation of Windows 7 to add a VHD, apply
Windows 7 Enterprise on it and configure the boot configuration data store so it can boot off the
VHD.
Scenario 2 - WDS Deployment
one of the added features of Windows Server 2008 R2 is deploying VHD files with Windows
Deployment Services. In this scenario we will deploy a custom Windows 7 VHD using WDS.
Scenario 3 - Advanced Deployment Scenario.
In the advanced deployment scenario we will establish native VHD boot with two operating systems
and have a local copy of Windows PE for recovery purposes. A locally installed version of Windows
will not be used, only virtual disks.
Scenario Prerequisites
In Preparation for the step-by-steps scenarios, download and install the required tools.

Windows Automated Installation Kit (WINDOWS AIK).
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=60a07e710acb-453a-8035-d30ead27ef72

Windows 7 Release Candidate
http://www.microsoft.com/windows/windows-7/download.aspx

Download Windows Server 2008 R2 RC.
http://www.microsoft.com/windowsserver2008/en/us/R2-Download.aspx

A USB drive with a minimum of 10 GB free disk space. (Only for the advanced deployment
scenario).
Page|8
&
Windows Native VHD Boot, Deployment Scenarios
* Windows 7 and Windows Server 2008 R2 are delivered in ISO format. Before continuing, extract
both ISO’s files as flat files or burn the ISO file to a DVD. We will use the data at a later stage in this
document.
Tools
The following tools will be used throughout this document.












WINDOWS AIK. The Windows Automated Installation kit. The default Microsoft toolset for
creating and maintaining images.
Windows PE. (Windows Pre-Installation environment). A Windows version with a very small
footprint specially designed for deployment purposes.
WDS. Windows Deployment Service. Out of the box solution for deploying Windows images.
BCD. Boot Configuration data store. The BCD stores the boot configuration parameters and is
the successor to the boot.ini.
BCDBoot. Command-line tool for manually creating the boot configuration data store.
BCDEdit. Command-line tool for manually editing the boot configuration data store.
Disk Manager. Graphical tool for editing disk configurations.
Diskpart. Command-line tool for editing disk configurations.
WIM. Windows Imaging format.
VHD. Virtual hard disk.
ImageX. Command-line tool for editing and deploying images.
DISM. Command-line tool for managing WIM and VHD files.
Page|9
&
Windows Native VHD Boot, Deployment Scenarios
Scenario 1 - Basic Setup
Scenario description:
The goal of this scenario is to gain familiarity with the steps required for enabling Windows Native
VHD boot. Using an existing installation of Windows 7 *. Windows Server 2008 R2 can also be used in
this scenario. The steps for creating a VHD through the GUI and altering the boot configuration data
store are the same on both operating systems.
We will start out with the installation of the “Windows Automated Deployment Kit”. While not
directly related to Native VHD Boot, it offers the imageX tool that we will be using to apply an image
to a virtual disk. Next I’ll show you how to create a VHD through the graphical interface of disk
manager and apply an image to it. As a last step the boot configuration data store will be altered so
we can actually boot to the operating system applied to the virtual disk. To summarize, these are the
steps we will take:





Install the Windows Automated Installation Kit.
Create a VHD through the GUI.
Mount the VHD and create a partition.
Apply Windows 7 to the VHD.
Configure the boot configuration data store.
Assumptions



Windows 7 Enterprise, Windows 7 Ultimate or Windows 2008 R2 is installed.
Windows 7 Enterprise, Windows 7 Ultimate or Windows 2008 R2 installation media is
available.
“Windows Automated Installation Kit” (WINDOWS AIK) media is available.
To illustrate, figure 1 represents the disk layout and placement of the VHD disk for this scenario.
Figure 1Basic Setup
* Only Windows 7 Enterprise or Ultimate can be used with Windows Native VHD boot.
P a g e | 10
&
Windows Native VHD Boot, Deployment Scenarios
Step 1 installing the Windows AIK
Before we start with the creation of the VHD file, we first need to install the “Windows Automated
Installation Kit”. This kit, full of utilities for deployment and maintenance of Windows Images (WIM)
and VHD files can be downloaded from the Microsoft download center (URL in the requirements list).
The primary tool we will be using in this scenario is imagex. The tool is used when we apply the
image of Windows 7 to the virtual disk. But before we are able to do so, the Windows AIK must be
installed on the local computer. Use the steps below to install the kit.
1. Browse to the location where you stored the Windows AIK media and double click the
“startcd.exe” application.
2. Click “Yes” in the user account control dialog screen.
3. On the left of the “Welcome to the Windows Automated Installation Kit” dialog screen, click
on “Windows AIK setup”.
4. Click “Next” on the “Windows Automated Installation Kit Setup Wizard” page.
5. On the “License Terms” dialog screen, select “I agree” and click “Next”.
6. Select the appropriate installation folder or leave the default setting and click “Next”.
7. On the “Confirm Installation” screen, click “Next” and wait for the installation to finish.
8. Once the installation has finished, click on the “Close” button to exit the WINDOWS AIK
setup.
9. Close the setup application.
Once the installation is successful we have installed all the tools for the deployment and
management of VHD files. We will be using the”imagex.exe” tool later in this document to apply
the image to the VHD which we will create in the next step.
P a g e | 11
&
Windows Native VHD Boot, Deployment Scenarios
Step 2 create the VHD file
Now that we have installed the deployment tools, we can start with the creation of the VHD file. For
this scenario we will be using a local folder named “VHD Files” which is placed in the root of the C
drive, but you could give it any name or store it in any place you desire. Next to storing VHD’s in a
subfolder they could also be placed directly in the root of the drive. The VHD we’ll create will have
the following specifications:




Name: WIN7.vhd
Size: 50 GB
Type: Dynamically expandable
Storage Location: “C:\VHD Files”
Choose the “Dynamically expanding” option only when you want to save on initial disk space usage.
With this option only a small VHD is created initially and will grow dynamically once you put data on
the virtual drive. It does have an impact on performance though because not all blocks are
consistently written next to each other on the physical disk. For servers or workstation where
performance is an aspect you should take into consideration, choose the “Fixed Size” option.
To start with the creation of the VHD, follow these steps:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
On the start menu, right click on “Computer” and select “Manage”.
Click “Yes” in the “User Account Control” dialog screen.
In the “Computer Management” console, click on “Disk Manager” in the left column.
Click on “More Actions” in the right column and select “Create VHD”.
Use the following settings in the “Create and attach Virtual Hard Disk” dialog screen and click
“OK” when finished.
a. Location:”C:\VHD Files\WIN7.vhd”.
b. Virtual hard disk size: 50 GB.
c. Virtual hard disk format: Dynamically expanding.
If this is the first time you create a VHD, a small indicator will pop-up in the notification area
informing you that a driver is being installed.
Next thing we need to do is initialize the disk. In “Disk Manager” right click on the 50 GB disk
that we just created (notice that the disk has a blue color) and select “Initialize Disk”.
In the “Initialize Disk” dialog screen, make sure that the VHD disk we just created is selected
and choose “MBR” for the partition style. Click “OK”. Once the disk has been initialized we
can start creating a partition on it.
Right click on the “Unallocated space” area of the disk and select “New simple volume”.
On the “Welcome to the New Simple Volume Wizard”, click “Next”.
Leave the default values on the “Specify volume size” dialog screen as we will be using the
entire size of the disk as our system volume. Click “Next”.
On the “Assign Drive Letter or Path” dialog screen, select drive letter “V:” and click “Next”.
P a g e | 12
&
Windows Native VHD Boot, Deployment Scenarios
13. Choose the following options for the “Format this volume with the following settings” and
click “Next” to continue.
a. File system: NTFS
b. Allocation unit size: Default
c. Volume label: system
14. Click “Finish” on the “Completing the New Simple Volume Wizard”, to create the partition.
Wait for a few second for the creation of the partition to finish. Don’t close the “Computer
Management” console yet as we will need it at a later stage.
Step 3 applying the Windows image to the VHD
One of the limitations of Windows Native VHD Boot is that it’s only available with Windows 7
Enterprise, Windows 7 Ultimate or Windows Server 2008 R2 (all versions). Since it’s also possible for
a Windows Image file to contain more than one configuration we will first need to determine the
correct version (or index number) of that Windows version that resides within the WIM file. This is
especially true for the install.wim file that’s available on the original installation media. In step 1 we
already installed the “Windows Automated Installation Kit” which contains the tools to determine
the index number. The version of Windows that this number referrers to is called a stock unit, or SKU
for short. As a first step we will be searching for the correct SKU unit number, in this case Windows 7
Enterprise. The tool we will use is new to Windows 7 and is called the DISM tool, which stands for
“Deployment Image Servicing and Management”.
1. On the start menu right click on the “Deployment Tools Command Prompt” in the
“Microsoft Windows AIK” folder and select “Run as administrator”.
2. Click “Yes” in the “User Account Control” dialog screen.
3. Type the following DISM command to view the information on the SKU’s within the WIM file.
dism.exe /Get-Wiminfo /Wimfile:”C:\Sources\Windows 7
Enterprise\Sources\instal.wim”.
You will see that in the case of Windows 7 Enterprise that there’s only one SKU available in
the WIM file. The index number is the number to remember, we will be using this number
when we apply the data tot the virtual disk.
Note! If you want more information on the specific SKU, type “/Index:<Number>” behind
the command above.
4. Now that we have the correct index number we can start applying the data from the WIM
file to the virtual hard disk. Use the following command with the Imagex tool to apply the
data to the disk.
imagex.exe /apply ”C:\Sources\Windows 7 Enterprise\Sources\instal.wim”
P a g e | 13
&
Windows Native VHD Boot, Deployment Scenarios
1 v:
Wait for the command to finish. The whole process can easily take 10 minutes or more
depending on the performance of your configuration.
5. Type “exit” in the command prompt to close it.
Step 4 Change the boot configuration
We are almost done with the steps that are required for booting off a virtual disk. The last thing that
remains is to change the “Boot Configuration Data Store” (BCD), which is essentially the successor to
the boot.ini file that was used in previous versions of the Windows operating systems. The default
tool for editing the BCD store is “BCDEdit.exe”.
In this step we will be using this command-line tool to add a boot entry to the store so we will be
able to select it when we start the computer. Use the steps and commands below to enable the
settings in the BCD store.
1. On the start menu, right click on the “Command Prompt” in the “Accessories” folder and
choose “Run as administrator”.
2. Click “Yes” in the “User Account Control” dialog screen.
P a g e | 14
&
Windows Native VHD Boot, Deployment Scenarios
3. To take a first look at the BCD store we will be execute the “bcdedit.exe” command with
the “/enum” switch to enumerate the current entries. Use the command: “bcdedit.exe
/enum”. The output will look similar like figure 2:
Figure 2 Default BCD store
4. We could just make a new entry manually, but it’s far easier to just copy the settings from
the current boot environment and use that as a starting point. To do so use the following
command:
bcdedit.exe /copy {current} / d “Windows 7 VHD Boot”
The output will generate a new GUID. We will use this GUID in the following commands as a
reference when we want to change a setting in the Windows Boot loader entry.
5. We need to change two crucial settings in the newly created boot loader entry. These
settings tell the Windows boot manager to look for a VHD file during initialization. Use the
following two commands to alter the device and OSDevice setting.
bcdedit.exe /set {d89f3fa4-6416-11de-b070-b08b383b8f33} device
vhd=”[locate]\VHD Files\WIN7.vhd”
bcdedit.exe /set {d89f3fa4-6416-11de-b070-b08b383b8f33} osdevice
vhd=”[locate]\VHD Files\WIN7.vhd”
P a g e | 15
&
Windows Native VHD Boot, Deployment Scenarios
The setting [locate] will instruct the Windows Boot Manager to locate the VHD without
you having to specify a drive letter at creation time.
6. Since we will be doing an installation of Windows, we will also need to be able to detect the
hardware abstraction layer (HAL) during setup. Therefore we need to enable a final setting to
make this possible. Use the command below to enable this feature.
bcdedit.exe /set {d89f3fa4-6416-11de-b070-b08b383b8f33} detecthal Yes
7. If you where to run the “bcdedit.exe /enum” command again the output would now look
like the example in figure 3.
Figure 3 The new boot entry to enable VHD boot
8. This finishes the creation of the boot entry for the VHD we created. Type “exit” in the
command prompt to close it.
Note! To set the VHD boot loader entry as the default boot configuration, use the following
“bcdedit.exe” command:
Bcdedit.exe /default {d89f3fa4-6416-11de-b070-b08b383b8f33}
P a g e | 16
&
Windows Native VHD Boot, Deployment Scenarios
Step 5 detach the VHD
The final step is to gracefully detach the virtual disk. This will prevent data corruption if you reboot
the computer with the VHD still attached. If the VHD would remain attached there’s always a
possibility that files would remain open or locked and the data on the VHD would eventually be
damaged. Just like attaching a VHD we can also detach the virtual disk with “Disk Manager. Use the
following steps to detach the VHD, assuming that the “Computer Management” console is still open.
1. In “Disk Manager” right click on the disk representing the attached VHD. (The disk is
displayed in blue).
2. On the menu select “Detach VHD”.
3. On the “Detach Virtual Hard Disk” dialog screen, make sure that the option for deleting the
VHD after the detach is not selected and click “OK”.
4. Close the “Computer Management” console.
We have now completed all the steps required to create a virtual hard disk, applied an operating
system to it and configured the boot configuration data store to enable us to actually select the VHD
during boot. Al that remains is to reboot the machine and start the installation.
P a g e | 17
&
Windows Native VHD Boot, Deployment Scenarios
Scenario 2 - WDS Deployment
Scenario description
In the first chapter I showed you how to create and boot from a virtual disk. We’ve talked about how
to create the VHD, applied an OS to the virtual disk and edited the boot configuration so the VHD
could be used as a boot device. In this chapter we will be exploring one of the new VHD deployment
options for Windows Deployment Services (WDS) that comes as an optional role in Windows Server
2008 R2.
With the help of the new Windows deployment services VHD deployment options that is now
available in the Microsoft Server 2008 R2 operating system you will be able to deploy preconfigured
VHD files throughout your organization. If you are already familiar with WDS you will notice that
there is very little difference in how you would deploy a VHD file compared to a Windows Image
(WIM) file. The main difference will be on how you would manage the VHD with WDS. Unfortunately
it is currently not possible to use the “Windows Deployment Services Management Console” to add
VHD files on the server. For this purpose you will need the command-line utility “WDSUtil.exe”.
In this chapter we will explore the possibilities of this tool and add a VHD to the WDS server. Next
we’ll assign an unattended file and eventually install a client machine.
This chapter requires the following features:





A Windows 2008 or R2 domain controller.
DHCP, DNS must be operational.
The Windows Automated Installation Kit is installed (see chapter 1, step 1).
A domain member server with the WDS role installed (we’ll cover the basic setup).
o The server OS is installed on C:
o The data will be stored on D: which is a separate disk, not just a partition
The Windows 7 media is copied as flat files to “D:\Sources\Windows 7 Enterprise”
The client will have a disk layout with 2 partitions. One with the system partition, where the boot
files will be stored on and one data partition where the VHD will be copied to.
Figure 4 Disk Layout
P a g e | 18
&
Windows Native VHD Boot, Deployment Scenarios
Step 1 Initial configuration of WDS
When you have configured all the requirements for this scenario we can begin configuring the
Windows Deployment Service. The first step we need to take is to go through the basic setup wizard
for WDS. To do so follow these steps:






Click “Start” - “Administrative Tools” – “Windows Deployment Services”. The
administrative console for WDS will start.
In the conlsole, click on “Servers”. For a brief moment a dialog will try to add your already
installed WDS servers (if applicable). Eventually it will display your local server name, if it
does, select it. On the right side of the console you will see a message telling you that the
server needs to be configured before it can be used. To do so, we’ll right click on the server
name and choose “Configure”. The setup wizard will help us with the configuration of the
WDS server.
Read through requirements on the “before you begin” dialog screen and click “Next”.
The data for the WDS server (in our case the VHD and unattended files) will need to be
stored locally on the server. To be able to do so we’ll need suffecient space to store the VHD
and additional files. This option can be chosen in the dialog screen, “Remote Installation
Folder Location”. In my case I will be storing the data on the “D:” drive in the folder
“RemoteInstall”. Click “Next” when you have selected your target folder.
Before bringing your WDS server into production you need to configure it to respond to
clients requesting service. On the “PXE Server Initial settings” page you can select one of
three choices. The more advanced configuration of the WDS server is out of scope for this
document so we’ll choose the easy option of “Respond to all client computers (Know and
unknown)” and click “Next”. After this step the WDS server will apply the initial settings
which will take a few seconds to complete.
On the final page, clear the checkmark in front of the sentence “Add images to the server
now”. There’s no need to add a WIM file now because we will be deploying a VHD file
instead. Click “Finish” to complete the setup.
P a g e | 19
&
Windows Native VHD Boot, Deployment Scenarios
Step 2 Add an boot image
Besides deploying a VHD file, we need something that we can use as a boot device. Lucky for us
adding a boot device is a very easy, wizard driven task in WDS. After configuring WDS (in step 1) we
now have a couple of folders on the left side of the WDS management console.
Figure 5 WDS Folders





Install Images. Location for the WIM and / or VHD files.
Boot Images. Folder where the Windows PE (boot) images are listed.
Pending Devices. Depending on the configured policy, devices that request service will
appear in this node.
Multicast Transmissions. Folder for configuring and maintaining multicast deployment.
Drivers. A new feature of Windows Server 2008 R2, during deployment drivers will
automatically be selected (if properly configured).
In this step we will concentrate on the “Boot Images” folder. The image we’ll add can later be used as
our deployment vehicle. Follow the steps below to add the boot image.




Right click on the “Boot Images” folder and select “Add Boot Image”.
In the “Image File” dialog screen we can now browse to the location of a Windows PE image.
Windows PE is a minimal version of Windows that is primarily used for deployment purposes.
When you purchase Windows 7 you already have a version of WinPE that you can use free of
charge. On your Windows 7 media locate the “Sources” folder. Within this folder there are
two “.wim” files, Install.wim and boot.wim. The latter is the Windows PE version that we will
be using. Click on the “Browse” button and proceed to the folder where you stored the
boot.wim file. Select the file and click “OK”. Click “Next” to proceed.
On the “Image Metadata” screen, leave the default text or alter it according to your wishes
and click “Next”.
On the “Summary” screen, review your settings and select “Next” to begin copying the file to
the deployment server store. This can take a few seconds, wait until the process finishes,
then click “Finish”.
P a g e | 20
&
Windows Native VHD Boot, Deployment Scenarios
Step 3 Create the reference VHD
Like Windows 7, Windows Server 2008 R2 has the ability to create a VHD through the GUI. Also with
the addition of Hyper-V you are now able to create VHD’s in the Hyper-v Management Console, apply
an operating system to it, customize and generalize it, all in a virtual environment. Afterwards these
VHD’s can be distributed with WDS or any other mechanism that supports VHD deployment.
Note! You cannot use VHD files created with Virtual PC 2007.
We will be creating our reference VHD with these specifications:




Name: WIN7WDS.vhd
Size: 50 GB
Type: Dynamically expandable
Storage Location: “D:\Sources\VHD Files”
In the first scenario we used the computer management console to create our first VHD. In the
current scenario we will use the same steps, but now though the use of the command-line. Knowing
both methods gives you the flexibility of choosing the way that best fits you. The command-line
equivalent of the graphical disk manager is “diskpart.exe”. We will be using this tool to create the
virtual disk.
Open the command prompt, make sure you run it as an administrator and enter the commands
below.
diskpart
create vdisk file=”D:\Sources\VHD Files\WIN7WDS.VHD” type=expandable
maximum=50000
select vdisk file=”D:\Sources\VHD Files\WIN7WDS.VHD”
attach vdisk
Create partition primary
Assign letter=v
format fs=ntfs quick
exit
exit
The commands above will create an expandable VHD disk with a maximum size of 50 GB, mount it as
drive letter v: and prepare the file system.
P a g e | 21
&
Windows Native VHD Boot, Deployment Scenarios
Step 4 apply the image to the VHD
In scenario one (basic setup) we applied a Windows image (WIM) file to a VHD with the commandline tool “imagex.exe” (step 3). It really doesn’t matter if you’re running Windows 7 or Windows
Server 2008 R2 if you want to use the “imagex” tool for applying an image to the disk. Refer to step 3
in scenario one for more information or follow the commands below to apply the image to the virtual
disk.
1. On the start menu right click on the “Deployment Tools Command Prompt” in the
“Microsoft Windows AIK” folder and choose “Run as administrator”.
2. Click “Yes” if the “User Account Control” dialog screen appears.
3. Type the following DISM command to view the information on the SKU’s within the WIM file.
dism.exe /Get-Wiminfo /Wimfile:”D:\Sources\Windows 7
Enterprise\Sources\instal.wim”.
You will see that in the case of Windows 7 Enterprise that there’s only one SKU available in
the WIM file. The index number is the number to remember, we will be using this number
when we apply the data to the virtual disk.
Note! If you want more information on the SKU, type “/Index:<Number>” behind the
command above.
4. Now that we have the correct index number we can start applying the data from the WIM
file to the virtual hard disk. Use the following command with the “Imagex” tool to apply the
data to the disk.
imagex.exe /apply :”D:\Sources\Windows 7
Enterprise\Sources\instal.wim” 1 v:
Wait for the command to finish. The whole process can easily take 10 minutes or more
depending on the performance of your configuration.
5. Type “exit” in the command prompt to close it.
P a g e | 22
&
Windows Native VHD Boot, Deployment Scenarios
Step 5 detach the VHD
Much like in the final step of scenario 1 we also need to gracefully detach the VHD before we can
begin using it. Instead of the disk manager tool we used in the first scenario, we will again use the
diskpart command-line tool like we did before. Use the commands below to detach the virtual disk.
Open the command prompt, make sure you run it as an administrator and enter the commands
below.
diskpart
select vdisk file=”D:\Sources\VHD Files\WIN7WDS.VHD”
detach vdisk
exit
exit
Step 6 add the VHD to WDS
Windows deployment services graphical interface has a fairly simple but limited functionality. A more
powerful tool that exposes all the features of WDS is the command-line tool, “WDSUtil.exe”. As it
happens there is actually no option in the WDS console to add a VHD file so consider adding a VHD
file as an advanced feature.
In step 2 of this scenario I showed you that after initializing the WDS server a couple of default
folders where created on the server. One of these folders is “Install Images” which obviously is the
location where we will find or store the installation images and VHD files that we add to the server.
Before we can actually add an image to the “Install Images” folder we need to create a group
underneath it. This will create a more structured approach of maintaining and deploying your images.
We could now open the management console and use the GUI to add an image group, but since
we’re busy with command-line tools , this will be a good introduction into “WDSUtil.exe”. Use the
commands below to add the image group “Virtual Disks”.
WDSUtil.exe /add-imagegroup /imagegroup:”Virtual Disks”
We’re now ready to add our previously created VHD file to the WDS server. Like stated above we are
required to use “WDSUtil.exe” to accomplish this task. The command below will select the correct
image, select the just created image group and add the VHD to the server. The “verbose” and
“progress” options give extra information during the copy.
Wdsutil.exe /verbose /progress /add-image /imagefile:”d:\sources\vhd
files\win7wds.vhd” /imagetype:install /imagegroup:”vhd files”
This process will take a while, give it time to finish before you continue with the next step.
The output will look similar as is displayed in figure 6:
P a g e | 23
&
Windows Native VHD Boot, Deployment Scenarios
Figure 6 WDSUtil output
Step 7 creating the unattended file
If you were to network boot a client machine and login to the WDS deployment wizard you would
probably see the virtual disk we added in step 6. I say probably because running the deployment
wizard manually is currently not a supported configuration. If you want to deploy a VHD to more
than one machine you would most likely want to create an unattended file for deployment anyway.
In this step we will focus on the “Windows System Image Manager” tool (WSIM). This tools that’s
included with the “Windows Automated Installation Kit” is the default editor for creating unattended
xml files that can be used for deploying Windows. Use the following steps to create the unattended
file for the VHD deployment method.



In the start menu, under “All Programs”, select “Windows System Image Manager” in the
folder “Windows Automated Installation Kit”.
In the “Windows System Image Manager” window, right click “Select a Windows image or
catalog file” and select “Select Windows Image”.
Now you have probably noticed that we can’t select the VHD file from the “Select a
Windows Image” dialog screen. We don’t really want to open a VHD at this point but a
regular Windows Image, so we will be able to use the content of that image. Browse to the
location where you stored the Windows 7 media. In my case this is “D:\Sources\Windows 7
Enterprise\Sources”. Select the “install_windows 7 ENTERPRISE.clg” file. What actually
happened is that you “looked” inside the WIM file and retrieved all the configuration
options available. The catalog file is a subtract of the actual WIM file that is too large to
work with directly.
P a g e | 24
&
Windows Native VHD Boot, Deployment Scenarios
Note! If an error message appears indicating that the catalog file is out of date, select the
WIM file instead so the system can generate a new catalog for you.


Now that we can use the content of the image, it’s time to create the unattended file.
Right click on “Create or open an answer file” and select “New Answer File…”. A new
empty answer file will be created for you. As you can see there are 7 components added to
your answer file by default. These represent the 7 stages that a setup can go though. I say
can go through because not all components are applicable at all deployment stages. In this
scenario we will focus on the “Windows PE” component.
On the left side of the WSIM console, expand “Components”. Scroll down to “MicrosoftWindows-Setup” and expand the node. Right click on”WindowsDeploymentServices” and
select “Add Setting to Pass 1 WindowsPE”. This will expose all the possible options for this
component in the unattended answer file. Before the settings are actually written to the
file they have to be given a value first. Use the following table to create the entire
unattended answer file. Repeat the steps above if necessary.
Windows International Core WinPE
Property
Setting
Value
UILanguage
en-US
UILanguage
en-US
Setting
Value
WillShowUI
OnError
DiskID
0
WillWipeDisk
True
Windows-International-Core-Winpe
SetupUILanguage
Windows Setup Neutral
Property
DiskConfiguration
Disk[DiskID=”0”]
P a g e | 25
&
Windows Native VHD Boot, Deployment Scenarios
CreatePartition[Order=”1”]
Extend
False
Order
1
Size
100
Type
Primary
Extend
True
Order
2
Type
Primary
Active
True
Format
NTFS
Label
System Reserved
Order
1
PartitionID
1
Active
False
Format
NTFS
Letter
D
Order
2
PartitionID
2
CreatePartition[Order=”2”]
ModifyPartition[Order=”1”]
ModifyPartition[Order=”2”]
P a g e | 26
&
Windows Native VHD Boot, Deployment Scenarios
WindowsDeploymentServices
Property
Setting
Value
Filename
WIN7WDS.vhd
ImageGroup
Virtual Disks
ImageName
Enterprise_6.1.7200
DiskID
0
PartitionID
2
Domain
<YourDomain>
Password
<YourPassword>
Username
<YourUsername>
InstallImage
InstallTo
Credentials
Those of you that have worked with unattended setup files before might have noticed that in the
settings above, the deployment is actually done to drive D. This is because the drive letter you assign
here is the drive letter that will be assigned to the partition where the image will be deployed to. In
the case of VHD deployment the virtual disk needs to be on the D drive so the system within the VHD
can be assigned the drive letter C (still with me?). This isn’t a hard technical requirement, but it
prevents users from being confused and will probably also prevent applications from failing because
they most likely expects to be on the C drive.
The final step is to save the unattended XML file. Click the save option in the menu bar and save the
file in the “WDSClientUnattend” directory. This sub folder resides under the root of the WDS folder
structure.
P a g e | 27
&
Windows Native VHD Boot, Deployment Scenarios
Step 8 associate the unattended file
The final step in the “Windows Deployment Services” virtual disk deployment scenario is to associate
the unattended file we created in step 7 with either an X86, IA64 or X64 architecture or an individual
computer object. We will cover both in this step.
The WDS console exposes the possibility to associate the XML file with either the X86, IA64 or the
X64 architecture. Working in this manner will configure every single machine that falls in either
category in exactly the same way. In our case this would mean that every machine that contacts the
WDS server will get 2 partitions where the VHD will be installed on drive letter D. This could work for
the larger part of your organization, but there are always exceptions. I’ll show you how to handle
these exceptions, but first here are the steps on how to associate the unattended file with the X86
architecture.





In the “Windows Deployment Services” console, right click on the server name and select
“Properties”.
Click the “Client” tab.
Enable the option “Enable unattended installation”.
Click the “Browse” button and select the unattended file we created in step 7. (the file was
stored in the WDSClientUnattend folder). Click “Open” to return to the client tab.
Click “Ok” to close the properties pages.
These are all the steps required to associate an unattended file with a specific architecture. Now
suppose we want to make an exception to the rule and configure an individual machine with
different settings. This option is unfortunately not exposed by the WDS console and has to be
configured with “WDSUtil.exe”. Follow the steps below to associate the XML file we created in step
7 with an individual computer.


Open the command prompt. Make sure you have sufficient right to create a computer object
in Active Directory.
Use “WDSUtil.exe” with the following command:
wdsutil.exe /Add-Device /Device:Computer1 /ID:{The computers UUID}
/WDSClientUnattend:WDSClientUnattend\WDSUnattend.xml
The UUID of the computer can be found in the bios, when the computer boots to the network or
when it is installed already via WDS in the properties of the computer object in Active Directory.
Note! There are many options available for client staging with WDS. Use “wdsutil.exe /adddevice /?” for more options.
P a g e | 28
&
Windows Native VHD Boot, Deployment Scenarios
Scenario 3 - Advanced Deployment
Scenario Description:
In this chapter we will combine a couple of the more advanced deployment and configuration tools
for Windows 7 and Windows Server 2008 R2. We’ll make extensive use of command-line tools and
we’ll create our own custom build Windows PE which will serve as our installation platform. To reach
this goal we will take the following steps:








Create a custom version of Windows PE.
Boot Windows PE off a USB drive.
Create 2 partitions on the local disk.
Copy Windows PE as a WIM file to the first partition.
Edit the boot file so when the WIM file selected it is loaded into memory.
Create 2 VHD’s on the second partition and use them as the boot disks. No additional
operating system will be installed on that drive.
Edit the boot configuration so you can select Windows PE, Windows 7 or Windows Server R2
when the system boots.
Enable the use of differencing disks once the operating systems have been installed and
configured.
To illustrate, figure 7 represents the disk layout and placement of the VHD disks.
Figure 7 Scenario Layout
As you can see the first partition is slightly larger than the default 100 MB that Windows 7 or
Windows server 2008 R2 creates. The reason for this is that we will store our custom WIM file, which
is just a bit larger than 100 Megabytes, on that partition. Choosing a size of 512 MB will ensure
sufficient disk space for additional tools.
P a g e | 29
&
Windows Native VHD Boot, Deployment Scenarios
Step 1 create Windows PE
The first step in the process is to create a special version of Windows PE. PE stands for preinstallation environment and is basically a minimal version of Windows specifically design for
deployment purposes. You might not know be aware of it, but we already make extensive use of
Windows PE when we install Windows 7 or Windows Server 2008 R2. When you startup the media
with Windows 7 on it, the installation environment that you see is a version of Windows PE. In the
case of Windows 7 and Server 2008 R2, The version of Windows PE is 3.0.
During this scenario we will make extensive use of a custom created Windows PE version. Use the
step-by-step below to start with the creation of that version.
Note! Make sure that you have The WINDOWS AIK (Windows Automated Installation Kit) installed.
See scenario 1 – step 1 for more details.
Open the “Deployment Tools Command Prompt” from the start menu and run it as an Administrator.
We’ll start of with creating the initial directory structure for Windows PE. Use the command below to
start with the process.
copype.cmd amd64 c:\winpe_X64
Note! This will create a 64 bits version of Windows PE that we will use to create our setup. If you
want to create a 32 bit version, replace “amd64” with “X86”.
Copype.cmd is a script that is installed with the Windows Automated Installation Kit and creates and
populates the appropriate directory structure for you. After running the command above it will
create the following directory structure.
\winpe_x64
\winpe_x64\ISO
\winpe_x64\mount
In the root of the “winpe_x64” folder a default Windows PE WIM file will be created with the
architecture we chose in the first command (in our case X64). This WIM file will serve as the base for
our custom Windows PE version.
Later in this document we will make use of the many command line tools available in Windows 7.
These tools are not all available in the default Windows PE version we’ve just created. We will need
to add them manually to be able to use them. We will first need to mount the WIM file so we can
add, edit or delete files as we see fit. Basically you can look at mounting a WIM file as attaching it to
a folder. When we open that folder we will see the content of the WIM file and we will be able to
alter the content. The tool that makes this possible is DISM (Deployment Image Servicing and
Management). This tool is new to Windows 7 and can handle most management tasks for
maintaining images (an image can be a WIM or VHD file).
P a g e | 30
&
Windows Native VHD Boot, Deployment Scenarios
In our setup we will mount the winpe.wim file that is stored in the “C:\winpe_x64” folder in the
folder “C:\winpe_x64\mount” .
Dism /Mount-Wim /WimFile:C:\winpe_x64\winpe.wim /index:1
/MountDir:C:\winpe_x64\mount
When we now open up Windows Explorer and browse to the folder “C:\winpe_x64\mount” we will
see the content of the WIM file that was mounted.
In the root of the mounted folder we will create a sub folder where we will copy the necessary tool
into. At a later stage we will use them to apply the WIM file to the VHD’s and to create and configure
the boot files. Use the following command line to execute the tasks:
mkdir c:\winpe_x64\mount\tools
xcopy "c:\Program Files\Windows AIK\Tools\x64" /e c:\winpe_X64\mount\tools
After copying all the required tools we will need to close the WIM file and save the changes. Again,
we will need to use the DISM tool to achieve our goal. Use the following command:
dism /unmount-wim /Mountdir:c:\winpe_x64\mount /commit
The parameter “/commit” takes care of storing the changes to the WIM file. All changes would be
lost if the parameter would not be omitted.
P a g e | 31
&
Windows Native VHD Boot, Deployment Scenarios
Step 2 create boot media
After creating our custom Windows PE version we are now ready to use it on a bootable device. We
could simply create an ISO file and burn it to a DVD, but since we need some flexibility and have to
consider the environment, we’ll use a USB thumbnail drive instead. In the steps below we will use a
16 Gigabyte “Kingston Data Traveler G2”, but most USB drives will do as long as they can be used as a
bootable device and contain sufficient storage capacity.
During the boot of Windows PE, the system will search for a “boot.wim” file located in the “Sources”
folder in the root of the boot device. So, to make use of our custom Windows PE version we first
have to rename it and place it in the appropriate folder structure.
Execute the following command to copy the “winpe.wim” to the sources folder and rename it.
copy c:\winpe_x64\winpe.wim c:\winpe_x64\ISO\sources\boot.wim
After successfully executing the copy command we are ready to prepare the USB device so it can be
used as a boot device. For this purpose the command-line tool “diskpart.exe” will be used.
Run the following commands in a command prompt.
Note! Use the “Run as administrator” option when running diskpart.
Diskpart
list disk
Running the command “List disk” will display all the available disks in the machine.
Figure 8 All Local Disks
P a g e | 32
&
Windows Native VHD Boot, Deployment Scenarios
In the example on the previous page, disk 5 is the disk that we will use (circled in red). The following
commands will select the appropriate disk, remove all the data and create the partition where the
files will be copied to.
*** These actions will destroy all data on the disk! ***
select
clean
create
active
format
assign
exit
disk 5
partition primary
quick fs=ntfs
letter=u
After creating the partition on the USB drive the custom Windows PE files that we created in step 1
of this scenario need to be copied to it. The PE files are stored in the “C:\winpe_x64\iso” folder and
will be copied using the “xcopy” command to the “U:\” drive.
xcopy c:\winpe_x64\iso\*.* /e u:\
That’s it! We now have a bootable USB drive with a custom Windows PE version. Proceed to the next
step to copy the WIM files to the drive.
P a g e | 33
&
Windows Native VHD Boot, Deployment Scenarios
Step 3 copy WIM files
In this step we need to copy the install.wim off the installation media (a DVD or an extracted ISO file)
onto the USB drive. Because we eventually want to create a dual boot configuration between
Windows 7 and Windows Server 2008 R2 we need the images from both sources. Nowadays with
image deployment all we need to do is copy a single file to the USB disk which contains all the bits for
the Windows installation. This file, “install.wim” is located in the sources folder of the installation
media. Because each file has the same name, two separate folders need to be created. In this
example scenario, W2K8R2-RC will be used for storing the Windows Server 2008 R2 file, while WIN7RC will be used for the Windows 7 file.
Use the following commands to create the folders and copy the install.wim files.
mkdir U:\WIM\W2K8R2-RC
mkdir U:\WIM\WIN7-RC
copy C:\W2K8R2-RC\Sources\install.wim U:\WIM\W2K8R2-RC
copy C:\WIN7-RC\Sources\Install.wim U:\WIM\WIN7-RC
Figure 9 WIM Folder Structure
P a g e | 34
&
Windows Native VHD Boot, Deployment Scenarios
Step 4 USB boot
Almost all systems are different when it comes to choosing the option to boot from USB. For example,
my HP laptop is an EliteBook 8530w and uses the F9 function key to enter the boot menu. One of my
home build machines has Gigabyte motherboard that has a completely different way of choosing the
appropriate USB device. So it really depends on your brand and model how you could enter the boot
menu.
Once you’ve figured it out, insert the custom made Windows PE bootable USB drive in an available
USB connector and select it from the boot menu. Wait a minute or so for Windows PE to complete its
boot sequence. When it’s finished you will see a command prompt with a blinking cursor awaiting
your commands.
Step 5 prepare the system
If you already installed Windows 7 or Windows Server 2008 R2 you might have noticed that Windows
creates a 100 megabyte partition at the beginning of the disk. On this partition, setup will copy and
configure the Windows boot files to prevent accidental damage. The partition will also not receive a
drive letter after the system has booted. Another advantage of creating such a partition during setup
is for use of “BitLocker Drive Encryption”. Systems will already be prepared for BitLocker usage and
do not require additional disk configuration afterwards.
The disk layout presented at the beginning of this scenario indicates a somewhat larger partition
than the default 100 Megabytes. This is necessary so we will be able to store the Windows PE WIM
file on it. Obviously we could always use the USB drive we created in the previous steps, but it’s far
more convenient to always have a local bootable copy of Windows PE, in case you need to recover or
alter the underlying system. Figure 10 gives an overview of the intended partition layout.
Figure 10 Partition Layout
P a g e | 35
&
Windows Native VHD Boot, Deployment Scenarios
Step 6 diskpart
It will most likely not be a surprise that we will be using the command-line tool “diskpart.exe” for
the partitioning of the disk. Again use the following “List disk” command to determine the
number of the disk that we want to target.
Diskpart
list disk
Once you have located the appropriate disk remember the disk number. In most systems it will be
disk number “0” but it could be a different number.
Note! Disk numbers always start with number 0 while partitions always start with 1.
In the example below we will create a 512 MB partition, make it bootable and assign drive letter
“C:\”.
*** These actions will destroy all data on the disk! ***
Select
clean
create
Active
Assign
format
disk 0
partition primary size=512
letter=c
fs=ntfs quick
At this point you might be thinking. “Hey wait a minute, I want “C:” to be the drive letter of my
operating system. Let me assure you, drive letters are not persistent once you exit Windows PE and
reboot into, for example, Windows 7. We could also assign drive letter “Z:” if we wanted to. Once the
system is rebooted the drive letters will automatically be assigned again. In the example above we
assign a drive letter only so we can access the partition.
After the bootable partition has been created, we now need to create a second partition that will
eventually be used to store the VHD files onto. In this example we are going to use the remaining
capacity of the disk, but you could assign a maximum partition size if you wanted to. While still in
diskpart enter the following commands to create the second partition and assign drive letter “D:\” to
it.
create partition primary
assign letter=d
format fs=ntfs quick
exit
Your disk layout will now look similar as displayed in figure 11.
P a g e | 36
&
Windows Native VHD Boot, Deployment Scenarios
Figure 11 New Partition Layout
Step 7 create the VHD's
After creating the partition layout the next step is to create the VHD files. Because Windows PE lacks
the graphical interface to create VHD files we will be using “diskpart.exe” again to create the VHD
manually. Diskpart in Windows 7 and Windows Server 2008 R2 is extended so it can also manage
VHD files. Disks are still disks even if they are virtual. Use the following command to create the VHD’s.
diskpart
create vdisk file="D:\WIN7RC.vhd" maximum=102400 type=expandable
create vdisk file="D:\W2K8R2RCRC.vhd" maximum=102400 type=expandable
The command-line above creates 2 VHD files, WIN7RC, that we will use for Windows 7 and
W2K8R2RC, that will be used to host Windows Server 2008 R2. The maximum size of the disk is 100
Gigabyte. The option “type=expandable” is the same as using a dynamic expanding disk in
Microsoft’s Virtual PC or Hyper-V. The VHD will grow dynamically when data is added to the disk. For
more information and options for creating VHD’s with diskpart use “help create vdisk”.
Before we can continue editing the VHD we first have to let diskpart “know” which disk we want to
use. Basically we have to select the disk and bring it online first. The “select” and “attach”
command will do just that.
select vdisk file="D:\WIN7RC.vhd"
attach vdisk
From this point on it will be like we just inserted a physical disk of a 100 Gigabyte that we can use
just as any other disk. For example, suppose we would do a “list disk” in diskpart we would see
an additional disk that we could edit just as a physical disk. The following commands will do just that.
First we will create a primary partition, format it and assign drive letter “V:\”.
create partition primary
format fs=ntfs quick
assign letter=v
We now have to use the same commands for creating the disk that will host Windows Server 2008
R2. Obviously we can’t use the same drive letter, so we will use “S:\” instead.
select vdisk file="D:\W2K8R2RC.vhd"
attach vdisk
create partition primary
P a g e | 37
&
Windows Native VHD Boot, Deployment Scenarios
format fs=ntfs quick
assign letter=s
exit
After creating the virtual disks for both operating systems the diskpart tool can be closed. Actually
the “exit” command above already takes care of that. The disk layout that we created now looks
like the figure 12.
Figure 12 Physical and mounted virtual disks
Step 8 Apply the WIM files to the VHD's
After creating the disks, the WIM files that we copied in step 3 must be applied to the virtual disks.
The tool for applying WIM files is “imagex.exe”. Windows PE normally does carry the
“imagex.exe” tool, but in step 1 we added the “Tools” folder that contains all the files needed for
working with WIM images.
Since a WIM image can contain more than one configuration within a single file we first need to
determine the correct index number. An index number is what is used to refer to a configuration
within the WIM file. This configuration is also named a Stock Unit or SKU for short. Specifically for
Windows 7 it’s important to get the correct SKU, because only Windows 7 Ultimate and Enterprise
can be used for Windows Native VHD boot. In this scenario we will use the Windows 7 Ultimate
Edition SKU, but we first need to locate the index number within the WIM file. To accomplish this
task we will be using “imagex.exe” with the info parameter. Run the following commands.
cd \tools
imagex.exe /info E:\WIM\WIN7-RC\Install.wim
The output will generate an overview on the content of the WIM file in XML format. The first
information we will need to locate is the name of the Windows 7 SKU. Locate the following line.
<NAME>Windows 7 ULTIMATE</NAME>
After you find the Windows 7 Ultimate SKU, you need to scroll up and locate the index number. In
my case it’s index number 4. Search for the following line, where 4 is a variable number.
<IMAGE INDEX="4">
Remember the index number above, we will use it later on as a reference when applying the content
of the WIM file to the VHD.
P a g e | 38
&
Windows Native VHD Boot, Deployment Scenarios
The next step is to apply the Windows 7 Ultimate SKU to the WIN7RC VHD file that we created in
step 7. Use the following command to apply the correct Windows edition from the WIM file to the
virtual disk.
imagex.exe /apply E:\WIM\WIN7-RC\Install.wim 4 V:\
The process can take a few minutes to complete. Let it finish before continuing to the next step.
Now that we have Windows 7 applied on the VHD, we also still need to apply Windows Server 2008
R2 to the VHD. Therefore we will run “imagex.exe” with the “/info” switch against the Windows
Server 2008 R2 WIM file first and select the appropriate SKU. In this scenario we will select the
standard version of Windows Sever. Run the commands below to accomplish this task.
imagex.exe /info E:\WIM\W2K8R2-RC\Install.wim
imagex.exe /apply E:\WIM\W2K8R2-RC\Install.wim 1 S:\
The process can take a few minutes to complete. Let it finish before continuing to the next step.
Note! Instead of using the default “install.wim” file from the installation media you could also use a
custom made WIM file.
Step 9 boot configuration data store
After successfully creating the virtual disk and applying the operating systems on them it’s now time
to configure the boot files. Normally when you install Windows on the disk, setup takes care of this
step, but since we are manually building our system, there are no files yet that the system can use to
start the machine. The primary file that we will be working with is the BCD, or “Boot Configuration
Data” store which is basically the successor to the boot.ini file. We could create the store and enter
every line manually, but that’s too much work and leaves a lot of room for errors. Lucky for us there’s
a tool available that takes care of most of the work for us. In this scenario, “BCDBoot.exe” is your
friend. It will copy a default BCD store to your disk and make the necessary configuration changes.
The only thing we need to do is point it to a copy of Windows and let it know where to copy the files
to. Use the following command-line to copy the boot files from the Windows 7 VHD file to “C:\”
which will be our partition for hosting the boot files.
bcdboot.exe v:\windows /s c:
If the system would be restarted at this point the operating system that was used to copy the boot
files from would automatically be started. To validate this, we will use the default tool for editing the
BCD store, “BCDEdit.exe”.
BCDEdit.exe -store c:\Boot\BCD /emum /v
The output will be similar as in figure 13 on the next page.
P a g e | 39
&
Windows Native VHD Boot, Deployment Scenarios
Figure 13 The default BCD
P a g e | 40
&
Windows Native VHD Boot, Deployment Scenarios
Step 10 Windows Server 2008 R2 VHD
In the overview on the previous page Windows Server 2008 R2 is still missing. Since we already
created a default store in step 9, we can start adding additional entries to support booting Windows
Server 2008 R2. We will be using “BCDEdit.exe” again to complete this task. The first step we will
need to take is make a copy of the default boot entry (The one for Windows 7). Use the command
below to copy the default entry. The” /d” parameter will allow a custom description to the new
entry.
BCDEdit.exe -store c:\Boot\BCD /copy {24761cb1-3f82-11de-8235-0003ffa37a4a}
/d "Windows Server 2008 R2"
The result of this command will generate a GUID that must be used as a reference to the created
boot entry. There are now two items that need to be changed before booting Windows Server 2008
R2. The “OSDevice” and “Device” options. With “BCDEdit.exe” we need to point the entries to
the VHD we created earlier in the process.
Note! The option “Device” references to the location where the OSLoader is located (winload.exe),
“OSDevice” points to the location where the operating system itself resides.
BCDEdit.exe -store c:\Boot\BCD /set {4a453550-3f84-11de-8235-0003ffa37a4a}
device VHD=[D:]\W2K8R2RC.vhd
BCDEdit.exe -store c:\Boot\BCD /set {4a453550-3f84-11de-8235-0003ffa37a4a}
osdevice VHD=[D:]\W2K8R2RC.vhd
Note! Instead of using the option [D:] we could also use [Locate] so the boot manager would search
all drives for the VHD. In this case the first match found would be used.
If we were to execute the command “BCDEdit.exe -store c:\Boot\BCD /emum /v” we
would now see the Windows Server 2008 R2 entry appear (figure 14).
Figure 14 BCD entry for Windows Server 2008 R2
P a g e | 41
&
Windows Native VHD Boot, Deployment Scenarios
Step 11 add Windows PE
One of the requirements for this scenario was to also have the custom made Windows PE locally
available on the disk. The WIM file that we created earlier must be copied to the smaller partition so
it will remain hidden during the normal operation of Windows 7 or Windows 2008 R2. Execute the
following commands to copy the required files to the disk.
copy e:\sources\boot.wim c:\Boot\winpe.wim
copy e:\boot\boot.sdi c:\boot\boot.sdi
The file “boot.sdi” will be used in the next paragraph to create a RAMDISK drive.
Step 12 create the RAMDISK
To be able to alter the disk layout of the system disk, the operating system that starts from that disk
must be loaded into memory. This way no handles to the locale disk remain open and the disk can be
edited freely. Windows PE architecture allows it to be loaded into a RAMDISK and execute its
operations from there. However, Windows PE doesn’t do this by default, we need to configure the
boot sequence to enable this functionality.
To make sure that we don’t already have a RAMDISK entry available in the boot configuration data
store, we need to run the “BCDEdit.exe” tool with the “all” parameter.
BCDEdit.exe -store c:\Boot\BCD /enum all /v
The “all” parameter will show all entries including those that are normally hidden. If you followed
the steps above you’ll notice that there’s no reference to a RAMDISK available and we will need to
configure the BCD manually. Just use the following command to create the reference to the RAMDISK.
BCDEdit.exe -store c:\Boot\BCD /create {ramdiskoptions}
If the above command ran successfully the RAMDISK option will now be available in the BCD store.
Execute the “BCDedit.exe” command again to locate the entry.
"BCDEdit.exe -store c:\Boot\BCD /enum all /v"
Figure 15 RAMDISK options
As you can see in figure 15, the identifier to the RAMDISK option is really a GUID. This GUID is our
reference when we want to alter the other required options.
P a g e | 42
&
Windows Native VHD Boot, Deployment Scenarios
Now that we have created the RAMDISK options entry and identified the GUID, the other settings can
be created. We will need a description, which obviously describes the entry. The text that you enter
here will eventually be displayed in the boot menu as an option you can choose to boot from. The
option “ramdisksdidevice” is the partition letter where the binary file that creates the RAMDISK
resides. The last entry, “ramdisksdipath” points to the binary file itself. Use the following
commands to alter the BCD.
BCDEdit.exe -store c:\Boot\BCD /set {ae5534e0-a924-b836-758539a3ee3a}
description "Windows PE"
BCDEdit.exe -store c:\Boot\BCD /set {ae5534e0-a924-b836-758539a3ee3a}
ramdisksdidevice partition=C:
BCDEdit.exe -store c:\Boot\BCD /set {ae5534e0-a924-b836-758539a3ee3a}
ramdisksdipath \boot\boot.sdi
A final enumeration of the BCD store will display our custom made RAMDISK option.
Figure 16 Custom made RAMDISK Options
P a g e | 43
&
Windows Native VHD Boot, Deployment Scenarios
Step 13 create the Windows PE entry
In the previous step we created a RAMDISK to support our custom made Windows PE version. In this
step we will be creating a new entry to be able to boot that Windows PE version of the hard disk and
into memory. We could manually create all the required entries, but it far easier to simply copy a
previously created boot entry and use that as a starting point. Use the following command to copy
the Windows 7 boot entry.
BCDEdit.exe -store c:\Boot\BCD /copy {24761cb1-3f82-11de-8235-0003ffa37a4a}
/d "Windows PE"
You may have noticed that we did the exact same thing as when we created an entry for booting a
VHD in step 10. Just as before, we will be using the GUID as a reference. As small alteration to the
previous entries for Windows 7 or Windows Server 2008 R2 is that we need to "tell" it to first copy
the file to memory and boot from there. Execute the following commands to create our Windows PE
entry in the boot configuration data store.
BCDEdit.exe -store c:\Boot\BCD /set {76247ac0-3f8f-11de-8235-0003ffa37a4a}
device ramdisk=[C:]\boot\winpe.wim,{ae5534e0-a924-b836-758539a3ee3a}
BCDEdit.exe -store c:\Boot\BCD /set {76247ac0-3f8f-11de-8235-0003ffa37a4a}
osdevice ramdisk=[C:]\boot\winpe.wim,{ae5534e0-a924-b836-758539a3ee3a}
BCDEdit.exe -store c:\Boot\BCD /set {76247ac0-3f8f-11de-8235-0003ffa37a4a}
winpe yes
BCDEdit.exe -store c:\Boot\BCD /set {76247ac0-3f8f-11de-8235-0003ffa37a4a}
detecthal on
The GUID that immediately follows the comma is the GUID to the RAMDISK that we created in Step
12. This way we tell the Windows PE version to first copy the WIM file into memory and boot from
there.
This was the last step we needed to take to achieve our goal that we set out in the beginning of this
scenario. No operating system is installed on the local disk and we can boot Windows PE from the
local hard drive into memory.
P a g e | 44
&
Windows Native VHD Boot, Deployment Scenarios
Step 14 thin provisioning for native VHD boot
Thin provisioning for Windows Native VHD boot basically means that you handout more storage
capacity than is actually physical available. During boot time a VHD will be expanded to its full size to
guarantee the available space and to prevent data corruption. If the system can't allocate the entire
space from the physical disk that the VHD resides on it will generate a stop error and prevent the
system from booting. Now, with a single VHD this will normally not be an issue, but suppose you
have a system that has multiple VHD and you just don't want to use all the space all at once.
Coincidently as is the case in this scenario. That's where we can use thin provisioning for Windows
Native VHD boot.
Figure 17 Default behavior of native VHD Boot
As you can see in figure 17, the disk will normally expand to its full size after it has booted the
operating system within the VHD. As a comparison, the Windows Server VHD disk that you see in
figure 17 only has a size of around 5 Gigabyte.
Just suppose a situation where the Windows 7 VHD grows to a size of 30 GB and the underlying
physical disk has a total size of 120 Gigabyte. In theory this would leave sufficient disk space. After all,
30G + 5G = 35G would leave 85 GB remaining. Unfortunately this is not the case with the default
behavior of Windows Native VHD boot. Normally the virtual disk would expand the Windows 2008
R2 VHD to its full size of a 100 GB once it would be selected to start up. Now let’s do that calculation
again. 100G for Windows Server 2008 R2 + 30 GB for the Windows 7 VHD = 130 GB total. In this case,
the boot of Windows Server 2008 R2 would generate a stop error and prevent you from booting the
system because it lacks 10 GB and can’t expand to its full size.
Note! For increased performance the pagefile will be placed outsize the VHD. Use the following
calculation to determine the maximum size of a VHD when only one VHD is used on the system.
MaxVHD =Size physical Disk - size Pagefile
In the scenario with multiple VHD on the same disk where disk space is an issue we can prevent the
situation that I described above by using thin provisioning for Windows Native VHD boot. A simple
registry entry will prevent the disk from expanding to its full size. Open the registry editor, browse to
the location that’s displayed below and alter the value to “4”.
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\FsDepends\Parameters]
"VirtualDiskExpandOnMount"=dword:00000004
Figure 18 Changes after applying the registry key
P a g e | 45
&
Windows Native VHD Boot, Deployment Scenarios
As you can see in figure 18, the disk will not be expanded to its full size anymore after adding the
registry setting and rebooting the system. This way we can make more efficient use of the underlying
storage.
P a g e | 46
&
Windows Native VHD Boot, Deployment Scenarios
Step 15 apply thin provisioning during Windows PE
In some cases it can be beneficial to apply the previously mentioned thin provisioning option before
the first boot of the operating system. To achieve this requirement, the setting must be applied when
Windows PE is still operational, as is the case in our scenario. We will need to mount the registry
from the operating system residing on the VHD, apply the appropriate setting and save the registry
file. Use the following steps to apply the thin provisioning setting to the previously created Windows
7 VHD.





Type "Regedit" in the Windows PE command prompt.
Select the “HKEY_LOCAL_MACHINE” hive.
Choose "file" - "Load Hive" from the menu.
Browse to the appropriate drive letter. In our example this would be drive "V:"
Select the file "SYSTEM" located in the folder: "V:\Windows\System32\Config".
Figure 19 Select the system file







Select "Open" in the menu.
Type "TEMP" in the "Load Hive" dialog screen.
Browse to the key:
"HKEY_LOCAL_MACHINE\TEMP\ControlSet001\services\FsDepends\Parameters".
Change the setting "VirtualDiskExpandOnMount" to a value of "4".
Select "TEMP" on the left just underneath "HKEY_LOCAL_MACHINE".
Click "File" on the menu and choose the option "Unload Hive".
Select "Yes" In the "Confirm Unload Hive" screen. This will save the changes we just created.
We can now repeat the same steps to change the registry value for the Windows Server 2008 R2 VHD.
P a g e | 47
&
Windows Native VHD Boot, Deployment Scenarios
Step 16 detach the VHD's
To prevent corruption we must detach the VHD gracefully before rebooting the system. Just as
attaching, detaching must also be done with the “diskpart.exe” tool. Use the following
commands to detach the Windows 7 & Windows Server 2008 R2 VHD’s.
diskpart
select vdisk file="D:\WIN7RC.vhd"
detach vdisk
Select vdisk file="D:\W2K8R2RC.vhd"
detach vdisk
exit
Step 17 reboot Windows PE
As a final step before installing the operating systems that we applied to the VHD’s we need to
reboot the machine. Type “exit” in the command prompt and remove the USB device. After the
machine reboots select Windows 7 and continue the installation. Once it has finished, configure the
system the way you want it to be. Do the exact same thing for the Windows Server 2008 R2 virtual
disk. If you’re satisfied with the result of both configurations reboot back into Windows PE and
continue with the next step.
P a g e | 48
&
Windows Native VHD Boot, Deployment Scenarios
Step 18 creating differencing disks
Wouldn’t it be a great feature if you could restore an operating system to its default configuration
within a couple of minutes? This can easily be achieved with the help of VHD differencing disks.
Differencing disk in Hyper-V or Microsoft Virtual PC are in essence the same as with Windows Native
VHD boot. The disk has a parent – child relationship where all new blocks are written to the child disk,
leaving the parent disk to its preconfigured state. This enables the possibility of a quick restore by
replacing the differencing disk and re-enabling the parent – child relationship. In our scenario we
have installed and configured Windows 7 and Windows Server 2008 R2 in the previous steps. Now
that we have rebooted back into Windows PE we can start creating the differencing disks. Essentially
we will use the same steps as before, create two VHD’s, one for Windows 7 and one for Windows
Server 2008 R2 and setup the parent – child relationship. As the final step we will need to alter the
boot configuration data store again to be able to boot off the differencing disks. Use the following
steps to create the VHD’s and setup the relationship.
diskpart
create vdisk file="D:\WIN7RC_Diff0.vhd" parent="D:\WIN7RC.vhd"
create vdisk file="D:\W2K8R2RCRC_Diff0.vhd" "D:\W2K8R2RCRC.vhd"
exit
This takes care of creating the VHD’s and setting up the parent – child relationship. To be able to
boot to the differencing disk, the BCD store will need to be updated to reflect our intended changes.
Use the commands below to update the BCD store.
Note! The GUID below could be different on your system. Use “bcdedit.exe /enum all /v”
command to view the appropriate GUID.
Windows 7
BCDEdit.exe -store c:\Boot\BCD /set {24761cb1-3f82-11de-8235-0003ffa37a4a}
device VHD=[D:]\W2K8R2RC_Diff0.vhd
BCDEdit.exe -store c:\Boot\BCD /set {24761cb1-3f82-11de-8235-0003ffa37a4a}
osdevice VHD=[D:]\W2K8R2RC_Diff0.vhd
Windows Server 2008
BCDEdit.exe -store c:\Boot\BCD /set {4a453550-3f84-11de-8235-0003ffa37a4a}
device VHD=[D:]\W2K8R2RC_Diff0.vhd
BCDEdit.exe -store c:\Boot\BCD /set {4a453550-3f84-11de-8235-0003ffa37a4a}
osdevice VHD=[D:]\W2K8R2RC_Diff0.vhd
This concludes all steps required for this advanced deployment scenario.
P a g e | 49
&
Windows Native VHD Boot, Deployment Scenarios
Final word
With the addition of Windows Native VHD boot you will have a powerful new tool available that will
enable you to have a single file format that can be used in either a virtual or physical environment.
With the scenarios described in this document I hope to have given you insight into this new piece of
excellent technology and you will start to enjoy it as I have enjoyed writing this step-by-step guide. If
you have any questions, remarks or suggestions about this document or in general please don’t
hesitate to contact me.
Michael Waterman
michael.waterman@microsoft.com
P a g e | 50
&