Wednesday, June 19, 2019

Install and Configure KVM on Ubuntu 18.04

We can use VirtualBox or KVM on Ubuntu to do virtualization, we often use virtual machine for development, not necessarily on a server, we can use KVM on Ubuntu Desktop.

To setup KVM on Ubuntu 18.04, perform the following steps:

Nested Virtualization KVM on CentOS 7

Nested Virtualization is disabled by default on CentOS 7, we can verify by running a command:

# cat /sys/module/kvm_intel/parameters/nested

Make sure KVM is intalled on the machine, if output is N, then Nested Virtualization is disabled, to enable the feature, set options kvm-intel nested=1 in /etc/modprobe.d/kvm-nested.conf

# echo "options kvm-intel nested=1" > /etc/modprobe.d/kvm-nested.conf

Reboot the machine, and verify like above command.
On the xml configuration, ensure cpu mode is host-passthrough

To use nested virtualization, the host CPU must have the necessary feature flags: For Intel - vmx (Hardware Virtualization) and ept (Extended Page Tables) For AMD - svm (equivalent to vmx) and npt (equivalent to ept) Check that flag on /proc/cpuinfo