Scenario 3: Performing an Advanced Deployment of Native Boot VHDs

Applies To: Windows 7, Windows Server 2008 R2

In this scenario, you will use more advanced deployment and configuration tools that are included in Windows 7 and Windows Server 2008 R2. You will make extensive use of command-line tools and you will create a customized Windows PE image, which will serve as an installation platform (instead of the Boot.wim file used in Scenario 2). After you finish the steps in this scenario, you will have a computer that can boot to two VHDs in addition to Windows PE. The following is a summary of the steps that you will take to accomplish this:

  • Create a customized Windows PE image and boot into it from a USB flash drive to a client computer.

  • Create two partitions on the local disk of the client computer.

  • Copy the Windows PE image from the USB flash drive to the first partition on the client computer.

  • Edit the Windows PE image so that when it is selected, it is loaded into memory.

  • Create two VHDs on the second partition of the client computer to use as boot disks. No additional operating system will be installed on this drive.

  • Edit the boot configuration data (BCD) store so you can select Windows PE, Windows 7, or Windows Server 2008 R2 when the computer boots.

  • After the operating systems are installed, create and configure differencing VHDs.

To illustrate, Figure 7 represents the disk layout and placement of the VHDs of the resulting client computer.

Figure 7  VHD layout for the client computer

As you can see, the first partition is slightly larger than the default 100 MB partition that Windows 7 or Windows Server 2008 R2 creates. The reason for this is that you will store the custom .wim file, which is larger than 100 MB, on that partition. Choosing a size of 512 MB ensures that there is sufficient disk space for additional tools.

Scenario prerequisites

Before you proceed, ensure you have the following resources available:

  • A computer running Windows 7 Enterprise, Windows 7 Ultimate, or Windows Server 2008 R2.

  • The Windows Automated Installation Kit (Windows AIK) installed on your computer. If not, see Step 1 of Scenario 1: Configuring Native VHD Boot on a Single Computer.

  • The installation media for Windows 7 Enterprise, Windows 7 Ultimate, or Windows Server 2008 R2.

  • A computer on which to install the VHD.

  • A USB flash drive with a minimum of 10 GB free disk space.

Step 1: Create a customized Windows PE image

The first step is to create a custom version of Windows PE. You might not be aware, but you already use Windows PE when you install Windows 7 or Windows Server 2008 R2. When you start the installation, the environment that you see is a version of Windows PE. In the case of Windows 7 and Server 2008 R2, the version is 3.0.

To create a customized Windows PE image

  1. On the Start menu, in the Microsoft Windows AIK folder, right-click Deployment Tools Command Prompt, and then click Run as administrator.

  2. Create the initial directory structure for Windows PE by using Copype.cmd, a script that is installed with the Windows AIK. The following command creates the appropriate directory structure for a 64-bit version; if you want to create a 32-bit version, replace amd64 with x86.

    copype.cmd amd64 c:\winpe_x64
    

    Specifically, this command will create the following directory structure:

    \winpe_x64
    \winpe_x64\ISO
    \winpe_x64\mount
    

    In the root of the winpe_x64 folder, you will find a default Windows PE image (Winpe.wim) that has the architecture you used in the previous command (in this case x64). This file will serve as the base for the custom version of Windows PE that you will modify in the following steps.

  3. Later, when you configure the client computer, you will make use of many command-line tools. However, these tools are not all available in Winpe.wim by default. To add them manually, you need to mount the image so that you can add, edit, or delete files. (Mounting an image is basically attaching it to a folder. When you open that folder, you will see the data of the image and you can alter the data.) The tool that makes this possible is Deployment Image Servicing and Management (DISM). This tool is new to Windows 7 and Windows Server 2008 R2, and it can handle most management tasks for maintaining .wim and .vhd images. In this example, to mount the Winpe.wim file that is stored in the folder named C:\winpe_x64\mount, type:

    Dism /Mount-Wim /WimFile:C:\winpe_x64\winpe.wim /index:1 /MountDir:C:\winpe_x64\mount
    
  4. Optionally, you can browse to C:\winpe_x64\mount in Windows Explorer to see the content of image that you just mounted.

  5. In the root of C:\winpe_x64\mount, create a subfolder where you will copy the necessary tools. Later, you will use these tools to apply the Windows PE image to the VHDs and to create and configure the boot files. To run these tasks, type:

    mkdir c:\winpe_x64\mount\tools 
    xcopy "c:\Program Files\Windows AIK\Tools\x64" /e c:\winpe_x64\mount\tools
    
  6. Close the Winpe.wim, and then type the following command to save the changes by using DISM:

    dism /unmount-wim /Mountdir:c:\winpe_x64\mount /commit
    

