Switch between Hyper-V and Virtualbox on Windows

Since a while I have been using Virtualbox + vagrant to do web development based on Linux, Nginx and NodeJS. However I also still do Windows development occasionally. For that reason I needed a way to easily switch from Virtualbox to Hyper-V or the other way around, as Hyper-V is required for example for the Windows Phone emulator.

Hyper-V can not run together with Virtualbox as they both need an Hypervisor. Unfortunately you can’t have 2 Hypervisors running. Therefore we need to disable Hyper-V when we want to use Virtualbox. Unfortunatily you simply can’t just disable Hyper-V.

What I wanted to achieve was the following:

  • Being able to use vagrant and virtualbox to do my webserver development on my Linux VM’s.
  • Being able to use the Windows Phone emulator using Hyper-V to do my Windows Phone development.

Basically some webpages out there advice you to disable Hyper-V by using the Add/Remove Features. However if we do that we have to reinstall it when we need it again. So for me that wasn’t really a solution. The other solution is to have multiple boot profiles on Windows, so you can pick which one to use when booting your computer. As it is not the ideal solution, since you have to reboot your computer to switch, it is the only solution today.

As we are going to modify our boot loader I want you to pay extra attention as we don’t want to end with our computer in a corrupted state. When not comfortable, please consult a local expert to help you on the topic. First of all we create a backup of the boot manager using the /export option. Make sure you are running from an elevated (administrator) Command prompt.

Backup
1
bcdedit /export backup.bcd

If you feel you have messed up somewhere in the process, restore the original settings from your backup. The backup is located in the directory where you started the export.

Restore
1
bcdedit /import backup.bcd

To create a second boot profile you can execute following command.

Copy and Disable Hypervisor
1
2
3
4
5
bcdedit /copy {current} /d "Windows 10 No Hyper-V"
The entry was successfully copied to {058c531b-e643-11e3-81ef-ecf4bb2c6815}.
bcdedit /set {058c531b-e643-11e3-81ef-ecf4bb2c6815} hypervisorlaunchtype off
The operation completed successfully.

The first commands copies the current boot profile to a new one named Windows 10 No Hyper-V. The second command disables Hyper-V on this copy of the boot profile. Please note we are using the ID of the profile to set this option, it might differ on your side, when creating the copy.

What this basically gives us is a dual boot system where you can pick from the following options (blue window at boot):

  • Windows 10
  • Windows 10 No Hyper-V

This window gives you a few seconds to make your choice. When you didn’t make a choice it will pick the default which is in our case Windows 10.

You can also use the tool bcdedit to check your boot profiles using following command.

Show your boot configuration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
bcdedit /enum
Windows Boot Manager
--------------------
identifier {bootmgr}
device partition=\Device\HarddiskVolume1
description Windows Boot Manager
locale en-US
inherit {globalsettings}
integrityservices Enable
default {current}
resumeobject {058c531a-e643-11e3-81ef-ecf4bb2c6815}
displayorder {058c531b-e643-11e3-81ef-ecf4bb2c6815}
{current}
toolsdisplayorder {memdiag}
timeout 30
Windows Boot Loader
-------------------
...
.....
...

For brevity I left the details of my boot loaders. In your case it should show 1 Windows Boot Manager and 2 Windows Boot Loaders. As you can see the boot manager also has a default configured. In my case I decided to make my Windows 10 No Hyper-V the default as I’m using Virtualbox more often. To do so you can run following command to configure this boot loader as default. Make sure you pick the right ID.

Set a default
1
bcdedit /default {058c531b-e643-11e3-81ef-ecf4bb2c6815}

I also decided to change the order of the entries in the boot manager so it shows the Windows 10 No Hyper-V option first and the Windows 10 option second.

Set a display order
1
bcdedit /displayorder {058c531a-e643-11e3-81ef-ecf4bb2c6815} {otherid}

The timeout by default is 30 seconds, which gives you plenty of time to make your choice. I figured that when I configured my default I barely have to switch the choice. In that case I don’t want to wait 30 seconds for my computer to pick that default. So then I still have to hit enter to not be waiting for this timeout to expire. No big deal right? However waiting for this boot screen also takes a few seconds, and I don’t want to wait for that either. I just want to press the power button and then immediately head out for the coffee machine as any developer would obviously do ;-). As I don’t want to delay the process of booting for 30 seconds I just decreased the timeout to 10 seconds. It still gives me enough time to make a choice when the default is not suitable, but it doesn’t delay to much when I’m not waiting for the boot loader to make the choice myself. This basically leaves me with a booted machine when I take an espresso at the coffee machine instead of a lungo ;-).

Set a timeout
1
bcdedit /timeout 10

There are many more neat tricks you can achieve with bcdedit. Please use following command(s) to figure out more about how to use bcdedit.

bcdedit help
1
2
bcdedit /?
bcdedit /export /?

The first command gives you the global help of bcdedit. The second command gives you some more detailed help on the /export option. I guess I don’t have to explain you can get more details about other commands in a similar way.

I hope this blog post was useful for you, and you didn’t end up with a corrupted Boot loader. Please let me know if you have any valuable additions which I can include in this blog post, by leaving me a comment below.

Share