How to run Nested Virtualization on a Mac
Nested virtualization lets you run a virtual machine inside a virtual machine, and though it may sound silly, it's very useful for testing apps. This guide will show you how to do it on a Mac.
I’m a big fan of open-source software, but I couldn’t get the two main open-source virtualization products (QEMU and VirtualBox) to run nested virtualization.
This is because they don’t pass the hardware assisted virtualization feature of the CPU to the virtual machine.
When trying to run KVM inside a Linux VM running on my Mac with VirtualBox or QEMU, I was getting the following error.
$ kvm-ok INFO: Your CPU does not support KVM extensions INFO: For more detailed results, you should run this as root HINT: sudo /usr/sbin/kvm-ok
VMware Fusion to the rescue
It turns out, nested virtualization on a Mac is possible with VMware Fusion*.
It can be enabled by ticking the Enable hypervisor applications in this virtual machine option. This is found in the advanced options of the Processors & Memory screen for the virtual machine you want to run nested virtualization on.
Now when running the kvm-ok command I get the following output.
$ kvm-ok INFO: /dev/kvm exists KVM acceleration can be used
Open-source software is good, but sometimes it lacks certain features, and the only way to get nested virtualization working on a Mac at the time of writing, is to use a commercial product like VMware Fusion*.
What the * means above
Links marked with * are affiliated and can earn us a small commission at no additional cost to you, should you click through and make a purchase. For more details, read How This Site Is Financed.