Did you ever want to boot an HyperV Windows VM from a USB key on a physical PC? Or simply want to boot windows from a USB key? Why would you want to do that you ask? Well, this can be really handy to run the new flavor of Windows you want without needing to mess with yourÂ PC internal HDD. It allow you to bring your own Windows environment in a classroom and boot to what you know every time and continue to work where you left things at.
Since it also run from a fast USB 3 key it can actually be much faster than running windows on an old clunky 5400 rpm internal drive.
So how can you make such a bootable USB key? Really easily it turn’s out. 1st, gather the following things:
- Get a fast USB 3.0 key like the Sandisk Extreme USB 3.0 Flash Drive.
- Download and install a copy of Rufus 2.10
- Build yourself a Windows HyperV VM. Make sure the VM virtual HDD is smaller than the capacity of your USB key by 5 to 10 GB. This space will be used for the pagefile.
Now that you have the required components connect your USB key to your PC. Next open Rufus, select the USB key under Device and configure it to use a Partition scheme and target of MBR partition scheme for BIOS or UEFI. Select NTFS as the File system. Keep the default Cluster size to 4096 bytes. Name the useb key (NTFS in the example belowâ€ť. Click the white arrow beside â€śFormat Optionsâ€ť to access the hidden options.
Select UEFI:NTSF in â€śCreate a bootable disk usingâ€ť. Last, make sure to select â€śAdd fixes for old BIOSesâ€¦â€ť. It should look something like this:
Click Start. In a few seconds your USB key will be formatted and ready for the next step. Take note of the drive letter assigned to the USB key (f: in my case).
Copy the VM folder at the root of your USB key. Next, open the VM folder on the USB key and then open the â€śVirtual Hard Disksâ€ť folder. Right click on the vhdx file an select mount.
Take note of the drive letter associated with the mounted vhdx file. In my case it was h:
Next, open command prompt with Admin rights and install the boot loader on key with:
bcdboot h:\windows /s f: /f ALL (where h: is replaced with the VHDX drive letter and f: with the USB key drive letter)
To prevent internal drive from going online when you run the VM from the USB key boot the VHDX tht is on the USB key in hyperv, open an admin command prompt and type:
What are the benefits of putting the exported VM on the key instead of just the vhdx? You can easily import it on another windows PC in hyperV and make updates to the vhdx file that wonâ€™t
If you intend to use Bitlocker to encrypt the VM c: you will need to change the following registry key to 0 after bitlocker is configured. Failure to do so will result in the inability to have a pagefile when running from the USB drive:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Memory Management\PagefileOnOsVolume
That is it. You should now have a fully bootable VM in a USB key. Bravo!