The Enterprise and Ultimate editions of Windows 7, as well as
all editions of Windows Server 2008 R2, can be configured to boot from
a virtual hard disk file (VHD). The VHD file is stored on the hard
disk as a normal file, and the deployed operating system is contained
within this file. In essence, the VHD file serves as a container
located on the hard disk. The benefit of deploying an operating system
to a container is that the container can be moved to another platform
if you need to move it. For example, to transfer a fully deployed
computer from one host to another, boot using the Windows PE
environment and copy the VHD file to a new location. The only step
required to prepare the new location is to edit the boot configuration
file to point to the operating system on the VHD. You perform the task
of boot environment configuration in the practice exercise at the end
of this lesson.
Another benefit of deploying to VHD rather than
consuming an entire disk partition with an installation of Windows 7
is that it simplifies the process of deploying Windows 7 in a multiple
operating system boot configuration. For example, you could configure
two VHD files, one of which is configured and optimized to run one set
of applications, and another that you have configured and optimized to
run a separate set of applications.
You can create VHD files using the Diskpart.exe utility and
through the Create And Attach Virtual Hard Disk dialog box available
from the Disk Management Console. This dialog box is shown in Figure 1. When you create a VHD on a
hard disk that you intend to use as the host for an operating system,
you choose between dynamically expanding and fixed-size disk types. A
dynamically expanding virtual hard disk increases size as needed until
it consumes the volume that hosts it. Dynamically expanding virtual
hard disks become increasingly fragmented over time. Fixed-size disks
use a fixed amount of space and are less likely to become fragmented,
which increases overall performance. The drawback to fixed-size disks
is that you cannot expand them if the need arises. It is also possible
to use Diskpart.exe to configure a boot from VHD on differencing
disks. Differencing disks allow you to discard changes to the
operating system at a later time.
You can deploy an operating system to an existing VHD file using
the traditional installation method or by mounting the VHD file and
using the ImageX.exe utility to apply an image to the VHD file. You
use this second method in the practice exercise at the end of this
lesson. You can also obtain a utility that converts files in Windows
Imaging Format (WIM) directly to VHD files, although Microsoft does
not directly support this method.
You can deploy fully prepared VHD files from Windows
Deployment Services running on computers with the Windows Server 2008
R2 operating system. This allows VHD files to be deployed directly to
hard disk drives through a multicast transmission.
A native VHD boot has the following limitations:
-
Can be used only for Enterprise and Ultimate editions of
Windows 7 and Windows Server 2008 R2.
-
A maximum of 512 VHD files can be attached
concurrently.
-
Operating system hibernation is not supported, although
sleep mode is supported.
-
VHD files cannot be nested.
-
BitLocker cannot be used to encrypt the host volume used for
native VHD boot. BitLocker cannot be used on volumes hosted inside
a VHD.
-
The parent volume of the VHD cannot be configured as a
dynamic disk.
-
The attached VHD volume cannot be configured as a dynamic
disk.
Exam Tip
Remember which editions of Windows 7 can use the boot from VHD
functionality. Remember which edition of Windows 7 includes four
virtual licenses.
Practice: Preparing Boot from VHD
You can install the Windows 7 operating system so that it
boots from a VHD file that is installed on physical hardware. This
method has a benefit of making the operating system more
portable.
EXERCISE 1 Preparing for and
Installing a VHD Boot
In this exercise, you prepare a computer for a VHD
installation of Windows 7. Only the Enterprise and Ultimate editions
of Windows 7 allow you to perform an installation to a VHD file on
physical hardware. To perform this practice, ensure that your
computer running Windows 7 has at least 20 GB of free hard disk
space. You need to have access to ImageX.exe, which is part of the
Windows AIK tools, to complete this practice.
-
Log on to computer WKSTN1.
-
Open an elevated command prompt and copy the file
Install.wim, which is located in the sources directory of the
Windows 7 installation media to the directory c:\wim-store.
Also, copy the ImageX.exe utility from the Windows AIK directory
to the c:\wim-store folder.
-
Start diskpart by entering the command diskpart.
-
At the diskpart prompt, type list
disk to list the current disks on the
computer.
-
At the diskpart prompt, type create vdisk file=c:\win7vhd.vhd maximum=20000
type=fixed.
-
At the diskpart prompt, type select vdisk
file=c:\win7vhd.vhd.
-
At the diskpart prompt, type attach vdisk, which attaches the
selected disk.
-
At the diskpart prompt, type list
disk to verify that the disk has been created. On
your screen, you should see something like the text shown in
Figure 2.
-
Select the disk that you created using the select disk X command where X is the
identifier of the newly created virtual hard disk.
-
Issue the create partition
primary command to create a partition on the selected
virtual hard disk.
-
Issue the select partition
1 command to select the partition, and then issue the
active command to mark the
partition as active.
-
Issue the command format fs=ntfs
quick. When this command completes execution, issue
the command assign. A pop-up
window that details the drive letter assigned to the VHD file is
displayed. Close this dialog box, and then in the command
prompt, type exit to leave
the diskpart utility.
-
Use the command dism.exe
/get-wiminfo /wimfile:c:\wim-store\install.wim to
determine the index assigned to the Windows 7 Ultimate or
Windows 7 Enterprise operating system file image.
-
Use the command c:\wim-store\imagex.exe /apply
c:\wim-store\install.wim /check X e:\ where e:\ is
the volume address label that was assigned to the VHD file when
you used diskpart in step 12, and X is the index number of the
operating system you discovered in step 13, as shown in Figure 3.
-
Enter the command diskpart to start the diskpart
utility.
-
Enter the command select vdisk
file=c:\win7vhd.vhd, and when this command completes,
enter the command detach
vdisk. This detaches the virtual disk from the drive
where you applied it. Type exit to leave the diskpart
utility.
-
Create a copy of the current boot loader entry by entering
the command bcdedit /copy {current} /d
“VHD Boot”. Make a note of the GUID that is
generated, as highlighted in Figure 4. You should use the
command prompt’s ability to mark and copy text to copy this to
the buffer.
-
Enter the command bcdedit /set
{6f159079-ab06-11de-84cb-d945bc04a2b7} device
vhd=[c:]\win7vhd.vhd where
{6f159079-ab06-11de-84cb-d945bc04a2b7} is the unique GUID
assigned on your computer.
-
Enter the command bcdedit /set
{6f159079-ab06-11de-84cb-d945bc04a2b7} osdevice
vhd=[c:]\win7vhd.vhd where
{6f159079-ab06-11de-84cb-d945bc04a2b7} is the unique GUID
assigned on your computer. This command differs from the one in
step 18 in that you use the osdevice
parameter instead of the device
parameter.
-
Enter the command bcdedit /set
{6f159079-ab06-11de-84cb-d945bc04a2b7} detecthal
on.
-
Type bcdedit /set
{6f159079-ab06-11de-84cb-d945bc04a2b7} description “Boot from
VHD”.
-
You can now reboot into the operating system deployed to
the VHD file.