Tallan's Technology Blog

Tallan's Top Technologists Share Their Thoughts on Today's Technology Challenges

Creating a Windows 10 Preview VHD That Can Run as a Hyper-V VM and Can Boot Natively

jgiessner

Introduction

When the Windows 10 Technical Preview came out earlier this month, I wanted to see kick the tires a bit and see what was new. However, I need my laptop to work reliably, so I couldn’t take the risk of installing Windows 10 over my Windows 8.1 installation.

So, I decided to install it to a Virtual Machine (VM) running in Hyper-V. This would allow me to run Windows 10 in a “sandbox” that would not affect my primary operating system. It would also allow me to multitask – doing my normal day-to-day activities on my laptop, while still “playing around” with Windows 10.

The other thing I wanted to be able to do is native boot into the Virtual Hard Disk (VHD) used by this VM. VHD native boot is a nice feature that was added with Windows 7 and Server 2008 R2. When you boot into a VHD, you are running everything in it on bare metal except for the disk. There are 2 advantages to doing this. The first is performance – you use all CPU cores and all of the memory on the computer and there is no virtualization layer to go through (except for the disk as mentioned above). The second is that you can verify that Windows 10 will work on the hardware of your computer – you can’t do that running in a VM since everything is virtualized.

I did something similar to this a few years ago, creating a Windows Server 2008 R2 VHD that could run as a VM and could be native booted into. I followed most of the same process here. One other thing to note is that I was able to follow similar steps with VirtualBox to create a Windows 10 Technical Preview VHD that can be booted into and run as a VM; so if VirtualBox is your preferred VM manager, you are in luck. In fact, the VHD that you create in the steps below can be used in both Hyper-V and VirtualBox (although, beware, you can’t run VirtualBox if Hyper-V is enabled).

The following shows the step-by-step process of how to create a Windows 10 Technical Preview VHD that can run as a Hyper-V (and VirtualBox) VM and can boot natively.

Step 1: Create Blank VHD

(NOTE: I looked at doing this with a VHDX. However, that would require an EFI compatible boot partition. The process of creating a bootable partition that is EFI compatible is not as simple, so I went with a VHD instead.)

  1. Open a Command Prompt, running as Administrator
  2. Enter the DISKPART utility:
      diskpart
    Diskpart screen capture
  3. Create a fixed VHD of a certain size. The example will create a fixed VHD that is 40GB (the maximum parameter is measured in MB) in the folder D:\VHDs\Windows10. I chose 40,960MB so that it will be an even number of GB, which makes it compatible if you want to upload it into Azure eventually.
      create vdisk file=”d:\vhds\Windows10\Windows10Preview.vhd” maximum=40960
  4. Select the new VHD:
      select vdisk file=”d:\vhds\Windows10\Windows10Preview.vhd”
  5. Attach VHD:
      attach vdisk
  6. Create primary partition:
      create partition primary
  7. Format partition:
      format fs=ntfs quick label=”Windows10_VMandNativeBoot”
  8. (Optional step) Review volumes, checking to make sure new VHD is listed (note that only the first 11 characters of the volume label will appear):
      list vol
  9. Detach VHD:
      detach vdisk
  10. Exit DISKPART:
      exit

Step 2: Install Windows 10 on the VHD through Hyper-V

  1. Create a new VM:
    Hyper-V create VM screen capture
  2. Name the VM:
    Hyper-V VM name screen capture
  3. I went with Generation 1 to keep it simple:
    Hyper-V VM generation selection screen capture
  4. Assign the amount of memory that you want and press Next.
  5. Setup network. You’ll want an external switch setup so that you can connect to the internet for Windows 10 setup.
  6. Chose “Use an existing virtual hard disk” and browse to the VHD that you created:
    Hyper-V VM disk selection screen capture
  7. Review the summary information and hit Finish.
  8. The VM should show up in the Virtual Machines pane.
  9. Click on the VM and then edit the Settings.
  10. Go down to DVD Drive under IDE Controller 1 and attach the image file:
    Hyper-V VM image selection screen capture
  11. Start the VM.
  12. The normal Windows 10 install process should start. On the storage selection screen, you should see the blank VHD you created. Perform a normal installation and configure as desired.
  13. Windows 10 should now be running successfully as a VM.

Step 3: Adding the VHD to Boot Menu

(Note that you can use a tool, like EasyBCD, to add the VHD to the boot menu. However, the steps below show how to do it manually.)

  1. Open a Command Prompt, running as Administrator.
  2. Use BCDEDIT command to copy the default boot option:
      bcdedit /copy {default} /d “Windows 10 Preview”
  3. The results of the previous command will return a GUID. Copy the GUID (including the braces) to the clipboard for the following steps:
    BCDEdit screen capture
  4. Use BCDEDIT to set the DEVICE and OSDEVICE options for the VHD boot entry. Use the GUID you copied in the previous step for the {YOUR GUID}references below. Also note: the [locate] parameter below will allow the VHD to be loaded from multiple locations. Run the BCDEDIT commands as shown with the GUID you copied and your VHD filename:
      bcdedit /set {YOUR GUID} device vhd=[locate]\vhds\Windows10\Windows10.vhd
      bcdedit /set
    {YOUR GUID} osdevice vhd=[locate]\vhds\Windows10\Windows10.vhd
  5. (Optional step) Run BCDEDIT to review your boot options, checking to make sure your new boot entry for the VHD appears.
  6. Reboot your machine and choose the Windows 10 Preview boot option.

You should be all set! Now you can run Windows 10 as a VM and you can boot directly into it.

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

\\\