Boot To VHD – Configuring, Creating a Reusable Trial version image and more….

 

With the introduction of Boot To VHD in Windows 7 and Windows 2008 R2, we have an excellent way of cleanly booting to multiple Windows OS versions (Windows 7 and later only). Traditional dual-boot scenarios required us to load different version of Windows in a specific order to ensure we could dual-boot properly. Even worse, if something caused a system wide failure, dual-boot systems are more difficult to troubleshoot and restore.

Boot to VHD cleans all of this up, though it does restrict us to using certain Windows versions and, unlike dual-boot, does not allow us to use non-Windows OSes in the mix (unless you are dual-booting *and* using Boot to VHD in which cas4e, you are entirely on your own!)

While there are many articles out there on how to get started with Boot to VHD, I would like to provide some additional information to help you set up images that can be re-used. And I want to show you a way to use a trial version to do this!Perhaps you do a lot of testing in a lab, or maybe you are a teacher or instructor that is setting up a large number of identical workstations. Using a few of the built in tools for Windows, it is very easy to create re-usable images for these scenarios. In a nutshell, this is what we will be doing in this article

Create the reference Virtual Machine/VHD

Create a VHD file

Create a new Virtual Machine

Attach VHD file

Install OS/Patch

Install Applications/Patch

Package the reference Virtual Machine/VHD

Sysprep

.ZIP or .RAR (optional)

Make copies of the VHD file

Configure Boot to VHD

Copy file to workstation

Extract (optional)

Use BCDEIT or BCDBOOT to configure Boot to VHD

Test!

Here we go!

Preparation

You will need access to a Windows Server 2008 R2 or Windows Server 2012 Server with the Hyper-V role enabled. You can use the CMD line to create VHD files or even create them in Disk Manager. However, the simplest way I have found to do this is to using Hyper-V in Windows Server. Since you will have to use this console at some point anyway for managing the virtual machine, it provides one stop shopping for everything we need.

Download Windows Server 2012 Trial here (get the .ISO version!)

You can use the same trial above as your re-usable server image, or you can download a trial of Windows 8 and use it as the re-usable trial

Download Windows 8 Enterprise Trial here (get the .ISO version!)

 

Creating the Virtual Hard Disk (VHD) file

You can use Hyper-V in Windows Server 2008 R2 or Windows Server 2012 to do this.

1) In the Hyper-V management console, create a new virtual hard drive using the wizard

image

2) Select the type of virtual hard disk - RecommendationUse a Dynamically Expanding VHD – Why? Much faster to create and smaller file size means less to copy onto individual workstations!

Fixed – This will create a VHD file of the same size you specify in the wizard. This takes longer to create because we are basically formatting the VHD file (the larger the allotted size, the longer it takes). Pros – Slightly better performance, and the VHD can be expanded (offline only) if you need more space.

Dynamically expanding – This will create a very small initial file that will expand to the maximum size you specify in the wizard. I recommend using a dynamic disk for our scenario as we will be copying it to multiple workstations. Pros - The smaller size means less copy time. Can be compacted to remove white space if you delete data from the VHD file.

 

image

3) Follow the rest of the wizard to select location to store the file (remember where you store it!) and the maximum capacity you need for the virtual hard drive.

Create a New Virtual Machine & Attach the VHD

Next we will create a new virtual machine and attach the VHD file we created above

1) In the Hyper-V management console, create a new virtual machine using the wizard

image

2) Follow the wizard to provide a name and storage location for the virtual machine (the storage location can be removed after we complete the process to get space back)

3) Specify the amount of RAM for the virtual machine

This is only important for this initial phase. I recommend using 2GB minimum for this part of the setup. If you have >4GB in the host where you are creating the Virtual Machine, use as much memory as you can to speed up the setup. Once we perform the actual Boot to VHD process, the VHD operating system will recognize the amount of RAM in the host system and adjust accordingly.

4) Configure networking – I recommend attaching to an existing virtual network so you can patch the system or install other components over the network.

5) Connect Virtual Hard Disk – Select “Use an existing virtual hard disk” and then browse to where you stored the VHD file above.

image