Note

The /commit option stores the changes to Winpe.wim. All the changes would be lost if you omitted this parameter.

Step 2: Create bootable media

After creating a custom Windows PE image, you are ready to configure it on a bootable device. You could simply create an .iso file of the image and burn it to a DVD, but in this scenario we will use a USB flash drive, which provides flexibility. Most USB flash drives will work as long as they can be used as a bootable device and they contain sufficient storage capacity.

To create bootable media

  1. When you boot to a USB flash drive, the computer searches for a Boot.wim file that is located in the Sources folder in the root of the boot device. To copy Winpe.wim to the Sources folder and rename it as Boot.wim, type:

    copy c:\winpe_x64\winpe.wim c:\winpe_x64\ISO\sources\boot.wim
    
  2. You are now ready to use DiskPart to prepare the USB flash drive so it can be used as a boot device.. To start DiskPart and display all of the available disks on the computer, type:

    diskpart
    list disk
    

    Your output will look similar to Figure 8.

    Figure 8 Display of all local disks

  3. In this example, disk 5 is the USB flash drive (circled in red). The following commands will select this disk, remove all the data from it, and create the partition where the files will be copied.

Important

These actions will delete all data on the USB flash drive.

To perform these tasks, type:

    select disk 5 
    clean create partition primary active 
    format quick fs=ntfs 
    assign letter=u 
    exit
  1. After you create the partition on the USB flash drive, you need to copy the custom Windows PE files that you created in Step 1 to this partition. The files are stored in the C:\winpe_x64\iso folder. To copy these files to drive U, type:

    xcopy c:\winpe_x64\iso\*.* /e u:\
    

You now have a bootable USB flash drive that contains a custom Windows PE image.

Step 3: Copy the Windows image to the USB flash drive

In this step, you will copy the Windows image (Install.wim), which contains all the bits for the Windows installations, onto the USB flash drive. The Install.wim file is located in the Sources folder of the installation media (a DVD or an extracted .iso file). Because you want to create a dual boot configuration between Windows 7 and Windows Server 2008 R2, you need the Install.wim from both operating systems. You will create two folders to separate the files: a W2K8R2 folder to store the Install.wim for Windows Server 2008 R2, and a WIN7 folder to store the Install.wim for Windows 7.

To create the folders and copy the Install.wim files to them, type:

mkdir U:\WIM\W2K8R2 
mkdir U:\WIM\WIN7 
copy C:\W2K8R2\Sources\install.wim U:\WIM\W2K8R2 
copy C:\WIN7\Sources\Install.wim U:\WIM\WIN7

Step 4: Boot to the USB flash drive from the client computer

You are now ready to begin configuring the client computer. Computers are different when it comes to how to boot from a USB flash drive. For example, some laptops use the F9 function key to enter the boot menu, but other computers have completely different methods.

When you know how to boot to the USB flash drive on your client computer, insert the USB flash drive, boot the computer, and select the USB flash drive from the boot menu. When the boot sequence is finished, you will see a Command Prompt window with a blinking cursor awaiting your commands.

Step 5: Partition the disk on the client computer

If you have installed Windows 7 or Windows Server 2008 R2 in the past, you may have noticed that Windows setup created a 100 MB partition. This partition is where Windows setup copies and configures the boot files for the operating system to prevent accidental damage. The partition does not receive a drive letter after the computer has booted. Another advantage of creating such a partition is for those who want to use BitLocker Drive Encryption. Computers are already prepared for BitLocker, and they do not require additional disk configuration.

