Didn’t think you could boot Hyper-V from a USB? Well, you can.
Yeah, kinda snuck up on me too – I knew this was a feature request but it fell off my radar as it’s not something that I’ve had a need for and quite frankly, no one has asked me about it in any of the dozens of sessions that I’ve done on virtualization to partners and customers since R2 was released. But, after a conference call last week when this topic came up, I thought I better go do some due diligence to see where we were. Sure enough, this is fully supported now.
So, I grabbed my Kingston DataTraveler 16GB USB stick and set out to see if I could make this work.
The cool thing about how this works is that you are actually booting from a VHD – the operating system isn’t ‘installed’ to the USB drive. If you didn’t know, this ability to boot from a VHD is a new feature available in Windows 2008 R2 and Windows 7. You could dual boot your Windows 7 to this VHD that is created during this process if you wanted to. You could copy it to your hard drive, modify the boot manager to point to the VHD and you’re done. More details on how to do that HERE.
That said, first I’ll describe the ‘command line’ method, which is basically what this tool is doing for your behind the scenes, just so you know. I actually tried running the tool but ended up with a .NET error but didn’t feel like troubleshooting. 🙂
For the command-line junkies:
Step 1: Get a USB-drive with at least 8 GB storage. This is minimum req’s for Hyper-V Server 2008 R2, but I’d recommend 16 GB. Shop the fastest one you can find, it’ll be worth it when you have to sit around and wait. You’ll also need the ISO for Hyper-V Server 2008 R2 and the Windows Automated Installation Kit (WAIK).
Either burn your ISO or use a program to mount it as a virtual drive. You could also extract the files to a directory
Step 2: Fire up CMD with admin-rights.
diskpart (starts the disk management CMD-utility)
create vdisk file=driveletter:\virtualharddisk.vhd maximum=6000 type=fixed (creates a VHD on driveletter: of the size 6000 Mb and it’s fixed size for better performance)
select vdisk file=driveletter:\virtualharddisk.vhd (selects the created disk)
attach vdisk (attaches it so Windows can see it)
list disk (shows you all the disks in the system, note the number of your newly created VHD)
select disk disknumber (selects the newly created VHD)
create partition primary (creates a primary partition)
select partition 1 (selects the primary partition)
active (sets it to active)
format fs=ntfs quick (format it with NTFS and do it quick)
assign (assigns a driveletter, note with driveletter it gets!)
Leave this window open and start a new CMD with administrative rights.
Step 3: Download Windows AIK from Microsoft (1.7 GB) and install it. You need this to get ImageX which we’ll need soon and you could use the WAIK to customize your installation but that’s beyond the scope of this post.
imagex /info dvddrive:\sources\install.wim (this will show you all the entries (or versions) available in the WIM-file, Hyper-V Server 2008 R2 has only one entry, index 1)
imagex /apply dvddrive:\sources\install.wim /check 1 vhddrive:\
Step 5: Back to our diskpart-CMD
select vdisk file=driveletter:\virtualharddisk.vhd
list volume (note the drive letter for the newly mounted VHD.)
bcdboot vhddrive:\Windows /s usbdrive: /v (this copies the boot-files from your VHD’s Windows-directory to your USB-stick, which lets you boot later on)
When it’s finished, go back to the CMD with diskpart active and run
Now for the “BootFromUSB” Method:
But first, a few pre-requisites.
- USB drive should be 8GB or larger
- Need to have the Windows Automated Installation Kit (WAIK) or the Windows OEM Pre install Kit (OPK) installed.
- Have Microsoft Hyper-V Server 2008 R2 WIM file available from the DVD (INSTALL.WIM in the SOURCES directory).
- Only tested on Win7 (32/64 bit) and Windows Server 2008 R2 but should work everywhere the Windows AIK/OPK does.
- Need .NET 3.5 installed
- Download BootFromUSB
The tool is pretty prescriptive with hover-over help so you know what to stick in each box, but it’s pretty straightforward. Here’s what it looks like for my setup: