Installing and running Hyper-V 2012 R2 from a flash drive(USB)
Microsoft ships Windows ServerHyper-V2012 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.
Requirements
- 8 GB USB flash drive.
- Windows 7
- Windows Automated Installation Kit (AIK) for Windows 7 (AIK)
- Microsoft Hyper-V Server 2012 ISO from theMicrosoft web site (Hyper-V 2012 R2)
- Available drive letters on local computer Z: and T:
1. Install AIK
The first step you need to do is installing the AIK. We need this one later.
2. Create, mount and format a VHD file
Open a new Command Prompt (Run as Administrator)!
Create the following folders on your local machine.
mkdir c:\WIMFile<br></br>
mkdir c:\HyperV```
Now we create a new VHD and asign a drive letter to it!
diskpart
create vdisk file=C:\HyperV\Boot.vhd maximum=6000 type=fixed
select vdisk file=C:\HyperV\Boot.vhd
attach vdisk
create partition primary
assign letter=Z
format quick fs=ntfs label=hyperVDisk
exit```
3. Apply Install.WIM image and detach the VHD file
Copy the “Install.WIM” file from the Hyper-V Server 2012 R2 iso (you can find it in the sources folder) to “c:\WIMFile”!
Then apply the file.
cd /d "C:\program files\Windows AIK\tools\AMD64"<br></br>
ImageX /apply C:\WIMFile\Install.WIM 1 Z:\```
Use the DISKPART tool to detachthe virtual disk from your local machine.
diskpart
select vdisk file=C:\HyperV\Boot.vhd
detach vdisk
exit```
4. Preparing your USB flash drive
diskpart<br></br>
list disk<br></br>```
Remember the disk number(USB flash drive), you need it in the next step!
Now we will prepare the usb flash drive.
select disk (USB Disk number)
clean
create partition primary
select partition 1
active
format quick fs=ntfs
assign letter=T
exit```
Copy then the VHD file “c:\HyperV\Boot.vhd” to the USB flash drive(drive letter T:)
5. Use BOOTSECT to update the MBR code
We need the BOOTSECT tool to update the MBR record on the USB flash drive, so you can boot Hyper-V from your USB flash drive.
cd /d "C:\program files\Windows AIK\tools\PETools\AMD64\"<br></br>
BOOTSect /nt60 T: /force /MBR```
Then we attach the vhd to the T: drive
diskpart
select vdisk file=T:\Boot.vhd
attach vdisk
exit```
6. Use BCDBoot tool for the boot files
We use the BCDBoot tool to copy all the necessary boot files to your USBflash drive
BCDBOOT Z:\windows /s T:
7. Remove the paging file from the USB flash drive
We need to remove the Pagefile from our USB flash drive
REG load HKLM\HyperVRegistry Z:\windows\system32\config\system<br></br>
REG add "HKLM\HyperVRegistry\ControlSet001\Control\Session Manager\Memory Management" /v PagingFiles /t REG_MULTI_SZ /d "" /f<br></br>
REG delete "HKLM\HyperVRegistry\ControlSet001\Control\Session Manager\Memory Management" /v ExistingPageFiles /f<br></br>
REG unload HKLM\HyperVRegistry<br></br>```
We also detach the VHD from the T: drive
Diskpart
select vdisk file=T:\HyperVBoot.vhd
detach vdisk
exit```
8. Start Hyper-V
Now we are ready to start Hyper-V from the USB flash drive. Just attach it to the computer you went. And Hyper-V will boot.
Questions?
Just reply to this blog post!