As discussed at the beginning of this document, you will create a somewhat larger partition than the default 100 MB partition to store the Windows PE image. You could use the USB flash drive that you created in the previous steps, but it is more convenient to have a local bootable copy of Windows PE, in case you need to recover or alter the underlying system. Figure 9 shows an overview of the intended partition layout.

Figure 9  Partition layout  

You will use the command-line tool DiskPart to partition the disk.

To partition the disk

  1. At an elevated command prompt, type diskpart, and then type the following command to determine the number of the disk that you want to target.

    list disk
    

    Locate the appropriate disk and remember the disk number. In most computers, it will be disk number 0, but this is not always the case.

Note

Disk numbers always start with number 0, while partitions always start with 1.

  1. Type the following commands to create a 512 MB partition, make it bootable, and assign drive letter C.

Important

These actions will delete all data on the hard disk drive.

    Select disk 0 
    clean 
    create partition primary size=512 
    Active 
    Assign letter=c 
    format fs=ntfs quick

Note

At this point you might be wondering why you assigned the drive letter C to this partition when you will want C to be the drive letter of the operating system. You can be assured that drive letters do not persist after you exit Windows PE and reboot into the operating system. You could have assigned drive letter Z because after the computer is rebooted, the drive letters are automatically assigned again.

  1. After you create the bootable partition, you need to create a second partition to store the VHD files. In this example, you will use the remaining capacity of the disk, but you could assign a maximum partition size. In DiskPart, type 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
    

    After partitioning the computer, your disk layout will look similar to Figure 10.

    Figure 10  New partition layout

Step 6: Create the VHDs

The next step is to create the VHD files. Because Windows PE does not have a UI to create VHD files (like Disk Management), you will again use DiskPart to create and configure the VHD manually.

To create the VHD

  1. In DiskPart, type the following command to create the VHDs:

    
    create vdisk file="D:\WIN7.vhd" maximum=102400 type=expandable 
    create vdisk file="D:\W2K8R2.vhd" maximum=102400 type=expandable
    

    This command creates two VHD files: WIN7.vhd (which you will use for Windows 7) and W2K8R2.vhd (which you will use for Windows Server 2008 R2). The type=expandable parameter specifies to create a dynamically expanding VHD so the VHDs will grow as data is added to them (with a maximum size of 100 GB). For more information and options for creating VHDs with DiskPart, see Create vdisk (https://go.microsoft.com/fwlink/?LinkId=205510).

  2. Before you can continue editing the VHD, you have to tell DiskPart which disk you want to use (by using the select command) and bring it online (by using the attach command). To perform these tasks, type:

    select vdisk file="D:\WIN7.vhd" 
    attach vdisk
    
  3. From this point, it will be like you inserted a 100 GB physical disk that you can treat it like any other physical disk. If you run the list disk command, you will see the additional disk. To create a primary partition on the VHD, format it, and assign drive letter V, type:

    create partition primary 
    format fs=ntfs quick 
    assign letter=v
    
  4. Now use the same commands to configure the VHD that will host Windows Server 2008 R2. You cannot use the same drive letter, so you will type S:

    select vdisk file="D:\W2K8R2.vhd" 
    attach vdisk 
    create partition primary
    format fs=ntfs quick 
    assign letter=s 
    
  5. With both VHDs created, (type exit) to close DiskPart.

The disk layout that you created now looks like Figure 11.

Figure 11  Physical disks and mounted VHDs (V and S)

Step 7: Apply the WIM files to the VHDs

After you create the VHDs, you need to apply the Install.wim files from Step 3 to the VHDs. The tool you will use is ImageX. Windows PE normally does not contain ImageX, but you added it to your Windows PE image with the Tools folder in Step 1.

Note

If you are a more advanced user, you could use a custom Windows image (.wim) file instead of using the Install.wim file from the installation media.

To apply the Install.wim to the VHDs

  1. Because a .wim image can contain more than one edition of Windows, you first need to determine the correct index number of the edition that you want to use. This is particularly important for Windows 7 because only Windows 7 Ultimate and Windows 7 Enterprise can be used for native VHD boot. To view the contents of the Install.wim, type the following commands:

    cd \tools 
    imagex /info E:\WIM\WIN7\Install.wim
    

    The output will display an overview of the Install.wim in XML format. To locate Windows 7 Ultimate, which is used in this scenario, find the following line:

    <NAME>Windows 7 ULTIMATE</NAME>
    
  2. After you locate this line, scroll up and locate the index number that is associated with it. Specifically, for Windows 7 Ultimate, you will see:

    <IMAGE INDEX="4">
    

    Remember this index number because you will use it in the next step.

  3. To apply the data from Windows 7 Ultimate to the WIN7.vhd file, type:

    imagex /apply E:\WIM\WIN7\Install.wim 4 V:\
    

    Let the process finish before you continue.

  4. Now you have applied Windows 7 Ultimate to WIN7.vhd, but you still need to apply Windows Server 2008 R2 to W2K8R2.vhd. Before you apply the Windows image, you will run ImageX again with the /info parameter to locate the appropriate index number. To view the output and then apply Windows Server 2008 R2 Standard (which has an index number of 1) to W2K8R2.vhd, run the following commands:

    imagex /info E:\WIM\W2K8R2\Install.wim 
    imagex /apply E:\WIM\W2K8R2\Install.wim 1 S:\
    

    Let the process finish before you continue to the next step.

Step 8: Configure the BCD store

Now that you have created the VHDs and applied the operating systems to them, you need to configure the files that are used to start the operating system (the boot files). Typically, when you install the Windows operating system on a computer, setup completes this step. However, because you are building this system, you will need to create and manually configure the boot files.

You will work with the boot configuration data (BCD) store by using two command line tools: BCDBoot and BCDEdit. You will use BCDBoot to copy a default BCD store to the hard disk drive and make the necessary configuration changes. You will use BCDEdit to edit the BCD store that you create.

To create a BCD store

  1. You need to point BCDBoot to a copy of the Windows operating system and tell it where to copy the files. To copy the boot files from the WIN7.vhd file to drive C, which will be the partition that hosts the boot files, type:

    bcdboot v:\windows /s c:
    
  2. If you start the computer at this point, the operating system that was used to copy the boot files from (Windows 7) would automatically start. To validate this, type the following BCDEdit command:

    BCDEdit -store c:\Boot\BCD /enum /v
    

    The output will be similar to Figure 12. You will see that the default value (the GUID) under Windows Boot Manager matches the value for the Windows 7 entry. Note or copy this GUID because you will use it in the following procedure.

    Figure 12  The default BCD

After you complete the previous procedure, a boot entry for Windows Server 2008 R2 is still missing. However, because you created a default store by using BCDBoot, you can add additional entries to it to support booting Windows Server 2008 R2. The following procedure shows how to use BCDEdit to complete this task.

To add a boot entry for Windows Server 2008 R2 to the BCD store

  1. Type the following command to make a copy of the default boot entry for Windows 7 (use the identifier GUID from the previous step). Optionally, you can use the /d parameter to specify a custom description for the new entry.

    BCDEdit -store c:\Boot\BCD /copy {24761cb1-3f82-11de-8235-0003ffa37a4a} /d "Windows Server 2008 R2"
    

    This command will generate a GUID, which you should note or copy. You will use it in the following steps to modify the entry.

  2. There are now two parameters that you need to change before you can boot Windows Server 2008 R2: OSDevice and Device. The Device parameter references the location where the OSLoader is located (Winload), and the OSDevice parameter references the location of the operating system. Type the following commands by using the GUID for the Windows Server 2008 R2 boot entry that you just created.

    BCDEdit -store c:\Boot\BCD /set {4a453550-3f84-11de-8235-0003ffa37a4a} device VHD=[D:]\W2K8R2.vhd
    BCDEdit -store c:\Boot\BCD /set {4a453550-3f84-11de-8235-0003ffa37a4a} osdevice VHD=[D:]\W2K8R2.vhd
    

Note

Instead of using [D:] in these two commands, you could use [Locate], in which case the Boot Manager will search all drives for the VHD and use the first match.

  1. Type the following command to view the new entry for Windows Server 2008 R2.

    BCDEdit -store c:\Boot\BCD /enum /v
    

    Figure 13 shows an example of the output.

Figure 13  New boot entry for Windows Server 2008 R2

Step 9: Add the Windows PE image to the client computer

One of the requirements for this scenario was to have the Windows PE image available locally on the physical hard disk drive. To configure this, you must copy the Winpe.wim file that you created earlier to the smaller partition. This way, it will remain hidden during the normal operations of Windows 7 or Windows Server 2008 R2. To copy the required files to the hard disk drive, type the following two commands:

copy e:\sources\boot.wim c:\Boot\winpe.wim 
copy e:\boot\boot.sdi c:\boot\boot.sdi

In the next step, you will use the Boot.sdi file to create a RAM disk. A RAM disk is essentially RAM that you configure to act as a disk. However, because the disk is made of RAM, its contents are lost when the computer is turned off.

Step 10: Create a RAM disk

Typically when you boot a computer, you cannot edit the boot disk because the files that are loaded from the boot disk are locked. Therefore, to alter the partition layout of the hard disk drive, the operating system that starts from the hard disk drive must be loaded into memory first. This way, no handles remain open and you can make changes to the hard disk drive as needed. Windows PE can be loaded into memory, which is called a RAM disk. However, this is not default behavior so you need to configure the boot sequence to enable this functionality. To create a RAM disk, use the following procedure.

To create a RAM disk

  1. To make sure that you do not already have a RAM disk entry available in the BCD store, run the following BCDEdit command:

    BCDEdit -store c:\Boot\BCD /enum all /v
    

    The all parameter displays all boot entries, including those that are normally hidden.

  2. If you followed the steps in this scenario, there will not be an entry for a RAM disk so you will need to manually configure the BCD. To create the entry for the RAM disk, type:

    BCDEdit -store c:\Boot\BCD /create {ramdiskoptions}
    
  3. If the previous command ran successfully, an entry for the RAM disk will now be available in the BCD store. To view the entry, type:

    BCDEdit -store c:\Boot\BCD /enum all /v
    

    Figure 14 displays output similar to what you should see. The identifier to the RAM disk entry is another GUID, and you will use this GUID to alter the boot entry.

    Figure 14  The entry for the RAM disk

  4. Now you can specify the following three settings to alter the boot entry:

    • Description. The text that you enter for the description will be displayed in the boot menu as an option that you can choose to boot from.

    • Ramdisksdidevice. This setting specifies the partition letter where the binary file that creates the RAM disk (Boot.sdi) resides.

    • Ramdisksdipath. This setting points to the binary file.

    To specify these settings, type the following three commands:

    BCDEdit -store c:\Boot\BCD /set {ae5534e0-a924-466c-b836-758539a3ee3a} description "Windows PE" 
    BCDEdit -store c:\Boot\BCD /set {ae5534e0-a924-466c-b836-758539a3ee3a} ramdisksdidevice partition=C: 
    BCDEdit -store c:\Boot\BCD /set {ae5534e0-a924-466c-b836-758539a3ee3a} ramdisksdipath \boot\boot.sdi
    

    Type the following command to display the custom options for the RAM disk entry:

    BCDEdit.exe -store c:\Boot\BCD /enum /v
    

    Figure 15 displays output similar to what you should see.

    Figure 15  Custom RAM disk settings

Step 11: Create the BCD entry for the Windows PE image

You will create a new BCD entry for the Windows PE image. This will enable you to boot Windows PE from the hard disk drive directly to the RAM disk that you created in the previous step.

To create a BCD entry for Windows PE

  1. You could manually create all the required entries, but it is easier to copy a previously created boot entry and use that as a starting point. To copy the boot entry for Windows 7, type:

    BCDEdit -store c:\Boot\BCD /copy {24761cb1-3f82-11de-8235-0003ffa37a4a} /d "Windows PE"
    
  2. You may have noticed that you ran the same command as the command that you used to create the Windows Server 2008 R2 boot entry. Just as before, you will use the GUID for this boot entry as a reference.

    To further modify the entry, type the following three commands. Note that there is one difference to the commands that you ran previously: you need to configure the Boot Loader to first copy the Winpe.wim file to the RAM disk, and then boot it from there. You accomplish this by using the GUID that immediately follows the comma (this is the GUID for the RAM disk that you created in the Step 10).

    BCDEdit -store c:\Boot\BCD /set {76247ac0-3f8f-11de-8235-0003ffa37a4a} device ramdisk=[C:]\boot\winpe.wim,{ae5534e0-a924-b836-758539a3ee3a} 
    BCDEdit -store c:\Boot\BCD /set {76247ac0-3f8f-11de-8235-0003ffa37a4a} osdevice ramdisk=[C:]\boot\winpe.wim,{ae5534e0-a924-b836-758539a3ee3a} 
    BCDEdit -store c:\Boot\BCD /set {76247ac0-3f8f-11de-8235-0003ffa37a4a} winpe yes 
    BCDEdit -store c:\Boot\BCD /set {76247ac0-3f8f-11de-8235-0003ffa37a4a} detecthal on
    

This was the last step you needed to achieve one of the primary goals of this scenario: no operating system is installed on the local hard disk drive and you can boot Windows PE from the local hard disk drive which will load directly into memory.

Step 12: Prevent the VHD from expanding to its full size

Note

You can skip this step if you are deploying fixed-size VHDs instead of dynamically expanding VHDs.

During boot time, a dynamically expanding VHD will expand to its full size to guarantee space on the computer and to prevent data corruption. If the computer cannot allocate sufficient space from the physical disk that the VHD resides on, it will generate a stop error message and prevent the operating system from booting.

When you have a single VHD configured on a computer (as in Scenario 1), this is typically not an issue. However, when you have multiple VHDs (as in this scenario), and you do not want to use all of the space at one time, you can prevent this expansion by adjusting a registry key. This is sometimes called “thin provisioning”.

In this step, you will learn how to configure this in two ways: after booting into the operating system, and from within Windows PE before the operating system has been booted (which is currently the case if you are following the steps in this scenario). Before we walk through the steps, the following example explains why you may want to consider preventing VHDs from expanding.

Imagine 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 GB. In theory, this would leave sufficient disk space. After all, 30 GB + 5 GB = 35 GB, so 85 GB would remain. Unfortunately, this is not the default behavior of the native VHD boot. Normally, the Windows Server 2008 R2 VHD would expand to a full size of a 100 GB when it is selected to start. This would require 130 GB of disk space (100 GB for Windows Server 2008 R2 + 30 GB for the Windows 7 VHD). In this case, booting Windows Server 2008 R2 would generate a stop error message and prevent you from booting the system because it lacks 10 GB, and it cannot expand to its full size.

Therefore, in scenarios where multiple VHDs reside on the same hard disk drive and disk space is an issue, you can prevent this behavior in two ways:

  • After the operating system has booted. For VHDs that you have already booted into, you can prevent this expansion by using Registry Editor. To do this, browse to the following location and change the value to 4:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\FsDepends\Parameters] "VirtualDiskExpandOnMount"=dword:00000004
    

    As you can see in Figure 16, the disk will expand to its full size after you restart the computer. This allows you to make more efficient use of the underlying storage space.

    Figure 16  Changes after applying the registry key

  • Before the operating system has booted. You can also configure this setting from within Windows PE when the operating system has not already been booted into. You need to mount the registry from the operating system that resides on the VHD, apply the appropriate setting, and then save the registry file. Use the following procedure to configure this functionality on your Windows 7 VHD.

