Here's the situation: You are a Windows systems administrator who works from a Windows 7 or Windows 8 domain workstation. You need to test out some Windows Server 2012 features without touching any of your production machines. You also need to run Windows Server 2012 on physical hardware instead of as a virtual machine. What do you do?
- Purchase a new computer to run the Windows Server 2012 instance
- Configure your Windows workstation in a dual-boot configuration with Windows Server 2012
- Install Windows Server 2012 onto a VHD and boot your workstation u sing the VHD
In the context of today's 4sysops blog post, the correct answer is (C). 😉
The Native Boot to VHD technology included in Windows 7 and Windows 8 provides an excellent way to multi-boot a computer without the traditional hazards and inconveniences associated with physically installing multiple versions of Windows on the same hardware.
Similarly, the Boot to VHD capability works its magic in the absence of a hypervisor such as Hyper-V. Thus, we can boot a VHD-based operating system and access the host computer hardware directly.
Finally, we can back up and restore the entire configuration by working with a single file--the virtual hard disk (VHD) file!
The high-level overview for creating a Windows 8 VHD and booting from it is as follows:
- Create a VHD file and prepare it to receive an OS.
- Mount the Windows 8 DVD (or ISO file) on your host computer.
- Obtain ImageX.exe and use the utility to apply a Windows 8 image to the VHD file.
- Add the VHD-based Windows 8 installation to the host computer's boot menu.
We'll cover each overview step in detail right now.
Step #1: Create a VHD File ^
We can use the GUI Disk Management Microsoft Management Console (MMC) or the command-line diskpart tool to create the VHD file.
For instance, open Disk Management and click Action > Create VHD. This action invokes the Create and Attach Virtual Hard Disk dialog box, where you can define the VHD parameters. If you'd like, you can copy my settings as shown below.
Create a VHD by using the Disk Management console
Once you create and attach the VHD, be sure to initialize it and build a single, simple volume. The drive letter that Windows provides does not matter, although we need to remember the designation later in this procedure.
Step #2: Mount the Windows 8 DVD ^
This step is straightforward enough. If you don't have the physical Windows 8 media, you can use a number of third-party utilities to mount the ISO version of the DVD to your host computer's file system. For instance, I've had good luck with both of the following free tools:
Make a note of the drive letter assigned to the Windows 8 source media; you'll need that bit of info as well.
Step #3: Apply Windows 8 to the New VHD File ^
This is the only step that is a bit of a pain, only because you may have to download and install the huge Windows Assessment and Deployment Kit (ADK) for Windows 8. Why? Because the ImageX.exe tool that we need to complete this step is seemingly available only from within the Windows ADK.
Once you've installed that enormous toolset, you can extract ImageX.exe from the following path:
C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Deployment Tools\x86\DISM
If you plan to run ImageX on a 64-bit system, then check the amd64\DISM folder instead.
Now, open an elevated command prompt on your host computer, navigate to the folder that contains ImageX, and run the following statement to "install" Windows 8 from its source WIM file to your newly created VHD:
ImageX /apply d:\sources\install.wim 1 f:\
Here's an explanation of the syntax:
- /apply: This parameter "installs" a WIM image to a target
- d:\sources\install: This is the path to the Windows 8 source media. Of course, you may have a different drive letter in play
- 1: This is the WIM index number from the source media
- f:\: This is the root of our VHD file. Again, your drive letter might be different from mine
I show you the results of the above syntax in the next screenshot.
Use ImageX and BCDBoot to configure the VHD for booting
If you pop open Windows Explorer and browse to the root of your VHD file, you'll see what appears to be a standard installation of Windows 8. I show you this interface below.
A VHD can host a fully functional copy of Windows 8
Step #4: Add the VHD to the Host Computer's Boot Menu ^
The final step is pretty easy: to add the new VHD installation to our host computer's boot menu, run the following statement from your elevated command prompt:
Again, I showed you the syntax results in Step 3.
We can now restart the computer at test out the new configuration!
Testing it Out
During the first system startup with the new VHD present, you'll see the interface shown below.
The Windows 8 boot loader screen
Deciphering the entries on the new boot menu is pretty easy if you've installed Windows 7, Windows Server 2008 or Windows Server 2002. However, things can get (seemingly) hairy if your host PC runs Windows 8 and you attach another Windows 8 VHD.
As you can read in the above screenshiot, my current default installation is on "volume 4." This tells me, by default, that my VHD installation is on "volume 2," whatever that is. For now, go ahead and select your new installation and let the boot proceed.
As shown in in the next screenshot, you'll be taken through the traditional Windows 8 out of box experience (OOBE) steps as if you were setting up a new computer. Hardware detection, prompts to run Windows Update--the works.
A VHD Windows 8 installation works exactly the same as a hardware installation
Once you're logged in, your best bet to customize the Windows 8 boot configuration database, which involves setting a default installation, setting a boot menu timeout value, and (most importantly here), renaming the boot entries.
I've had great luck with EasyBCD; if you want (or you are a glutton for punishment), you can use the built-in BCDEdit command-line tool or Windows PowerShell v3. I show you in the next screenshot how simple it is to customize the BCD by using the free EasyBCD tool.
EasyBCD makes short work out of managing the Windows boot configuration database
So there you have it, friends! Please be aware that although I used only Windows 8 in this example, these steps should work with any combination of Windows 7, Windows Server 2008 R2, or Windows Server 2012.