Installing Microsoft Hyper-V Server 2012 R2 & 2016 to USB

This is a short How-To Guide on installing Microsoft Hyper-V Server 2012 R2 or Microsoft Hyper V Server 10 Technical Preview to a USB drive so you can use all available SATA/SAS ports for Virtual Machines. This is a Bare Metal Hypervisor from Microsoft that is similar to Xenserver & VMWare ESXi. Installation is pretty straight forward, and easy for those familiar with Windows.

1st April 2015 - Updated to include Microsoft Hyper-V Server 2016 Technical Preview

Download Microsoft Hyper-V Server Technical Preview

Whats new in Microsoft Hyper-V Server Technical Preview

HyperV USB Boot

The first thing we are going to do is create a virtual hard drive as a base for our operating system image. Once this is created it will be transferred to the USB disk for booting.

To get started launch an elevated command prompt (right click the start menu icon in Windows 8.1/10, and choose "Command Prompt (Admin)"

Next you should see the command prompt window launch with admin rights;

Now it's time to enter the following commands, lets get our hands dirty;
The following commands create a virtual disk file that is 7GB in size, with the volume formatted as NTFS and the drive letter H: and label "HyperVDisk";

mkdir C:\HyperVBoot
diskpart
create vdisk file=C:\HyperVBoot.vhd maximum=7288 type=fixed
select vdisk file=C:\HyperVBoot.vhd
attach vdisk
create partition primary
assign letter=H
format quick fs=ntfs label=HyperVDisk
exit

The next thing we need to do is download the Windows 8.1 ADK, which is;

"The Windows Assessment and Deployment Kit (Windows ADK) is a collection of tools that you can use to customize, assess, and deploy Windows operating systems to new computers."

Microsoft Windows 8.1 ADK Download - For Hyper-V 2012 R2

Microsoft Windows 10 Technical Preview ADK Download - For Hyper-V 10

Once the .exe has downloaded, Run it. Make sure to only select the deployment tools in the options screen like below;

Once its all installed which may take some time depending on your internet connnection, jump back into an elevated command prompt and issue the following commands;

cd /d C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\amd64\DISM
dism.exe /apply-image /Imagefile:C:\WIMFile\install.wim /Index:1 /ApplyDir:H:\
diskpart
select vdisk file=C:\HyperVBoot.vhd
detach vdisk
exit

Now its time to prepare the USB drive ready for the image, to do this we'll use Diskpart again;

diskpart
list disk
select disk (USB Disk number)
clean
create partition primary
select partition 1
active
format quick fs=ntfs
assign letter=K
exit

Copy the VHD file C:\HyperVBoot.vhd created earlier to the USB
drive that we assigned as letter K:

Next is to install the bootsector to the USB disk so it will boot;

cd /d C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\amd64\BCDBoot
BOOTSect /nt60 K: /force /MBR
diskpart
select vdisk file=K:\HyperVBoot.vhd
attach vdisk
exit

The next thing we have to do is load up the registry and disable and delete the paging file. If we didn't do this performance would be poor and the poor USB disk wouldn't last long due to many many writes to disk;

BCDBOOT H:\windows /s K:
REG load HKLM\HyperVRegistry H:\windows\system32\config\system
REG add HKLM\HyperVRegistry\ControlSet001\Control\Session Manager\Memory Management /v PagingFiles /t REG_MULTI_SZ /d “” /f
REG delete HKLM\HyperVRegistry\ControlSet001\Control\Session Manager\Memory Management /v ExistingPageFiles /f
REG unload HKLM\HyperVRegistry

Detach disk ready for booting!

Diskpart
select vdisk file=K:\HyperVBoot.vhd
detach vdisk
exit

Reboot machine with USB drive attached and choose as first boot device and depending on how fast you USB device can read/write Hyper-V will load.