To prevent the VHD from expanding by using Windows PE

  1. In the Windows PE command prompt, type Regedit.

  2. Click the HKEY_LOCAL_MACHINE hive.

  3. Click File, and then click Load Hive.

  4. Browse to the appropriate drive letter. In our example, this is V.

  5. In the V:\Windows\System32\Config folder, select the SYSTEM file (shown in Figure 17), and then click Open.

    Figure 17  The SYSTEM file

  6. In the Load Hive dialog box, type TEMP.

  7. Browse to the following key:

    HKEY_LOCAL_MACHINE\TEMP\ControlSet001\services\FsDepends\Parameters
    
  8. Change the VirtualDiskExpandOnMount setting to a value of 4.

  9. In the left pane under HKEY_LOCAL_MACHINE, click TEMP.

  10. Click the File menu, and then click Unload Hive.

  11. On the Confirm Unload Hive page, click Yes to save your changes.

  12. Repeat these steps to change the registry value for the VHD that hosts Windows Server 2008 R2.

Note

For increased performance during native VHD boot, Windows will place the paging file (Pagefile.sys) outside the VHD on the host volume. Therefore, when you only have a single VHD on a computer, you can use the following calculation to determine the maximum size that the VHD should be:
<Maximum size of the VHD> = <Size of the physical disk> - <Size of Pagefile.sys>

