Installing and running Hyper-V from a USB stick Installing and running Hyper-V from a USB stick

21 Feb by Nirmal Sharma     38     Hyper-V Articles

Microsoft ships Windows Server Hyper-V 2012 in two versions; Windows Server 2012 with Hyper-V as a role and Hyper-V Server 2012 version. The Hyper-V Server 2012 is a free version and offers almost all the components and features that are available in Windows Server 2012 with Hyper-V as a role version. It contains only Hyper-V role installed and it has to be installed on local hard disk like any other Windows installation. What if you need to make Hyper-V Server 2012 available on a USB stick; booting Hyper-V Server 2012 from a USB Stick and make it available for your testing? This is where this article comes handy; explaining the process involved in creating a bootable USB Stick with Hyper-V Server 2012 installed onto it.

The complete process to create the bootable USB Stick is done via command-line tools (mkdir, diskpart, ImageX, BOOTSect, BCDBoot, and REG.EXE) as shown in an example screenshot below:

Screencap of the command line for creating a bootable USB stick

Throughout the process, you need to have the following items available:

Requirements

  • 8 GB of space on flash drive.
  • A computer supporting boot from a USB Stick
  • Hyper-V Server prerequisites
  • Install.WIM file from Hyper-V Server Source folder
  • Windows 7 or newer Operating System
  • Windows Automated Installation Kit (WAIK) for Windows 7 or newer
  • Microsoft Hyper-V Server 2012 ISO from Microsoft web site
  • Available drive letters on local computers; Z: and R:

As an overview to the process, you will be performing the following steps:

  1. Creating and mounting a VHD file as a Primary Partition on local computer
  2. Formatting as NTFS and assigning a disk label
  3. Applying Install.WIM to VHD file using ImageX tool
  4. Using DISKPART to prepare the USB flash drive
  5. Using BOOTSect and BCDBoot tool to add the boot configuration to USB flash drive.
  6. Removing paging file using the REG command

These are the steps you’ll need to take:

1. Creating, mounting, and formatting a VHD File

Create the following folders on your local computer:

  • C:\WIMFile – used to store the WIM file
  • C:\HyperVBoot – used to store VHD file

Open the Hyper-V Server 2012 ISO file, navigate to the Sources folder, and copy the Install.WIM file to C:\WIMFile folder you created in the first step.

Next, open the command prompt under local administrator credentials and run the following command to create the VHD file which has a 6 GB capacity. The last three commands except “exit” will mount the VHD file as the drive letter Z:

2. Applying Install.WIM image and detaching the VHD file

Once the VHD file is created in the previous step, your next step is to apply Install.WIM file. Please execute the following commands:

And using DISKPART tool you detach the virtual disk from your computer:

3. Preparing your USB Stick

The next step is to prepare the USB Stick you will be using to install the Hyper-V Windows Server 2012 version. As part of the USB Stick preparation process, you will be using DISKPART tool to format the USB drive and copying the VHD File you created in earlier steps to the USB drive. Execute the following commands to get the USB disk number

Note: Note down the disk number for USB disk

And the following commands to create and format a new partition and assign the letter T: to the USB stick. Replace <USB Disk number> with the number identified in the previous step.

Copy the VHD file C:\HyperVBoot\hyperVBoot.vhd to the USB drive letter assigned as T:

4. Using BOOTSECT tool to update the MBR code

BOOTSect tool allows you to update the MBR record on the disk (USB Stick in thiscase) so you can boot Hyper-V Windows Server 2012 from USB Stick.

Run the following BOOTSect command to update the MBR

and the DISKPART command to attach the VHD file to the T drive.

5. Using BCDBOOT tool

Use the BCDBOOT tool to copy the necessary boot files so that you can boot your USB stick. Run the following command:

6.  Removing Paging file from USB flash drive

Since you are installing Hyper-V Windows Server 2012, you must remove the Pagefile requirement. Use the following command to load the registry from the VHD file and then remove the page file value and entry from the registry:

Finally the following commands to detach the VHD file from the T drive:

Remove the USB stick from this computer and attach it to a computer which supports all Hyper-V prerequisites to boot Hyper-V Windows Server 2012 from a USB Stick. Please make sure to change the boot order in computer BIOS in order to boot from the USB Stick.

Required software can be downloaded from below links:

