By default nested virtualization in Oracle VM VirtualBox on linux system is disabled. With the release of VirtualBox 6.1 we can enable nested virtualization on Intel CPUs starting with 5th generation Core i.
Prerequisites for VirtualBox Nested Virtualization:
- VirtualBox Version 6.1 or higher
- AMD CPU / Intel CPU ( Core i5 or higher)
In article we will demonstrate how to enable nested virtualization on Intel CPUs for VirtualBox VM on Linux.
Install / Upgrade VirtualBox to latest version
Note: You can Skip this step if already have VirtualBox 6.1 on your Linux system
At time of writing this article, latest version of VirtualBox is 6.1, so in case you are running an older version of virtualbox on system then run the following commands to install and upgrade it.
For Ubuntu / Debian
linuxtechi@ubuntu:~$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - linuxtechi@ubuntu:~$ wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - linuxtechi@ubuntu:~$ sudo add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" linuxtechi@ubuntu:~$ sudo apt-get update linuxtechi@ubuntu:~$ sudo apt-get install virtualbox-6.1 -y
If you get the following error message while starting or creating a VM after upgrading VirtualBox,,
To resolve this issue, execute the following commands
linuxtechi@ubuntu:~$ sudo apt-get remove virtualbox-dkms -y linuxtechi@ubuntu:~$ sudo /sbin/vboxconfig
For CentOS / RHEL / Fedora
Create VirtualBox 6.x repo file with following contents,
[root@linuxtechi ~]# vi /etc/yum.repos.d/virtualbox.repo [virtualbox] name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox baseurl=http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
save and exit the file,
Run below Yum / DNF command to install virtualbox 6.1
[root@linuxtechi ~]# yum install VirtualBox-6.1 -y or [root@linuxtechi ~]# dnf install VirtualBox-6.1 -y
Note: In case on your Linux system, if VirtualBox 6 repository is already configured then skip the repository configuration part, You can directly install or upgrade virtualbox.
Enable Nested Virtualization for VirtualBox VM
Let’s suppose i have a centos vm on my virtualbox, i want to enable nested virtualization for this vm, before enabling it login to vm console and execute the following command,
# grep -E --color 'vmx|svm' /proc/cpuinfo
Above command’s blank output confirms that nested virtualization is not enabled on centos vm.
Let’s power off this VM and enable VT-x /AMD-v , Select the VM for which you want to enable nested virtualization, then click on settings. Under the System Tab, select Processor and click on “Enable Nested VT-x/AMD-v” under the Extended Features Tab,
click on Ok to save the changes
In case “enable Nested VT-x/AMD-v” is greyed out then we can enable it via command line , execute the following command,
$ VBoxManage modifyvm <VM-Name> –nested-hw-virt on
Example :
linuxtechi@ubuntu:~$ VBoxManage modifyvm ubuntu18 --nested-hw-virt on
Now let’s verify from Centos VM whether nested virtualization is enabled or not, power on the VM and login to console and run following commands,
# egrep -E –color ‘svm|vmx’ /proc/cpuinfo # lscpu
Output of above commands confirm that Nested Virtualization has been enabled on CentOS VirtualBox VM.
That’s all from this article, I hope this article was informative and you get better understanding on how to enable Nested VT-x / AMD-v feature on Oracle VM VirtualBox. Please don’t hesitate to share your feedback and comments.
Here is an official confirmation in VirtualBox doc: ‘https://www.virtualbox.org/manual/ch03.html’ Chapter 3.5.2. Processor Tab
Enable Nested VT-x/AMD-V: Enables nested virtualization, with passthrough of hardware virtualization functions to the guest VM.
This feature is available on host systems that use an AMD CPU. For Intel CPUs, the option is grayed out.
And I can confirm, it doesn’t work on Intel(R) Xeon(R) CPU E5540
Hello I tried enabling the nested virtualization but got an error: “Cannot enable nested VT-x/AMD-V without nested-paging and unrestricted guest execution! (VERR_CPUM_INVALID_HWVIRT_CONFIG). Result Code: NS_ERROR_FAILURE (0x80004005) Component: ConsoleWrap Interface: IConsole {etc…}. Tried executing command you wrote with sudo and still it won’t open in VB. Any ideas? Thanks
Perhaps this will solve your problem too.
My host OS was Windows 10 (build 2004 – April 2020) that I was running VirtualBox on (as opposed to a Linux host in the article). I had this same error, “Cannot enable nested VT-x/AMD-V without nested-paging and unresricted guest execution!”.
Then I found this thread: ‘https://nullrend.com/11909/verr_cpum_invalid_hwvirt_config/’
The problem I was having was that Windows Hyper-V was interfering with VirtualBox. Perhaps this can happen on other host OSes too where another hypervisor, like KVM, interferes with VirtualBox.
My problem was fixed once I executed the following command and rebooted my Windows 10 host:
Disable-WindowsOptionalFeature -online -FeatureName VirtualMachinePlatform
i create vm in vbox to running docker, but its containers can’t ping outsite the world. i think it cause nested is disabled. but after i enable i have same problem