Step 13: Configure the operating systems in the VHDs

In this step, you will boot into the VHDs and finish configuring them.

To complete the configuration

  1. To prevent corruption, you should again detach the VHDs before restarting the computer. To detach both VHDs, type:

    
    diskpart 
    select vdisk file="D:\WIN7.vhd" 
    detach vdisk 
    select vdisk file="D:\W2K8R2.vhd" 
    detach vdisk 
    exit
    
  2. Type exit in the Command Prompt window and remove the USB flash drive.

  3. You are now ready to install the operating systems that you applied to the VHDs. Restart the computer, select Windows 7 from the boot menu, and continue the installation. When the installation has finished, configure the operating system as desired.

  4. Repeat the same process for the Windows Server 2008 R2 VHD (boot into the image and configure the operating system as appropriate).

  5. When you are satisfied with both configurations, boot back into Windows PE and continue with the next step.

Step 14: Create and configure differencing VHDs

By using differencing VHDs with native VHD boot, you can restore an operating system to its default configuration within a few minutes. Differencing VHDs with native VHD boot are the same identical to those you may have used with Hyper-V or Microsoft Virtual PC. The VHDs have a parent/child relationship where all new blocks are written to the child disk (the differencing VHD), leaving the parent disk in its preconfigured state. This enables you to quickly restore the operating system to its original state by replacing the differencing VHD and re-enabling the parent/child relationship.

