In this tutorial, we’ll install KVM on Arch Linux and set Kernel modules required to automatically load at boot. We’ll also install a guest machine running CentOS 7.2.
Our previous tutorials on KVM include:
First step is installing all packages needed to run KVM:
Install ebtables package:
# pacman -S iptables
Enable and start libvirtd daemon:
Status show it’s running:
# root at darkpy in ~ [21:36:22]
→ systemctl status libvirtd.service
● libvirtd.service – Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2016-03-26 21:36:22 EAT; 1s ago
Main PID: 9725 (libvirtd)
├─8315 /sbin/dnsmasq –conf-file=/var/lib/libvirt/dnsmasq/default.conf –leasefile-ro –dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
Mar 26 21:36:22 darkpy systemd: Stopping Virtualization daemon…
Mar 26 21:36:22 darkpy systemd: Stopped Virtualization daemon.
Mar 26 21:36:22 darkpy systemd: Started Virtualization daemon.
Mar 26 21:36:22 darkpy dnsmasq: read /etc/hosts – 2 addresses
Mar 26 21:36:22 darkpy dnsmasq: read /var/lib/libvirt/dnsmasq/default.addnhosts – 0 addresses
Mar 26 21:36:22 darkpy dnsmasq-dhcp: read /var/lib/libvirt/dnsmasq/default.hostsfile
Mar 26 21:36:23 darkpy libvirtd: libvirt version: 1.3.2
Enable Nested virtualization for kvm_intel
To make it permanent,do:
Then add below line and save the file:
One line command that can be used is:
You can also achieve the same by modifying ‘GRUB_CMDLINE_LINUX‘ line in /etc/default/grub/
Add kvm-intel.nested=1 to GRUB_CMDLINE_LINUX line
Then update grub:
Confirm that Nested Virtualization is set to Yes:
# root at darkpy in ~ [21:52:26]
→ systool -m kvm_intel -v | grep nested
# root at darkpy in ~ [21:55:17]
→ cat /sys/module/kvm_intel/parameters/nested
# root at darkpy in ~ [22:06:47]
→ modinfo kvm_intel | grep nested
After successful installation, you are ready to install a Linux or Windows OS. I did the installation of CentOS 7.2 Server using the Virt-install command.Virt Manager can also be used for this purpose.
Then launch installation:
Edit configuration settings and complete the installation process.
Since I want to set nested Virtualization on this Virtual Machine, I’ll edit it as follows:
- Make vim default editor for virsh
Add following lines to the end of the file:
- Save and exit. Then source it:
- Edit centos-server xml file
Look for CPU mode section, my original look like this
Then change the mode from “custom” to “host-passthrough“. This will Export host CPU model to guest CPU.
- Save and quit
Launch Virtual Machine added:
For more details on working with virsh, check: virsh commands cheatsheet to manage KVM guest virtual machines
To check if nested virtualization for KVM is working, boot the guest machine, then check using:
As you can see, we’re using kernel modules for the host machine on KVM. Hope Complete Installation of KVM, QEMU and Virt Manager on Arch Linux and Manjaro article was helpful.
To manage Virtual Disk Images of VMs on KVM, refer to: