Difference between revisions of "Hyper-V"

From Ever changing code
Jump to navigation Jump to search
(Created page with "=Enable/Install Hyper-V= ==Installing Hyper-V Role using ServerManagerCMD.exe== ServerManagerCMD.exe –query - servermanagercmd.exe -install Hyper-V ==Installing Hyper-V R...")
 
 
(11 intermediate revisions by the same user not shown)
Line 15: Line 15:
  dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
  dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
  dism.exe /Online /Disable-Feature:Microsoft-Hyper-V-All
  dism.exe /Online /Disable-Feature:Microsoft-Hyper-V-All
== Powershell install Hyper-V feature ==
Verified: Windows 10 Pro
Optional: Setup the Disk to allow the hypervisor
<syntaxhighlightjs lang="powershell">
# BCDEDIT /Set `{current`} hypervisorlaunchtype auto
</syntaxhighlightjs>
Install Hyper-V feature
<syntaxhighlightjs lang="powershell">
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All #PS1
DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V          #CMD
</syntaxhighlightjs>
Restart is required
= Allow Hyper-V and VirtualBox to coexist =
Allow Hyper-V and VirtualBox to coexist by creating Windows Boot entries. Hyper-V is enabled during boot process, so creating a additional BCDEDIT entry will be the solution. Open PS in Admin mode, and run as follows:
<syntaxhighlightjs lang="powershell">
C:>bcdedit #get all entries
Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=\Device\HarddiskVolume1
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description            Windows Boot Manager
locale                  en-US
inherit                {globalsettings}
default                {current}
resumeobject            {9d2ba249-1e98-11e9-b631-e7f466ad9adb}
displayorder            {current}
toolsdisplayorder      {memdiag}
timeout                30
Windows Boot Loader
-------------------
identifier              {current}
device                  partition=C:
path                    \WINDOWS\system32\winload.efi
description            Windows 10
locale                  en-US
inherit                {bootloadersettings}
recoverysequence        {9d2ba24c-1e98-11e9-b631-e7f466ad9adb}
displaymessageoverride  Recovery
recoveryenabled        Yes
isolatedcontext        Yes
allowedinmemorysettings 0x15000075
osdevice                partition=C:
systemroot              \WINDOWS
resumeobject            {9d2ba249-1e98-11e9-b631-e7f466ad9adb}
nx                      OptIn
bootmenupolicy          Standard
# Create a new entry by coping {current} context
C:>bcdedit /copy '{current}' /d "Windows 10 - No hypervisor"
The entry was successfully copied to {9d2ba24e-1e98-11e9-b631-e7f466ad9adb}.
# Set hypervisorlaunchtype off. Allowed values on | off | auto
C:>bcdedit /set {9d2ba24e-1e98-11e9-b631-e7f466ad9adb} hypervisorlaunchtype off #use guid from the previous command output
The operation completed successfully.
</syntaxhighlightjs>
In order to access the new boot menu:
* restart and hold down <code>shift</code> on the keyboard while clicking Restart with the mouse
* on a boot menu select <tt>Use another operating system</tt> > <tt>Windows 10 - No hypervisor</tt>
Anoter option is to enable/disable Hyper-V feature
#Open the command prompt as an Administrator.
#Run the command with no argument: <code>bcdedit</code>
#After you run the above command, you will see that the property hypervisorlaunchtype is set Auto by default.
#Disable Hyper-V by running the command: <code>bcdedit /set hypervisorlaunchtype off</code>
#Restart your PC system to use VirtualBox.
#To turn Hyper-V back on, run the command: <code>bcdedit /set hypervisorlaunchtype auto</code>
#You will need to reboot the system to use Hyper-V.
=Automatic Virtual Machine Activation=
Requirments
*The Hyper-V host is a Windows Server 2012 R2 Datacenter Edition.
*The VMs are running Windows Server 2012 R2, thus only the below three editions can get activated by AVMA
**Windows Server 2012 R2 Standard
**Windows Server 2012 R2 Datacenter
**Windows Server 2012 R2 Essentials
*The Hyper-V host is activated. (It can be activated using any of your regular activation mechanisms like MAK, OEM or KMS.)
*The Guest VMs have AVMA client key installed on it
slmgr /ipk <AVMA_key>
AVMA keys
Datacenter Y4TGP-NPTV9-HTC2H-7MGQ3-DV4TW
Standard  DBGBW-NPF86-BJVTX-K3WKJ-MTB6V
Essentials K2XGM-NMBT3-2R6Q8-WF2FK-P36R2
Force VM to activate
slmgr /ato
= Nesting virtualisation providers =
== Hypervisor: Vmware Tools / Vmplayer on Windows ==
=== Nested provider: Oracle Virtualbox on Ubuntu ===
Virtual box will throw following error if you do not enable in VMWare Virtual Machine Settings > Processor > Virtualize Intel VT-x/EPT or AMD-V/RVI
Failed to open a session for the virtual machine vagranttest_1371583212.
VT-x is not available. (VERR_VMX_NO_VMX).
Result Code: NS_ERROR_FAILURE (0x80004005)
Component: Console
Interface: IConsole {db7ab4ca-2a3f-4183-9243-c1208da92392}
== Hypervisor: Virtualbox ==
;VirtualBox 6.x: [https://forums.virtualbox.org/viewtopic.php?f=1&t=90831 VirtualBox 6.x Nested virtualization, VT-x/AMD-V in the guest]
;prior version <6.x: Oracle Virtualbox can nest only 32bit systems, therefore you cannot run Hyper-V hypervisor on it as it would require 64-bit Windows OS. Often this is signalled by following error message "VM-server-#### failed to start. Failed to start the virtual machine  'VM-server-####' because one of Hyper-V components is not running."
=References=
*[https://technet.microsoft.com/en-GB/library/dn303421.aspx Automatic Virtual Machine Activation]
*[http://blogs.technet.com/b/askcore/archive/2013/11/13/activating-virtual-machines-via-automatic-virtual-machine-activation-in-windows-server-2012-r2.aspx Activating virtual machines via Automatic Virtual Machine Activation in Windows Server 2012 R2]
*[https://communities.vmware.com/docs/DOC-8970 Running Nested VMs] VMware community
*[http://www.virtualizationhowto.com/2015/05/installing-managing-hyperv-vmware-workstation-11/ Installing and managing Hyper-V in VMware Workstation 11]


[[Category:Hyper-V]]
[[Category:Hyper-V]]

Latest revision as of 01:12, 21 August 2019

Enable/Install Hyper-V

Installing Hyper-V Role using ServerManagerCMD.exe

ServerManagerCMD.exe –query -
servermanagercmd.exe -install Hyper-V

Installing Hyper-V Role using PowerShell

Import-Module servermanager
Add-WindowsFeature Hyper-V
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V –All
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All

Installing Hyper-V Role using OCSetup (Packet Manager)

Start /w ocsetup Microsoft-Hyper-V

Enable and Disable Hyper-V using DISM Command at elevated cmd prompt

dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V-All

Powershell install Hyper-V feature

Verified: Windows 10 Pro

Optional: Setup the Disk to allow the hypervisor <syntaxhighlightjs lang="powershell">

  1. BCDEDIT /Set `{current`} hypervisorlaunchtype auto

</syntaxhighlightjs>


Install Hyper-V feature <syntaxhighlightjs lang="powershell"> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All #PS1 DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V #CMD </syntaxhighlightjs> Restart is required


Allow Hyper-V and VirtualBox to coexist

Allow Hyper-V and VirtualBox to coexist by creating Windows Boot entries. Hyper-V is enabled during boot process, so creating a additional BCDEDIT entry will be the solution. Open PS in Admin mode, and run as follows: <syntaxhighlightjs lang="powershell"> C:>bcdedit #get all entries Windows Boot Manager


identifier {bootmgr} device partition=\Device\HarddiskVolume1 path \EFI\Microsoft\Boot\bootmgfw.efi description Windows Boot Manager locale en-US inherit {globalsettings} default {current} resumeobject {9d2ba249-1e98-11e9-b631-e7f466ad9adb} displayorder {current} toolsdisplayorder {memdiag} timeout 30

Windows Boot Loader


identifier {current} device partition=C: path \WINDOWS\system32\winload.efi description Windows 10 locale en-US inherit {bootloadersettings} recoverysequence {9d2ba24c-1e98-11e9-b631-e7f466ad9adb} displaymessageoverride Recovery recoveryenabled Yes isolatedcontext Yes allowedinmemorysettings 0x15000075 osdevice partition=C: systemroot \WINDOWS resumeobject {9d2ba249-1e98-11e9-b631-e7f466ad9adb} nx OptIn bootmenupolicy Standard

  1. Create a new entry by coping {current} context

C:>bcdedit /copy '{current}' /d "Windows 10 - No hypervisor" The entry was successfully copied to {9d2ba24e-1e98-11e9-b631-e7f466ad9adb}.

  1. Set hypervisorlaunchtype off. Allowed values on | off | auto

C:>bcdedit /set {9d2ba24e-1e98-11e9-b631-e7f466ad9adb} hypervisorlaunchtype off #use guid from the previous command output The operation completed successfully. </syntaxhighlightjs> In order to access the new boot menu:

  • restart and hold down shift on the keyboard while clicking Restart with the mouse
  • on a boot menu select Use another operating system > Windows 10 - No hypervisor


Anoter option is to enable/disable Hyper-V feature

  1. Open the command prompt as an Administrator.
  2. Run the command with no argument: bcdedit
  3. After you run the above command, you will see that the property hypervisorlaunchtype is set Auto by default.
  4. Disable Hyper-V by running the command: bcdedit /set hypervisorlaunchtype off
  5. Restart your PC system to use VirtualBox.
  6. To turn Hyper-V back on, run the command: bcdedit /set hypervisorlaunchtype auto
  7. You will need to reboot the system to use Hyper-V.

Automatic Virtual Machine Activation

Requirments

  • The Hyper-V host is a Windows Server 2012 R2 Datacenter Edition.
  • The VMs are running Windows Server 2012 R2, thus only the below three editions can get activated by AVMA
    • Windows Server 2012 R2 Standard
    • Windows Server 2012 R2 Datacenter
    • Windows Server 2012 R2 Essentials
  • The Hyper-V host is activated. (It can be activated using any of your regular activation mechanisms like MAK, OEM or KMS.)
  • The Guest VMs have AVMA client key installed on it
slmgr /ipk <AVMA_key>

AVMA keys

Datacenter Y4TGP-NPTV9-HTC2H-7MGQ3-DV4TW
Standard   DBGBW-NPF86-BJVTX-K3WKJ-MTB6V
Essentials K2XGM-NMBT3-2R6Q8-WF2FK-P36R2

Force VM to activate

slmgr /ato

Nesting virtualisation providers

Hypervisor: Vmware Tools / Vmplayer on Windows

Nested provider: Oracle Virtualbox on Ubuntu

Virtual box will throw following error if you do not enable in VMWare Virtual Machine Settings > Processor > Virtualize Intel VT-x/EPT or AMD-V/RVI

Failed to open a session for the virtual machine vagranttest_1371583212.
VT-x is not available. (VERR_VMX_NO_VMX).
Result Code: NS_ERROR_FAILURE (0x80004005)
Component: Console
Interface: IConsole {db7ab4ca-2a3f-4183-9243-c1208da92392}

Hypervisor: Virtualbox

VirtualBox 6.x
VirtualBox 6.x Nested virtualization, VT-x/AMD-V in the guest
prior version <6.x
Oracle Virtualbox can nest only 32bit systems, therefore you cannot run Hyper-V hypervisor on it as it would require 64-bit Windows OS. Often this is signalled by following error message "VM-server-#### failed to start. Failed to start the virtual machine 'VM-server-####' because one of Hyper-V components is not running."

References