Switching Hyper-V On and Off Using Boot Options

This document provides instructions for setting up your Windows 10 environment to allow easy switching between hypervisors without needing to install/uninstall Hyper-V support. You will still need to reboot to make the switch, but a reboot is all you’ll need to do since we won’t be adding/removing any software.

Overview 

Warning

The instructions in this document were written and tested only on Windows 10 Pro!

Hyper-V is not supported on Windows 10 Home.

Windows 10 Enterprise enables additional features that may create additional issues (see Blue Screen of Death (BSOD) when starting any VM (No HyperV) on Windows 10 Host forum topic). The method described in this document may work with Windows 10 Enterprise, but I don’t have access to this version and therefore cannot test it.

Standard method for running multiple hypervisors 

Windows 10 Pro provides the Hyper-V service for running virtual machines. This is great so long as you don’t also need to run alternative hypervisors (e.g. Virtualbox or VMWare) – you cannot run alternative hypervisors when the Windows Hyper-V Service is running. If you want to be able to use both Hyper-V and Virtualbox (or VMWare) on the same machine, you can only run the alternative hypervisors after turning off the Hyper-V Service.

The standard answer to this issue you will often find on the web is that you need to add or remove the Hyper-V Service using Powershell and then reboot:

Enable Hyper-V

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V –All

Disable Hyper-V

Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

This works, but it is literally removing all Hyper-V support, which takes a bit of time (since Windows has to uninstall software) and takes extra time on reboot (since it has to finish the software changes as part of the reboot).

There is an alternative!

A faster, more convenient way to switch between hypervisors 

This document provides instructions for setting up your Windows 10 environment to allow easy switching between hypervisors without needing to install/uninstall Hyper-V support. You will still need to reboot to make the switch, but a reboot is all you’ll need to do since we won’t be adding/removing any software.

The method uses a boot option (configured using BCDEDIT) named ‘hypervisorlaunchtype’ that can be used to enable/disable the Hyper-V service without requiring you to completely uninstall Hyper-V – it just tells Windows whether to use the Hyper-V service for a particular boot entry.

When ‘hypervisorlaunchtype’ is set to ‘Auto’ for a specific boot entry, then the Hyper-V service is enabled for that boot session and alternative hypervisors cannot run. When ‘hypervisorlaunchtype’ is set to ‘Off’ for a specific boot entry, then the Hyper-V service is disabled for that boot session and you can run Virtualbox (or any other alternative hypervisor).

As noted, you still need to reboot to select which boot session to use (Hyper-V on or off), but that’s all you have to do – there’s no install/uninstall of software to slow down the reboot process.

Here’s how to set this up…

Disclaimer

READ THIS FIRST: I have tested the following procedures and script(s) on several of my computers without any problems. However, since I cannot predict every possible scenario, you use these instructions and script(s) at your own risk – I assume no responsibility for any problems you may encounter even if you follow the instructions exactly!

Read this document carefully – you are modifying settings that control your boot process!
If you mess something up, you may not be able to boot at all!

Assumptions before you start 

  1. You have turned on Hyper-V support in Turn Windows Features on or off
    (see Install Hyper-V on Windows 10)
  2. You are comfortable editing your boot configuration
  3. You have a recent backup just in case this breaks something!

Important

The modifications you make using BCDEDIT may be lost/reverted after any Windows 10 Feature Upgrade (e.g. upgrading from Windows 10 1809 to 1903). It appears that the Feature Upgrades revert the Boot Configuration to “safe” settings, which seems to remove the ‘hypervisorlaunchtype’ = ‘Off’ setting if you’ve set it up below.

If Hyper-V was already turned on before the Feature Upgrade, it will remain turned on after a Feature Upgrade, so you will not have to re-enable it in Turn Windows Features On or Off. But you will (probably) need to repeat steps 1-6 below to set up the Boot menus to set ‘hypervisorlaunchtype’.

Steps to modify boot configuration 

Step 1 

Open an administrative Powershell (or CMD) console.

If you haven’t done so already, create a folder to contain your BCDEDIT export(s):

[C:\]$ mkdir C:\BCD.Backups

