Install KVM on Ubuntu 20.04
In this quick post we will focus on install KVM on Ubuntu 20.04. Kernel-based Virtual Machine (KVM) is an open source virtualization technology built into Linux operating systems. Ubuntu uses KVM as the back-end virtualization technology primarily for non-graphic servers and libvirt as its toolkit/API.
Advertisements
Install KVM on an Ubuntu operating system version 20.04 by following the steps below.
Check if virtualization is supported
egrep -c '(vmx|svm)' /proc/cpuinfo
Run this command to know if virtualization is supported in your Ubuntu system. If the output is 0, it’s not supported and if the output is more than 1, YES!
>egrep -c '(vmx|svm)' /proc/cpuinfo 4
Install KVM on Ubuntu 20.04
>sudo apt install -y qemu qemu-kvm libvirt-daemon libvirt-clients bridge-utils virt-manager
Reading package lists... Done Building dependency tree Reading state information... Done bridge-utils is already the newest version (1.6-2ubuntu1). libvirt-clients is already the newest version (6.0.0-0ubuntu8.4). libvirt-daemon is already the newest version (6.0.0-0ubuntu8.4). libvirt-daemon set to manually installed. qemu-kvm is already the newest version (1:4.2-3ubuntu6.6). The following packages were automatically installed and are no longer required: libfprint-2-tod1 linux-headers-5.4.0-45 linux-headers-5.4.0-45-generic linux-image-5.4.0-45-generic linux-modules-5.4.0-45-generic linux-modules-extra-5.4.0-45-generic Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: gir1.2-appindicator3-0.1 gir1.2-gtk-vnc-2.0 gir1.2-libosinfo-1.0 gir1.2-libvirt-glib-1.0 gir1.2-spiceclientglib-2.0 gir1.2-spiceclientgtk-3.0 libgovirt-common libgovirt2 libgtk-vnc-2.0-0 libgvnc-1.0-0 libosinfo-1.0-0 libphodav-2.0-0 libphodav-2.0-common libspice-client-glib-2.0-8 libspice-client-gtk-3.0-5 libusbredirhost1 libvirt-glib-1.0-0 osinfo-db python3-libvirt python3-libxml2 spice-client-glib-usb-acl-helper virt-viewer virtinst Suggested packages: libosinfo-l10n gstreamer1.0-libav gstreamer1.0-plugins-bad python3-guestfs ssh-askpass The following NEW packages will be installed: gir1.2-appindicator3-0.1 gir1.2-gtk-vnc-2.0 gir1.2-libosinfo-1.0 gir1.2-libvirt-glib-1.0 gir1.2-spiceclientglib-2.0 gir1.2-spiceclientgtk-3.0 libgovirt-common libgovirt2 libgtk-vnc-2.0-0 libgvnc-1.0-0 libosinfo-1.0-0 libphodav-2.0-0 libphodav-2.0-common libspice-client-glib-2.0-8 libspice-client-gtk-3.0-5 libusbredirhost1 libvirt-glib-1.0-0 osinfo-db python3-libvirt python3-libxml2 qemu spice-client-glib-usb-acl-helper virt-manager virt-viewer virtinst 0 upgraded, 25 newly installed, 0 to remove and 26 not upgraded. Need to get 2,498 kB of archives. After this operation, 16.9 MB of additional disk space will be used.
Check status of virtualization daemon
Run the following command to check if the virtualization service is running.
> sudo systemctl status libvirtd
● libvirtd.service - Virtualization daemon Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2020-10-07 09:00:35 IST; 8min ago TriggeredBy: ● libvirtd-ro.socket ● libvirtd-admin.socket ● libvirtd.socket Docs: man:libvirtd(8) https://libvirt.org Main PID: 5199 (libvirtd) Tasks: 19 (limit: 32768) Memory: 16.0M CGroup: /system.slice/libvirtd.service ├─5199 /usr/sbin/libvirtd ├─5376 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper └─5377 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper Oct 07 09:00:35 anandBuntu systemd[1]: Started Virtualization daemon. Oct 07 09:00:36 anandBuntu dnsmasq[5376]: started, version 2.80 cachesize 150 Oct 07 09:00:36 anandBuntu dnsmasq[5376]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify dumpfile Oct 07 09:00:36 anandBuntu dnsmasq-dhcp[5376]: DHCP, IP range 192.168.122.2 -- 192.168.122.254, lease time 1h Oct 07 09:00:36 anandBuntu dnsmasq-dhcp[5376]: DHCP, sockets bound exclusively to interface virbr0 Oct 07 09:00:36 anandBuntu dnsmasq[5376]: reading /etc/resolv.conf Oct 07 09:00:36 anandBuntu dnsmasq[5376]: using nameserver 127.0.0.53#53 Oct 07 09:00:36 anandBuntu dnsmasq[5376]: read /etc/hosts - 8 addresses Oct 07 09:00:36 anandBuntu dnsmasq[5376]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses Oct 07 09:00:36 anandBuntu dnsmasq-dhcp[5376]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Enable it to run on boot
Advertisements
sudo systemctl enable --now libvirtd
Validate KVM installation
> lsmod | grep -i kvm kvm_intel 282624 0 kvm 663552 1 kvm_intel