2018-01-02 16:18:48 +01:00
[[proc_enabling-nested-virtualization-in-kvm]]
2018-01-02 15:46:03 +01:00
= Enabling nested virtualization in KVM
2017-12-14 14:07:48 +10:00
2018-01-02 16:18:48 +01:00
Nested virtualization allows you to run a virtual machine (VM) inside another VM while still using hardware acceleration from the host.
2017-12-14 14:07:48 +10:00
== Checking if nested virtualization is supported
2018-01-02 16:18:48 +01:00
For Intel processors, check the `/sys/module/kvm_intel/parameters/nested` file. For AMD processors, check the `/sys/module/kvm_amd/parameters/nested` file. If you see `1` or `Y`, nested virtualization is supported; if you see `0` or `N`, nested virtualization is not supported.
2017-12-14 14:07:48 +10:00
For example:
2018-01-02 16:18:48 +01:00
----
2021-01-27 12:28:18 +08:00
cat /sys/module/kvm_intel/parameters/nested
2017-12-14 14:07:48 +10:00
Y
2018-01-02 16:18:48 +01:00
----
2017-12-14 14:07:48 +10:00
== Enabling nested virtualization
To enable nested virtualization for Intel processors:
2017-12-14 09:49:59 +05:30
2017-12-14 09:48:58 +05:30
. Shut down all running VMs and unload the `kvm_probe` module:
+
2017-12-14 14:07:48 +10:00
----
2021-01-27 12:28:18 +08:00
sudo modprobe -r kvm_intel
2017-12-14 14:07:48 +10:00
----
2017-12-14 09:48:58 +05:30
. Activate the nesting feature:
+
2017-12-14 14:07:48 +10:00
----
2021-01-27 12:28:18 +08:00
sudo modprobe kvm_intel nested=1
2017-12-14 14:07:48 +10:00
----
2018-01-02 15:46:03 +01:00
+
2017-12-14 09:48:58 +05:30
. Nested virtualization is enabled until the host is rebooted. To enable it permanently, add the following line to the `/etc/modprobe.d/kvm.conf` file:
+
2017-12-14 14:07:48 +10:00
----
options kvm_intel nested=1
----
To enable nested virtualization for AMD processors:
2017-12-14 09:49:59 +05:30
2017-12-14 09:48:58 +05:30
. Shut down all running VMs and unload the `kvm_amd` module:
+
2017-12-14 14:07:48 +10:00
----
2021-01-27 12:28:18 +08:00
sudo modprobe -r kvm_amd
2017-12-14 14:07:48 +10:00
----
2017-12-14 09:48:58 +05:30
. Activate the nesting feature:
+
2021-08-22 17:13:47 +02:00
----
2021-01-27 12:28:18 +08:00
sudo modprobe kvm_amd nested=1
2017-12-14 14:07:48 +10:00
----
2017-12-14 09:48:58 +05:30
. Nested virtualization is enabled until the host is rebooted. To enable it permanently, add the following line to the `/etc/modprobe.d/kvm.conf` file:
+
2021-08-22 17:13:47 +02:00
----
2017-12-14 14:07:48 +10:00
options kvm_amd nested=1
----