Export the current BCD config (just to be safe):

[C:\]$ bcdedit /export "C:\BCD.Backups\bcdedit.backup.20190628T1051.Original.bcd"
The operation completed successfully.

Tip

Use a unique path/filename for the export file. I use a date stamp based on the ISO 8601 standard – YYYYMMDDThhmm. You can use any naming convention you like, assuming the export file is unique and you can identify it later if needed.

Step 2 

Remember

This step assumes that you have installed Hyper-V (in Windows Features – see Assumptions) and that you have booted/rebooted after turning on Hyper-V so it is currently running.

Check to make sure your current environment has Hyper-V enabled:

[C:\]$ (Get-CimInstance Win32_ComputerSystem).HypervisorPresent

If the result is True then you can continue to the next step.

If the result is False then you need to make sure you’ve enabled Hyper-V (see Assumptions for a link to enabling Hyper-V)

Step 3 

Create a new Boot Menu entry based on “{current}” (your currently booted entry):

[C:\]$ bcdedit /copy "{current}" /d "Windows 10 - NO Hyper-V"
The entry was successfully copied to {c3ef58d3-995d-11e9-b374-b73603a34c4a}.

IMPORTANT: The GUID returned above will be unique – this is just an example!

Make a note of the GUID returned, since it will not be the same as the example above!

Step 4 

Using the GUID returned from the previous step, update the new menu entry to disable the Hyper-V service:

[C:\]$ bcdedit /set "{c3ef58d3-995d-11e9-b374-b73603a34c4a}" hypervisorlaunchtype off
The operation completed successfully.

You should change the description of the original (i.e. “{current}") entry to be more consistent with the name of the new entry:

[C:\]$ bcdedit /set "{current}" description "Windows 10 - Hyper-V ENABLED"
The operation completed successfully

Step 6 

Make a new backup (export) of the Boot Menu configuration:

[C:\]$ bcdedit /export "C:\BCD.Backups\bcdedit.backup.20190628T1056.Primary.bcd"
The operation completed successfully.

Remember

Use a unique path/filename for the export file.

Prolog 

Ideally, you should only have two boot entries containing the ‘hypervisorlaunchtype’ setting – one set to ‘Off’ and one set to ‘Auto’.

If you use the reboot-hyperv.ps1 script (see below), it will only look for the first entries containing ‘hypervisorlaunchtype’ = ‘Auto’ or ‘Off’. Any additional entries will be ignored.

Powershell script 

Assuming you have successfully followed the instructions in this document, the following Powershell script can be used to Enable/Disable the Hyper-V service on the next reboot. You can run this from a Powershell prompt or you can create shortcuts to run the script (one shortcut to Enable and one shortcut to Disable).

Important

You must run this script as an administrator.

Download reboot-hyperv.zip and unzip into a folder in your path.

Usage 

NAME
    reboot-hyperv.ps1

SYNOPSIS
    Use BCDEDIT to select menu entry that enables or disables Hyper-V

SYNTAX
    reboot-hyperv.ps1 [[-Enable]] [-Pause] [-MessageBox]

    reboot-hyperv.ps1 [[-Disable]] [-Pause] [-MessageBox]

    reboot-hyperv.ps1 [[-Clear]] [-Pause] [-MessageBox]

DESCRIPTION
    Uses the 'BCDEDIT /bootsequence' command to select the boot menu option
    that enables (or disables) Hyper-V (via 'hypervisorlaunchtype' menu option).

PARAMETERS
    -Enable [<SwitchParameter>]
        Selects the boot menu that enables Hyper-V
        (i.e. first entry with 'hypervisorlaunchtype' set to 'Auto' or 'On')

    -Disable [<SwitchParameter>]
        Selects the boot menu that disables Hyper-V
        (i.e. first entry with 'hypervisorlaunchtype' set to 'Off')

    -Clear [<SwitchParameter>]
        Clears the BootSeqence (revert to default boot)

    -Pause [<SwitchParameter>]
        Pause the output (useful when running this script from a Shortcut)

    -MessageBox [<SwitchParameter>]

Owner & Founder

Related

Next