Requirements:
- Hyper-v Server 2012 R2
- USB stick 80GB
- Windows 8.1 WAIK
- Net Framework 4.5
Note: The following steps work for Hyper-v 2012 R2. You have to use SConfig tool to configure basic Hyper-v settings such as remote administration and networking. When you boot server using this USB stick containing .vhdx file, Setup begins. You can then select preferred option.
How to install Hyper-v Server 2012 R2 on USB
Step1: Install Windows WAIK on a Windows 8 PC
You will see DISM.exe in C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Deployment Tools\amd64\DISM
Step2: Extract Windows Server 2012 R2 and copy install.wim file in C:\Win2012R2ISO location
Step3: Create VHDX file
Open elevated command prompt, issue the following command step by step
mkdir c:\Win2012R2
diskpart
create vdisk file=c:\Win2012R2\HYPV2012R2.vhdx maximum=81920 type=fixed
where 81920 is 80GB.
select vdisk file=c:\Win2012R2\ HYPV2012R2.vhdx
attach vdisk
create partition primary
assign letter=r
format quick fs=ntfs label=HYPV2012R2
exit
Step4: Apply install.wim file
Open elevated command prompt, issue the following command step by step
cd /d “c:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\<architecture>\DISM” where architecture is amd64 or x86
dism.exe /apply-image /Imagefile: C:\Win2012R2ISO\install.wim /Index:1 /ApplyDir:R:\
Step5: Insert USB stick and create partition
Open elevated command prompt, issue the following command step by step
diskpart
list disk
select disk <USB stick number>
clean
create partition primary
select partition 1
active
format quick fs=ntfs
assign letter=v
exit
Step6: Remove PageFile from Bootable disk
Open elevated command prompt, issue the following command step by step
reg load HKLM\HyperVTemp r:\windows\system32\config\system
reg add “HKLM\HyperVTemp\ControlSet001\Control\Session Manager\Memory Management” /v PagingFiles /t REG_MULTI_SZ /d “” /f
reg delete “HKLM\HyperVTemp\ControlSet001\Control\Session Manager\Memory Management” /v ExistingPageFiles /f
If you receive invalid key error. Simply type regedit and go this location and delete PagingFiles key.
reg unload HKLM\HyperVTemp
Step7: Copy VHDX to USB stick
Say USB stick is presented as V: drive of your PC. Copy the VHDX file from c:\Win2012R2\HYPV2012R2.vhdx to V: drive where the USB stick is attached. Open elevated command prompt, issue the following command step by step
diskpart
list disk
select vdisk file=V:\HYPV2012R2.vhdx
attach vdisk
exit
Step8: Make it bootable
Open elevated command prompt, issue the following command step by step
cd /d ” c:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\<architecture>\BCDBoot”
bootsect /nt60 v: /force /mbr
Use the BCDBoot tool to copy the necessary boot files so that you can boot your USB stick.
bcdboot r:\windows /s v:
Step9: Dettach r:\HYPV2012R2.vhdx
Open elevated command prompt, issue the following command step by step
diskpart
select vdisk file=r:\HYPV2012R2.vhdx
detach vdisk
exit
Step10: Test
Detach USB stick from PC and insert into server. Power on Server. Go to BIOS of the server. Change boot order to USB/ Build in Hypervisor. Save and Exit BIOS. Reboot the server.
Step11: Troubleshooting if required
- Put the USB in to your server
- Boot the server using a Hyper-v 2012 R2 DVD
- Select your language, click Next, then select ‘Repair your computer’
- Select ‘Command prompt’
Run ‘bcdedit /enum’, it’s probably still pointing to your .vhdx file (check ‘device’ and ‘osdevice’) - Fix this by using bcdedit, I used;
exe /set {default} device vhd=[C:]\HYPRV2012R2.vhd
and
bcdedit.exe /set {default} osdevice vhd=[C:]\HYPRV2012R2.vhd - Now remove the Windows dvd and boot from USB.
References http://technet.microsoft.com/en-us/library/ee731893%28WS.10%29.aspx