6) Attach Trial version .ISO – in the Preparation section above, you were instructed to download a .ISO image for Windows 2012 Server of Windows 8. Either one can be used depending on what you need to accomplish. Browse to the appropriate .ISO image

image

7) Complete the Wizard!

Start the Virtual Machine / Install Windows / Patch / Install Applications / Patch

Now that we have created a new Virtual machine, attached the VHD we created and configured a .ISO to load windows from, we just have to start the VM and load Windows.

image

Now we get to the hurry up and wait part. Once the virtual machine spins up, you will install Windows just as you would on a physical box including adding any Windows Features you want in the final image. You will want to go to Windows Update to patch Windows up to the current date as well. You will then install any applications you want to the image then patch those applications as well.

Recommendation – Don’t download install files to virtual machine – Anything you download directly to the virtual machine will increase the size of the VHD file. Instead, install applications and other components from network shares instead of downloading the installation files to the virtual machine.

Once you have completed this, head out to Windows Update one last time to make sure you have everything updated.

Once you have everything installed and patched, I recommend that you reboot the image one last time just to make sure all apps and updates have written everything to the registry and so we have a clean startup before we package the VHD.

 

Package the reference Virtual Machine/VHD

Now that we have a completely built Windows OS with everything we want installed, we are going to sun SYSPREP to create a distributable package that can be used for Boot to VHD.

1 ) On the virtual machine, run SYSPREP with administrative privileges

Windows 7/2008 R2 – Click Start, type CMD, right click CMD, select Run as Administrator

Windows 8/2012 – From the Start screen, type CMD, right click Command Prompt, select Run as Administrator (bottom of screen)

image

This will open a CMD prompt window and drop you at the c:\windows\system32 directory

 

2) Change to the \sysprep directory and run SYSPREP.EXE

image

This will open SYSPREP and allow you to select some options.

3) Select the following options for SYSPREP

System Cleanup Action:  Enter Out-of-Box Experience (OOBE)

Check the “Generalize” box

Shutdown Options:  Shutdown

image

When you click OK, SYSPREP will remove the current user profile, set Windows to run the Out-of-Box experience on startup (will ask for very basic information on startup), and best of all…..Stop the clock on the trial version!! How long SYSPREP takes is dependent on the speed of the host you are working on, and what applications you installed to Windows. Usually it takes no more than 5-10 minutes for SYSPREP to complete and shutdown the virtual machine.

Trial Versions

If you use a trial version of Windows, the SYSPREP process stops the clock on the data you perform the SYSPREP. Which means if you use a trial version to create the VHD file then immediately SYSPREP, you have almost the full duration of the trial left. if you make copies of the SYSPREP’d VHD, each of this will also have the remainder of the trial period left. This make for an excellent FREE resource to learn Windows or doing testing over an extended period of time.

 

Makin’ Copies

Once the virtual machine shuts down, you can store a master copy of the VHD file in safe location that you can make copies of to distribute. The key is to retain a master image that can be replicated to multiple systems. For our IT Camps that we deliver across the US, we compress the VHD file with WinZip or WinRAR and place the file on a USB memory stick. This helps the image fit in a smaller space and speeds up file copies.

Now that we have copies, it is a simple matter to configure Boot to VHD to use the VHD file.

 

Configure Boot to VHD

Almost there!   Most of the hard and time consuming stuff is complete. All we have to do now is copy the VHD file and do a few simple steps to complete the Boot to VHD process. But before we get there, lets review some system requirements for Boot to VHD.

Boot to VHD Host System Requirements

Boot to VHD can only be enabled on the following Windows Operating Systems:

Client – Windows 7 or later

Server - Windows Server 2008 R2 or later

Additional Restrictions:

Encryption – The drive where you will place the .VHD file you will boot from must not be encrypted. This includes all 3rd party encryption as well as Windows BitLocker. (in the case of Windows BitLocker enabled machines, attempting to configure Boot to VHD will trip BitLocker recovery and require you to enter your BitLocker Recovery key. This is a tedious process that you really don’t want to deal with….trust me!)

