How to enable Nested Virtualization in VirtualBox (New Feature)

Share on:

Did you ever want to have labs where you could play with different hypervisors within a single virtual machine on your laptop? I know this sounds more like an INCEPTION remake than a decent requirement but you can’t blame us for being greedy knowing all that tools like VirtualBox can help us do nowadays.

To give more context to this issue. I have been playing with KVM lately when I realized that I was actually installing a Hypervisor inside a guest machine within another Hypervisor. Pretty weird indeed when you think of it, but I only stopped because a tool was complaining that no Hypervisor was recognized.

So, how to make a Hypervisor (KVM) aware of the Host hardware when it’s only installed under another Hypervisor layer (VirtualBox)? This is called nested Virtualization

Well, after digging a little online, it turns out that the latest versions of VirtualBox do provide this feature and it is very simple to enable even after your VM has been provisioned.

 

1. Environment
Host: Intel-based Dell laptop with windows 10
Hypervisor: VirtualBox
Guest OS: Oracle Linux 7
Hypervisor installed within the guest: KVM
Issue description from KVM.org:
For KVM to run from a VM it needs access to a set of CPU instructions (intel VT or AMD) to enable running fully isolated virtual machines at native hardware speeds (HVM ). Learn more.

 

2. Symptoms

In my case the Host CPU socket is intel hence I would be looking whether Intel VT (Virtualization Technology) is listed as virtualization capability on the guest machine.

– So I ran the below which should display 2 if intel Virtualization capability is enabled. I got 0

– Alternatively, you can also check if nested virtualization is enabled in kvm (kvm_intel). Still nothing

3. Solution

All you have to do is to make sure your VirtualBox is of version 6.1.4 and from there you can “activate” nested virtualization. Use either one of the below options.

  • Adding <NestedHWVirt enabled=”true”/> in CPU section of your .vbox file inside your VM folder (usually hidden in windows)
  • Running the following vboxmanage command

Here is the result of to same lsmod command after applying the change.

Another quick way to check if the change is effective is by opening the processor setting tab in VirtualBox.

  • Enable Nested Virtualization on Vagrant
    If you are using vagrant to provision your VM you can also do it by adding below customize line in your vagrant file.

Share on:

More from this Author

Screen Shot 2021 04 06 at 9.46.07 AM

The not so AutoUpgrade (Oracle AutoUpgrade in Windows)

Intro First, before anyone starts sending me print screens about their successful AutoUpgrade, or flexing about how their 100+ databases were smoothly migrated to PDBs over the weekend, I am stopping you right there. This is my honest feedback on the experience I had when trying the tool on a windows environment. It is obviously not... Read More

Oracle VM VirtualBox

My Vagrant fork of Oracle Fleet Patching and Provisioning (FPP)

Intro I have been asked to read about Oracle database fleet management at work but the turnoff was that it relied entirely on OEM. Aggregating both functionalities makes provisioning, in my opinion, cumbersome and unattractive for shops that only want to manage the fleet. Luckily for me, I got acquainted with an even better framework that’s dedicated... Read More

Back to Top