Hyper-V 2012 Server Core Free edition:
http://aka.ms/dlhv2012

WAIK for Windows 7:
http://www.microsoft.com/en-in/download/details.aspx?id=5753

Have any questions?

Leave a comment below!

 

Backing up Hyper-V

If you’d like to make backing up your Hyper-V VMs easy, fast and reliable, check out Altaro Hyper-V Backup v4. It’s free for up to 2 VMs and supports Hyper-V Server 2012 R2! Need more? Download a 30-day trial of our Unlimited Edition here: http://www.altaro.com/hyper-v-backup/.

Receive all our free Hyper-V guides, checklists and ebooks first via email!

(Don’t worry, we hate spam too!)

Nirmal Sharma

Nirmal is a MCSEx3, MCITP and Microsoft MVP in Directory Services. He is specialized in Directory Services, Microsoft Clustering, Hyper-V, SQL and Exchange. He has been involved in Microsoft Technologies since 1994 and followed the progression of Microsoft Operating System and software. In his spare time, he likes to help others and share some of his knowledge by writing tips and articles. Nirmal can be reached at nirmal_sharma@mvps.org.

38 Responses to “Installing and running Hyper-V from a USB stick”

  1. tom miller

    This site is awesome. So much useful information. I’m a VMware Consultant learning what I can about Hyper-V 3 and SCVMM 2012 SP1. Currently have Hyper-V and SCVMM running on vSphere 5.1 to learn the features of Hyper-V. Runs well but it would be great to run Hyper-V from a USB drive to get a truer experience how Hyper-V performs on native hardware. I’m going to try this article to accomplish that task. The only thing I’m wondering is where to get all the utilities you mention?

    Thanks for sharing.

    Tom

  2. tom miller

    line 4 has a space “select vdisk file=C:\ HyperVBoot\hyperVBoot.vhd”
    also command “select disk <USB Disk number>” did not work? I had to select disk manually
    also the whole reg section has spaces that need to be dropped HKLM\” ” no space

    • Nirmal Sharma
      Nirmal Sharma

      Thank you Tom! Appreciate your time for reading this article! Yes, I fixed those and mentioned the links for downloading Hyper-V – 2012 free edition and WAIK for Windows 7.

  3. tom miller

    Thank you! Got me started. After creating two usb hyper-v 2012 sticks I rebooted my esx servers and they became hyper-v 2012 running from usb. This allows me to see native hyper-v performance verses them running as VM’s on ESX while saving my esx config. To run esx all I have to do is shutdown, remove the USB sticks, reboot, and now I’m running ESX again. Thanks for the tip.

    More for your readers, I wasn’t sure what functionality I might loose running Hyper-V 2012 vs Server 2012 with role Hyper-V added. As far as I can tell very little, if any. I’m using the RSAT tools to manage Hyper-V 2012 with Hyper-V Manager, Failover Cluster Manager, and SCVMM.

    Thanks again. Watching for continued great post from you.

  4. Jay Bietz

    Nirmal:
    Item 6 line 1 I’m seeing the r:\windows\system32 et al … I have r: free on my computer but I don’t see where / if I’m supposed to have it mapped.

    I’m also having to replace the AMD64 with x86 …

    Thanks for your post…

    • Nirmal Sharma
      Nirmal Sharma

      Thanks Jay for the comments! Fixed drive letter in the article!

  5. grasomega

    Hi!
    Thanks for the article. I think there’s a small typo on step 6:

    REG load HKLM\HyperVRegistry T:\windows\system32\config\system

    should probably be: REG load HKLM\HyperVRegistry Z:\windows\system32\config\system

    as the letter T: is assigned to the USB disk, not to the mounted vhd file.

    Regards

    • Nirmal Sharma
      Nirmal Sharma

      Hi, thanks for the feedback – fixed it!

  6. Srdjan

    It won’t work for me. System says that it can’t find any bootable files on USB removable device. :(
    I’m using Kingston DataTraveler Elite 3.0 Transcend drives. I follow the instructions, but it just won’t work.

    • Nirmal Sharma
      Nirmal Sharma

      Hi Srdjan, Thank you for reading the article!
      Could you please tell me at which step it fails? It looks like you received the “Can’t find any bootable files” message when you are booting from the USB?

      Thanks!
      Nirmal

  7. Nadav

    Hello,
    Thanks for this great post!
    I would like to comment that with Windows 8 and Server 2012, there is no need for WAIK any more. The following included commands are enough (on one line):
    1) “dism /apply-image /imagefile:d:\Sources\install.wim /index:1 /applydir::\”.
    2) “:\Windows\System32\bcdboot :\Windows /f ALL /s :”

    For more boot options: http://technet.microsoft.com/en-us/library/hh825709.aspx

    Thanks,
    Nadav

  8. Nadav

    On the above comment the commands are cutoff (drive letters are missing). Here are the fixed ones (D is for the install DVD/ISO, T is for the USB and S is for the VHD):
    1) “dism /apply-image /imagefile:D:\Sources\install.wim /index:1 /applydir:S:\”.
    2) “S:\Windows\System32\bcdboot S:\Windows /f ALL /s T:”

    Sorry for that,
    Nadav

    • Nirmal Sharma
      Nirmal Sharma

      Hi Nadav, Thank you for the commands!

      Nirmal

  9. Richard Sigar

    How do you backup the USB disk? Can we just clone the disk and replace it when the original one die?

    • Nirmal Sharma
      Nirmal Sharma

      Hi Richard, Windows does not have native tool for cloning USB stick but yes there are third-party tools available you can use to clone USB Sticks!

      Thanks!
      Nirmal

  10. tom miller

    Nirmal,
    Commented above, so I’ve been using your instructions to run Hyper-v 2012 from USB, 2 host and built SCVMM as a VM. All good. Have an assignment to build Hyper-V for a customer so I rebuilt my USB drives to start over and get more practice. Problem is after building the USB drive and on first boot I get “can’t find “\windows\system32\winload.exe”. Odd. Did not have that issue before. I had to use easybcd.exe to fix the bootloader? It’s working now but I did not have to use easybcd before. Any idea what I’m doing wrong?

  11. tom miller

    Nirmal,
    Nevermind. I went out and bought 2 Lexar USB drives and they work fine? The Western Digital not so much.

    Thanks again for this great post.

    Also just bought Windows Server 2012 Hyper-V Install and Config Guide. So far it’s well written and informative.

    • Nirmal Sharma
      Nirmal Sharma

      Hi Tom, Thanks!
      Interesting…
      Let me try with Western Digital…

      Nirmal

  12. Paul

    I’ve successfully did this on 2 proliant servers, now I have a new proliant G8 and keep getting blue screen saying there was a problem and can’t go any further. Any help would be good.

    • Nirmal Sharma
      Nirmal Sharma

      Hi Paul, Not sure why you’re seeing a blue screen.

      Does it say failure with any specific driver?

      Thank You,
      Nirmal

  13. arjen_mark

    Hi Nirmal,

    Thanks for the most excellent post – very clear and concise.
    I just wanted to pass on my experience with implementing this technique as having found your post I went away and gave it a try on my lab PC.
    The first time I tried it didn’t work – I just got the dreaded “Your PC has a problem…” error message when Windows attempted to boot and then my lab PC would just constantly restart.
    In the end I formatted my USB stick (A Lexar 16GB by the way) and ran through your instructions again.
    This time, success!!
    It worked like a dream – Hyper-V 2012 server core running off the USB.

    No idea what I did wrong the first time, but I just wanted to pass on to anyone that it doesn’t work for the first time, to not give up immediately..

    Thanks,

    Mark

    • Nirmal Sharma
      Nirmal Sharma

      Hi Mark, Thanks for sharing your feedback! Appreciate it!

      Nirmal.

  14. tom miller

    Nirmal – I assume this process will work for hyper-v 2012 R2 tech preview?

    Also just a comment for Richard above about backing up USB sticks. Along the same lines, as soon as I create the USB following your process I use linux to save the USB as an iso file, then I dd the iso to another usb stick. It’s builds another USB drive identical to the first. Quick, fast way to build multiple hyper-v USB boot sticks.

    dd if=/dev/sdX of=hyperv2012.iso creates clean ISO file
    dd if=hyperv2012.iso of=/dev/sdX create a clean USB just like the original

    Just saves a little time.

    Thanks
    Tom Miller

    • Nirmal Sharma
      Nirmal Sharma

      Hi Tom, I haven’t tested for 2012 R2 Preview but it should work, I believe!

      Thanks!
      Nirmal

  15. Dom

    Great Article. Couple of questions;

    1) The 6GB specified for the VHD is not sufficient if you want to patch the OS. I’m using 32GB UFD, so I increased the VHD size from 6GB to 20GB. It worked and I was able to fully patch the OS, however it was DESPERATELY slow. Even via RDP the screen refresh was like looking at a slide show showing events that occurred several seconds ago. Any idea why increasing the VHD size might attribute to slowing things down to a snails pace?

    2) Do you know of anyway to expand on the registry injection to include specifying IP details, enabling RDP and setting the Admin password? The method here is fine if you have physical access to all the servers, however I’ve got a requirement to get a Hyper-V server up an running I don’t have physical access to. If I can tell the DC techy to just plug in a USB flash disk and reboot, I think it would provide significant time savings.

    • Nirmal Sharma
      Nirmal Sharma

      Hi Dom,
      Thanks for comments!

      1. You’re right! 6 GB might not be enough if patching needs to be done! The article’s primary focus is to run Hyper-V from a USB stick for testing purpose.

      2. For IP details injection, you can design a small script which includes NETSH commands to change IP details and then run it via registry RunOnce. For admin password, you can use “Net User” command in the script to change the admin password.

      Thanks!
      Nirmal

  16. D Carlson

    Great article, thank you for sharing. It get this response when attempting to update the MBR (step 4):

    “This tool can only be run on systems booted using a PC/AT BIOS. This system was booted using EFI or some other firmware type.”

    Apart from running this process from a Windows 7 computer with the PC/AT BIOS, does anyone know a way around this? Thanks in advance.

  17. Peter

    What does the 90 in step 3 mean i just get a error?

  18. Nirmal Sharma
    Nirmal Sharma

    Hi Peter,

    Please ignore that. Fixed that!

    Thanks for pointing out!
    Nirmal

  19. tom miller

    Nirmal – for clarity you need to add “cd C:\Program Files\Windows AIK\Tools\amd64″ to step 5 BEFORE command bcdboot. As bcdboot is not found in the current directory your currently in.

    Also for your readers this process works fine with hyper-v 2012 R2 as well.

    Thanks for your work.
    Tom

  20. Nirmal Sharma
    Nirmal Sharma

    Hi Tom, Thank you very much for verifying on Hyper-V 2012 R2 and posting back!

    Regards,
    Nirmal.

  21. oDeLaY

    Hi,

    running hyper-v 2012 from usb for a while now with satisfactory, but can I upgrade the stick to R2 like a normal installation from another usbstick with the R2 ISO on it?

    Anyone done that yet?

    thx

  22. David

    @Nadav, you wrote:
    1) “dism /apply-image /imagefile:D:\Sources\install.wim /index:1 /applydir:S:\”
    2) “S:\Windows\System32\bcdboot S:\Windows /f ALL /s T:”

    should 2) have /s S: as follows??

    2) “S:\Windows\System32\bcdboot S:\Windows /f ALL /s S:”

  23. Stephen

    Nirmal,

    I have ran though the process 3 times now. When attempting to boot our supermicro server I get “Windows Boot Manager: Windows failed to start. A recent hardware or software change might be the cause. 0xc000000e”

    Have you ever encountered this issue?

  24. Stephen

    I was able to at least get to the windows loading screen, but getting a BSOD with an inaccessable boot device message. I have tried this on different machines with the same results.

    Is there a way to correct this issue?

  25. Nirmal Sharma
    Nirmal Sharma

    Hi Stephen,

    BSOD for Inaccessible Boot Device message indicates issue with driver. Which USB make and model are you using?

    Thank you for reading articles!
    Nirmal

  26. Andy

    Hi, it works like charm on a HP Gen7 box , thank for the detail procedure Nimal.

    Question: once the Hyper V is up , how can I mount the USB drive over network so I can upload program ( such as coreconfig ) to it ? it’s a homelab workgroup environment and I don’t have compatible client RSAT to config the hyper V .

    Thank you,

  27. Andy

    Hi it’s Andy again , if server on USB is up and running , how to access other files on USB ( other than hyperV.vhd ) from server ? Mine is a workgroup environment however I can’t access shares over the network ( running command like net use gets error ).

Leave a comment