Warning: While this worked on my 15" MacBook Pro (mid 2014, EMC 2881), and newer models based on the comments below, this messes with the Model Specific Registers on your Intel processor. Also, this WILL NOT WORK on AMD-based systems...should Apple ever release one. Before proceeding, ensure that rEFInd is supported for your specific Mac/processor. By following any of the steps outlined below, you agree to not hold me liable for any damages. You've been warned!
Ok, if you're at this point, you've agreed to chance fate. So, I got fed up that Apple's UEFI BIOS doesn't set VT-x enabled by default when a Boot Camp partition is started by default. Having to boot into OS X, then reboot into Windows just so I can use Hyper-V/Docker is a huge time suck, and a bit ridiculous.
I sat out to find a solution, and had a hard time digging up information. I stumbled upon a possible solution from 10 years ago using rEFIt, an EFI-based shell from ArchLinux, and some hacky EFI app to enable it, but the hacky solution only works for 32-bit mode...not 64-bit.
After researching about rEFIt, I found a newer version called rEFInd. Turns out, it has the option to enable VT-x and lock it when it starts up. If you're not familiar with rEFInd, it's a boot loader (similar to Grub) that is specifically built for EFI-based systems. By using this bootloader to start Windows, VT-x will be enabled before the Windows kernel gets started, and Hyper-V will always work without a reboot into OS X.
- Go here and download rEFInd (the zip version): http://www.rodsbooks.com/refind/getting.html
- Extract the zip to a folder, open the refind folder and edit refind.conf-sample.
- In refind.conf-sample:
Set the timeout to 5 seconds (or whatever you want)
Find enable_and_lock_vmx, uncomment the line and set it to true (HERE BE DRAGONS)
- Shut down your computer.
- After powering back up, press and hold Command+R before the chime/apple logo appears to boot into Apple Recovery.
- Once in Apple Recovery, go to Utilities -> Terminal, and execute the following to disable System Integrity Protection (necessary for writing to the EFI - http://www.rodsbooks.com/refind/sip.html)
csrutil disable
- Reboot into your normal OSX installation, and open a terminal window
- Navigate to the folder where you extracted rEFInd, and run
./refind-install
- Note: The installer will copy the refind.conf-sample file to EFI/refind/refind.conf on your ESP partition. If you need to change settings later on, you'll have to mount the partition first (use the first two commands from the uninstall instructions below to mount it.)
- Reboot your Mac and go back into recovery mode by pressing Command+R. (Now, your Mac may freeze. If it does, press and hold the power button until the LCD turns off, then turn it back on.)
- Once in Apple Recovery, go to Utilities -> Terminal, and execute the following to turn back on System Integrity Protection
csrutil enable
- Reboot your Mac
You'll be greeted by a GUI bootloader menu, which will load whatever OS you sat as your default. In my case, this was Windows, and Hyper-V worked flawlessly from a cold boot!
Troubleshooting:
If for some reason rEFInd is not working, power off the Mac, hold the Option key and power back on. Keep holding Option until you get to the UEFI bootloader menu, and you can boot back into OSX.
If you change your default boot OS via Boot Camp, it may stop rEFInd from loading in the future. Just re-run the installer after changing the default boot OS, and it should fix the issue.
Uninstall:
If you need to uninstall rEFInd, boot back into Apple Recovery, go to Terminal, and (assuming your EFI partition is disk0s1) run the following:
mkdir /Volumes/ESP
mount -t msdos /dev/disk0s1 /Volumes/ESP
rm -R -f /Volumes/ESP/EFI/refind
umount /Volumes/ESP
Once that's complete, exit Terminal, click on the Apple menu in the upper left corner, and open Startup Disk. Select the disk you want to start by default, and reboot.