How to enable nested virtualization
For Windows host enable VT-X for processor on Ubuntu linux are as below:
Set-VMProcessor -VMname BOTOP
-ExposeVirtualizationExtensions $true
Set-VMProcessor -VMname BOT-IVRCRM
-ExposeVirtualizationExtensions $true
------------------------
Check if the required kernel module for your CPU is already loaded. Hosts with Intel CPUs require the kvm_intel
module while AMD hosts require kvm_amd
instead:
$ lsmod | grep -i kvm
kvm_intel 204800 0
kvm 1347584 1 kvm_intel
If the module is already loaded, you can check if nested virtualization is enabled by running the following command:
cat /sys/module/<module>/parameters/nested
As an example for AMD hosts:
$ cat /sys/module/kvm_amd/parameters/nested
1
If the output is either 1
or Y
then nested virtualization is enabled and you will not need to manually enable the feature (this should be the case for Ubuntu users).
If the module your host requires is not loaded you can load it using modprobe
and add the property nested=1
to enable nested virtualization as shown below for Intel hosts:
modprobe kvm-intel nested=1
Or as follows for AMD hosts:
modprobe kvm-amd nested=1
If the above checks indicate that nested virtualization is not enabled, you can follow the below steps to enable it.
Create a file in /etc/modprobe.d
-e.g., /etc/modprobe.d/kvm.conf
- and add the line options kvm-intel nested=1
to that file (replace kvm-intel
with kvm-amd
for AMD hosts).
Reload the kernel module to apply the changes:
sudo modprobe -r <module>
Example for Intel hosts:
sudo modprobe -r kvm-intel
- You should now be able to see nested virtualization enabled:
Example for Intel hosts:
$ cat /sys/module/kvm_intel/parameters/nested
Y
Once the host is ready to use nested virtualization it is time to check if the guest instance where the other instance(s) are going to run is able to host these nested VMs.
To determine if an instance can host another instance on top, run the below command within the instance:
egrep "svm|vmx" /proc/cpuinfo