Hard Drive Space – Even though I recommend using Dynamic Expanding VHD drives, you must have enough free space on the host drive to allow for the VHD file to fully expand or Boot to VHD will fail to work (ie, if you created a 100GB Dynamic Expanding VHD, it may only take up 30GB of space after you have installed all applications and patches. Boot to VHD looks ahead to see if there is enough free space to fully expand. If not, then it fails with a “not enough space error”. So you must have at least 100GB *before* you copy the VHD file to the target machine.

The Final Stretch! – Configuring Boot to VHD

1) Copy the VHD file to the target machine

a) create the following folder on the target machine

     c:\vhd

b) copy your .VHD file to c:\vhd

2) Use Disk Management to Attach VHD and obtain drive letter -

Windows 7/2008 R2 – Click Start, type Computer, right click Computer, click Manage Computer

Windows 8/2012 - From the Start screen, type Computer, right click Computer, select Manage (bottom of screen)

image

This open the Computer Management Console. 

Navigate to Storage –> Disk Management

image

 

Right Click Disk Management, Select Attach VHD

Browse to C:\VHD, double click on the .VHD file you copied there (make sure the Read Only box is NOT selected), Click Ok

 

image

This will attaché the VHD and assign drive letters to any partitions that are in the VHD. You can identify the newly attached VHD file by the light blue icon next to the Disk # designation.

In my example below, I created a 20GB VHD file that I installed Windows 8 to. You will note that I have two partitions, a small System partition, and the remaining space in the main partition.

You will need to make note of the drive letter assigned to the LARGER partition (not the System Reserved partition). This will the partition where the \windows directory resides. You can confirming this using explorer by navigating to the drive letter and looking for the \windows directory

Important – Do not delete or modify any files!!!

 

image

Once you have confirmed the drive letter where the \windows directory resides you have to open another administrative CMD prompt to execute one final command and then we are done!

1 ) Open a CMD prompt with administrative privileges

Windows 7/2008 R2 – Click Start, type CMD, right click CMD, select Run as Administrator

Windows 8/2012 – From the Start screen, type CMD, right click Command Prompt, select Run as Administrator (bottom of screen)

Once you have the CMD prompt open, type the following -

bcdboot ?\:windows <do NOT press enter yet!!!>

You replace the  ?   with the drive letter you identified above. After you have comfirmed your drive letter and syntax, press Enter.

You should see – Boot files successfully created.

 

image

If you get ANY other message, the most likely cause is that you did not open the CMD prompt with Administrative privileges. Simply close the CMD prompt, re-open as an administrator and attempt the command again.

Reboot! And walk through Windows Setup

Once you receive the “successfully” message above, you are done!  All that is left to do is reboot your system and select the appropriate version of Windows to boot to.  By default, the newly added Boot to VHD will become the default Operating System. So if you simply reboot and walk away, it will reboot to the VHD file. You can of course change this by using MSCONFIG to set your preferred OS to be the default.

Removing Boot to VHD

Removing Boot to VHD is super simple.

1) If you are in your Boot to VHD operating system, restart your PC and select a different OS.

2) Open MSCONFIG, select the Boot Tab, highlight the Boot to VHD OS you wish to remove, click delete

image

This will remove the entry from the Operating System selection screen at bootup.

3) Navigate to where you stored the .VHD file used for Boot to VHD

Copy or move the file if you wish to save it

Delete the file to recover hard drive space

Done!   That simple!

 

Wrapping up Boot to VHD

One of my favorite things about Boot to VHD is that you are only constrained by disk space as far as the number of operating systems you can configure for Boot to VHD. A single 1 Terabyte drive can hold 10, 20, or more .VHD files that are all configured for Boot to VHD. All of them can be stored in the c:\VHD directory without fear of operating systems stepping on each other because they are all self contained in the respective VHD files.

If you are CAREFUL, you can even attach the other .VHD files to access data in the operating systems.

Each Boot to VHD image has full access to all hardware resources on the host PC. There is no virtualization layer that blocks access to Firewire, USB, etc. You have full hardware access.

Finally, it is possible to move the /VHD files back into Hyper-V, but there are some steps that have to take place and that I will leave for another blog post!

 

Cheers!