Testing a USB Windows Install disk with Hyper-V

Recently I was putting together a new Windows USB Install disk (if you are not familiar with the process for doing this - here is a good article: https://windowsitpro.com/windows-8/q-how-do-i-create-bootable-usb-stick-can-install-uefi-system).  I really wanted to use virtual machines to test the disk as I was putting together (I am using unattended installation files and various scripts) however you cannot boot a Hyper-V virtual machine off of a USB key.

So what could I do?

The answer is surprisingly simple.  If you setup a virtual hard disk in exactly the same way that you do a USB install disk - you can use it to install Windows.

The process that I followed was to:

  1. Create a 32GB dynamic VHDX file using Hyper-V
  2. Mount the VHDX file in the host operating system - and then use DISKPART to create a FAT32 partition on it (that is marked as active), as discussed in the article above
  3. Copy in the Windows install files (and my custom scripts and tweaks)
  4. Create a virtual machine with this 32GB VHDX as the first hard disk, and a blank VHDX as the second hard disk
  5. Boot the virtual machine and install the operating system

This allowed me to quickly and easily test my install scripts.  Once I had everything working the way I wanted - I just had to copy my files to a physical USB key and go.

Cheers,
Ben

Comments

  • Anonymous
    July 01, 2015
    What is the advantage of using FAT32 over NTFS? For it is to be working just fine when I format the stick as NTFS.

  • Anonymous
    July 02, 2015
    If you are booting a UEFI based system (many of the new laptops - and Generation 2 virtual machines) you must use FAT32

  • Anonymous
    July 03, 2015
    Wouln't be easier to support USB passthrough on Hyper-V?

  • Anonymous
    January 03, 2016
    This is pretty cool.  Unfortunately it did not work for SCCM standalone media.  loads WinPE and then throws an error "unable to read task sequence configuration disk"  SMSTS log shows !sVolumeID.empty(), HRESULT=80074005   and !sTSMDataPath.empty(), HRESULT=80070002 the USB drive works fine on physical machines really wish they would just let us pass through USB media... back to PXE boot

  • Anonymous
    February 03, 2016
    Thanks for your blog Ben, it helped me in the right direction. However, while this is the first time I create a virtual machine on a Windows 10 client, I "accidentally" managed to do the above even easier, so I figured I should share that here as well:1. First I created a virtual machine with one empty virtual disk, on which I wanted to install Windows 10.2. I then inserted my USB with Windows 10 boot media into my physical client (the host). 3. After booting the virtual machine, I realized I can't boot from the USB. That's when I started to Google for a solution and found your post.4. I turned off my virtual machine, after which I moved my empty virtual disk from location 0 to location 1 (for IDE controller 0). I currently don't know if this was necessary, but I did it.5. I then started to create a new virtual disk as you described in your post. However, in the add-new-virtual-disk-dialog I got an option to copy files from any of my physical disks, and since the USB drive was still plugged into the physical machine I could easy select that as source for the copy and let Hyper-V do the rest. That is, no need for task 2 and 3 from your list above.6. When the virtual disk was created/copied, I started the virtual machine, and the Windows 10 installation program started right away without any further input from my side.I hope this helps someone else. Thanks again for your post.

    • Anonymous
      November 15, 2016
      Wanted to say thanks to Roland, his setup was mostly stress free. Changing the empty virtual disk from location 0 to location 1 was necessary in my case. Also, when installing Windows 10 I found I needed to allocate more minimum RAM to get past a "Microsoft could not find license terms" error. Aside from that, W10 up and running.