In the previous steps, you installed and configured Windows 7 and Windows Server 2008 R2. Now that you have booted back into Windows PE, you can create the differencing VHDs. Essentially, you will follow the same steps that you performed previously: create two differencing VHDs, one for Windows 7 and one for Windows Server 2008 R2, and then alter the BCD store so that you can boot to the differencing VHDs.

To configure booting to a differencing VHD

  1. To create differencing VHDs that have a parent/child relationship with the VHDs you created previously, type:

    
    diskpart
    create vdisk file="D:\WIN7_Diff0.vhd" parent="D:\WIN7.vhd" 
    create vdisk file="D:\W2K8R2_Diff0.vhd" parent="D:\W2K8R2.vhd" 
    exit
    
  2. To boot to the differencing VHDs, you need to update the BCD store to reflect these intended changes. To do this, type the following commands, and use the GUIDs for the Windows 7 VHD boot entry and the Windows Server 2008 R2 VHD boot entry that you created in Steps 8 and 9. You can run the bcdedit /enum all /v command to view the appropriate GUIDs.

    • Windows 7

      BCDEdit -store c:\Boot\BCD /set {24761cb1-3f82-11de-8235-0003ffa37a4a} device VHD=[D:]\W2K8R2_Diff0.vhd
      BCDEdit -store c:\Boot\BCD /set {24761cb1-3f82-11de-8235-0003ffa37a4a} osdevice VHD=[D:]\W2K8R2_Diff0.vhd
      
    • Windows Server 2008 R2

      BCDEdit -store c:\Boot\BCD /set {4a453550-3f84-11de-8235-0003ffa37a4a} device VHD=[D:]\W2K8R2_Diff0.vhd
      BCDEdit -store c:\Boot\BCD /set {4a453550-3f84-11de-8235-0003ffa37a4a} osdevice VHD=[D:]\W2K8R2_Diff0.vhd
      

This concludes the steps that are required for this advanced deployment scenario.

Conclusion

With the addition of native VHD boot, you have a powerful new tool available that enables you to have a single file format that can be used in virtual and physical environments. Hopefully, the scenarios described in this document have provided enough insight so you can start enjoying the benefits of this technology.