Loading...
Loading...
Marco Franssen

I've been using VirtualBox and Vagrant for web development with Linux, Nginx, and Node.js for a while now. However, I still do Windows development occasionally. I needed an easy way to switch between VirtualBox and Hyper-V, which is required for the Windows Phone emulator, for example.
In this setup, Hyper-V can't run alongside VirtualBox because they both need a hypervisor. Unfortunately, you can't have two hypervisors running, so we need to disable Hyper-V when we want to use VirtualBox. That's not as simple as it sounds.
What I wanted to achieve was the following:
Some web pages advise disabling Hyper-V through Add/Remove Features. However, that means reinstalling it when we need it again, so it wasn't really a solution for me. The other option is to create multiple Windows boot profiles and pick one when starting the computer. It's not ideal—you have to reboot to switch—but at the time of writing, it was the only solution available to me.
We're going to modify the boot loader, so pay extra attention: we don't want to leave the computer in a corrupted state. If you're not comfortable with this, ask a local expert to help. First, let's back up the boot configuration using the /export option. Make sure you're running these commands from an elevated (administrator) Command Prompt.
bcdedit /export backup.bcdIf you think you've messed up somewhere in the process, restore the original settings from your backup. The backup is located in the directory where you ran the export.
bcdedit /import backup.bcdTo create a second boot profile, run the following commands.
$ 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 command copies the current boot profile to a new one named Windows 10 No Hyper-V. The second disables Hyper-V for that copy. Note that we're using the new profile's ID to set this option; the ID you get when creating your copy may differ.
This gives us two boot profiles to choose from in the blue boot menu:
This menu gives you a few seconds to make your choice. If you don't choose, it uses the default, which in our case is Windows 10.
You can also use bcdedit to check your boot profiles with the following command.
$ 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've left out the details of my boot loaders. In your case, the output should show 1 Windows Boot Manager and 2 Windows Boot Loaders. As you can see, the boot manager also has a default configured. I decided to make Windows 10 No Hyper-V the default because I use VirtualBox more often. Run the following command to set this boot profile as the default, making sure you use the right ID.
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.
bcdedit /displayorder {058c531a-e643-11e3-81ef-ecf4bb2c6815} {otherid}The default timeout is 30 seconds, which gives you plenty of time to choose. Once I'd configured my default, though, I rarely needed to change the selection. I didn't want to wait 30 seconds for the computer to pick it, or press Enter every time to skip the wait. No big deal, right? Still, I just want to press the power button and head straight for the coffee machine, as any developer would obviously do ;-). So I decreased the timeout to 10 seconds. That gives me enough time to choose another profile without delaying startup too much when I'm away. Basically, it leaves me with a booted machine even if I get an espresso instead of a lungo ;-).
bcdedit /timeout 10There are plenty of other neat tricks you can do with bcdedit. Use the following commands to learn more.
bcdedit /?
bcdedit /export /?The first command shows the general help for bcdedit. The second gives you more detailed help for the /export option. You can get details about other commands in the same way.
I hope this post was useful and you didn't end up with a corrupted boot loader. If you have any useful additions I can include, let me know in a comment below.
Marco Franssen
Learn how to replace Node.js error-first callbacks with Promises, flatten nested asynchronous code, and wrap callback APIs with practical examples.
Marco Franssen
Use the original Let's Encrypt client in a Vagrant VM to request an Azure website certificate through a reverse proxy, then export and upload a PFX.
Marco Franssen
Compare Jasmine 2.4 and Mocha 2.3, including test structure, Chai assertions, Sinon spies and asynchronous testing with callbacks and promises.
Marco Franssen
Configure SSH keys, Pageant, agent forwarding, and Git Bash on Windows to work with Linux VMs and Git without repeatedly entering key passphrases.