Install KVM on Oracle Linux

|
Last Updated:
|
|

In this tutorial, you will learn how to install KVM on Oracle Linux. KVM, an acronym for Kernel-based Virtual Machine, is an opensource, full virtualization too for Linux systems with Intel-VT or AMD-V based-processors hardware virtualization extensions.

Installing KVM on Oracle Linux

Verify Hardware Virtualization Support on your System

KVM can only be used on systems with Intel or AMD processors. Thus, before you can install KVM, verify the support by executing the command below. The command looks for the CPU flags; Intel vmx (Virtual Machine Extension) or AMD svm (Secure virtual Machine).

grep -iE 'vmx|svm' /proc/cpuinfo
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq monitor vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti tpr_shadow vnmi flexpriority vpid fsgsbase avx2 invpcid rdseed clflushopt md_clear flush_l1d arch_capabilities
vmx flags	: vnmi flexpriority tsc_offset vtpr vapic

If the output has vmx/svm, then you good to go.

If not, then find out how to enable virtualization on your respective machine BIOS.

Similarly, you can use the command below to check Virtualization support.

lscpu | grep Virtualization

Sample output;

Virtualization:                  VT-x
Virtualization type:             full

Installing KVM on Oracle Linux

Once you confirm the virtualization support, proceed to install KVM by executing the command below. In this tutorial, we are using Oracle Linux 9 desktop version.

sudo dnf install virt-manager qemu-kvm libvirt

Dependencies resolved.
========================================================================================================================
 Package                                      Arch      Version                              Repository            Size
========================================================================================================================
Installing:
 libvirt                                      x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream         14 k
 qemu-kvm                                     x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream         66 k
 virt-manager                                 noarch    3.2.0-14.0.1.el9                     ol9_appstream        792 k
Installing dependencies:
 boost-iostreams                              x86_64    1.75.0-6.el9                         ol9_appstream         39 k
 boost-system                                 x86_64    1.75.0-6.el9                         ol9_appstream         15 k
 boost-thread                                 x86_64    1.75.0-6.el9                         ol9_appstream         57 k
 cyrus-sasl                                   x86_64    2.1.27-20.el9                        ol9_baseos_latest     84 k
 daxctl-libs                                  x86_64    73-1.0.1.el9                         ol9_UEKR7             47 k
 edk2-ovmf                                    noarch    20220126gitbb1bba3d77-3.el9_0.1      ol9_appstream        4.1 M
 gnutls-dane                                  x86_64    3.7.3-9.el9                          ol9_appstream         23 k
 gnutls-utils                                 x86_64    3.7.3-9.el9                          ol9_appstream        286 k
 gssproxy                                     x86_64    0.8.4-4.el9                          ol9_baseos_latest    120 k
 gtk-vnc2                                     x86_64    1.3.0-1.el9                          ol9_appstream         46 k
 gvnc                                         x86_64    1.3.0-1.el9                          ol9_appstream        148 k
 ipxe-roms-qemu                               noarch    20200823-9.git4bd064de.el9_0         ol9_appstream        685 k
 keyutils                                     x86_64    1.6.1-4.el9                          ol9_baseos_latest     74 k
 libburn                                      x86_64    1.5.4-4.el9                          ol9_appstream        177 k
 libev                                        x86_64    4.33-5.el9                           ol9_baseos_latest     53 k
 libfdt                                       x86_64    1.6.0-7.el9                          ol9_appstream         34 k
 libisoburn                                   x86_64    1.5.4-4.el9                          ol9_appstream        420 k
 libisofs                                     x86_64    1.5.4-4.el9                          ol9_appstream        227 k
 libnfsidmap                                  x86_64    1:2.5.4-10.el9                       ol9_baseos_latest     71 k
 libpmem                                      x86_64    1.10.1-2.el9                         ol9_appstream        114 k
 librados2                                    x86_64    2:16.2.4-5.0.3.el9                   ol9_appstream        3.4 M
 librbd1                                      x86_64    2:16.2.4-5.0.3.el9                   ol9_appstream        3.0 M
 librdmacm                                    x86_64    37.2-1.el9                           ol9_baseos_latest     77 k
 libtpms                                      x86_64    0.9.1-0.20211126git1ff6fe1f43.el9    ol9_appstream        189 k
 libverto-libev                               x86_64    0.3.2-3.el9                          ol9_baseos_latest     14 k
 libvirt-client                               x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream        382 k
 libvirt-daemon                               x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream        453 k
 libvirt-daemon-config-network                x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream         17 k
 libvirt-daemon-config-nwfilter               x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream         47 k
 libvirt-daemon-driver-interface              x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream        172 k
 libvirt-daemon-driver-network                x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream        209 k
 libvirt-daemon-driver-nodedev                x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream        192 k
 libvirt-daemon-driver-nwfilter               x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream        207 k
 libvirt-daemon-driver-qemu                   x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream        901 k
 libvirt-daemon-driver-secret                 x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream        169 k
 libvirt-daemon-driver-storage                x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream         14 k
 libvirt-daemon-driver-storage-core           x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream        230 k
 libvirt-daemon-driver-storage-disk           x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream         25 k
 libvirt-daemon-driver-storage-iscsi          x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream         22 k
 libvirt-daemon-driver-storage-logical        x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream         27 k
 libvirt-daemon-driver-storage-mpath          x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream         20 k
 libvirt-daemon-driver-storage-rbd            x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream         31 k
 libvirt-daemon-driver-storage-scsi           x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream         22 k
 libvirt-glib                                 x86_64    4.0.0-3.el9                          ol9_appstream         66 k
 libvirt-libs                                 x86_64    8.0.0-8.1.0.1.el9_0                  ol9_appstream        4.6 M
 lzop                                         x86_64    1.04-8.el9                           ol9_baseos_latest     63 k
 mdevctl                                      x86_64    1.1.0-4.el9                          ol9_appstream        751 k
 ndctl-libs                                   x86_64    73-1.0.1.el9                         ol9_UEKR7             94 k
 nfs-utils                                    x86_64    1:2.5.4-10.el9                       ol9_baseos_latest    507 k
 numad                                        x86_64    0.5-36.20150602git.el9               ol9_baseos_latest     38 k
 python3-argcomplete                          noarch    1.12.0-5.el9                         ol9_appstream        100 k
 python3-libvirt                              x86_64    8.0.0-1.el9                          ol9_appstream        352 k
 python3-pyyaml                               x86_64    5.4.1-6.el9                          ol9_baseos_latest    258 k
 qemu-img                                     x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream        2.2 M
 qemu-kvm-audio-pa                            x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream         75 k
 qemu-kvm-block-rbd                           x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream         80 k
 qemu-kvm-common                              x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream        505 k
 qemu-kvm-core                                x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream        4.0 M
 qemu-kvm-device-display-virtio-gpu           x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream         85 k
 qemu-kvm-device-display-virtio-gpu-gl        x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream         68 k
 qemu-kvm-device-display-virtio-gpu-pci       x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream         70 k
 qemu-kvm-device-display-virtio-gpu-pci-gl    x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream         68 k
 qemu-kvm-device-display-virtio-vga           x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream         71 k
 qemu-kvm-device-display-virtio-vga-gl        x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream         68 k
 qemu-kvm-device-usb-host                     x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream         84 k
 qemu-kvm-device-usb-redirect                 x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream         89 k
 qemu-kvm-docs                                x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream        1.2 M
 qemu-kvm-tools                               x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream        304 k
 qemu-kvm-ui-egl-headless                     x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream         70 k
 qemu-kvm-ui-opengl                           x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream         76 k
 qemu-pr-helper                               x86_64    17:6.2.0-11.el9_0.3                  ol9_appstream        462 k
 rpcbind                                      x86_64    1.2.6-2.el9                          ol9_baseos_latest     69 k
 seabios-bin                                  noarch    1.15.0-1.el9                         ol9_appstream         99 k
 seavgabios-bin                               noarch    1.15.0-1.el9                         ol9_appstream         41 k
 sssd-nfs-idmap                               x86_64    2.6.2-2.0.1.el9                      ol9_baseos_latest     42 k
 swtpm                                        x86_64    0.7.0-1.20211109gitb79fd91.el9       ol9_appstream         49 k
 swtpm-libs                                   x86_64    0.7.0-1.20211109gitb79fd91.el9       ol9_appstream         50 k
 swtpm-tools                                  x86_64    0.7.0-1.20211109gitb79fd91.el9       ol9_appstream        139 k
 systemd-container                            x86_64    250-6.0.1.el9_0                      ol9_baseos_latest    581 k
 unbound-libs                                 x86_64    1.13.1-13.el9_0                      ol9_appstream        526 k
 usbredir                                     x86_64    0.12.0-2.el9                         ol9_appstream         50 k
 virt-manager-common                          noarch    3.2.0-14.0.1.el9                     ol9_appstream        1.2 M
 virtiofsd                                    x86_64    1.1.0-4.el9_0                        ol9_appstream        772 k
 xorriso                                      x86_64    1.5.4-4.el9                          ol9_appstream        326 k

Transaction Summary
========================================================================================================================
Install  87 Packages

Total download size: 37 M
Installed size: 144 M
Is this ok [y/N]:y
  • virt-manager is GUI for managing virtual machines through libvirt.
  • qemu-kvm is an open source virtualizer that provides hardware emulation for the KVM hypervisor. It acts as a virtual machine monitor together with the KVM kernel modules, and emulates the hardware for a full system such as a PC and its associated peripherals.
  • libvirt provides API libraries that enables GUI apps such as virt-manager to communicate with libvirtd daemon, a system service libvirtd , and a virsh CLI tool.

If you are running an headless server with no GUI, then it suffices to just run the command below;

sudo dnf install qemu-kvm libvirt virt-install

Once the installation is done, check if KVM modules are loaded;

lsmod | grep -i kvm
kvm_intel             385024  0
kvm                  1122304  1 kvm_intel
irqbypass              16384  1 kvm

Start libvirt management daemon (libvirtd)

According to man pages, the libvirtd program is the server side daemon component of the libvirt virtualization management system. This daemon runs on host servers and performs required management tasks for virtualized guests. This includes activities such as starting, stopping and migrating guests between host servers, configuring and manipulating networking, and managing storage for use by guests. The libvirt client libraries and utilities connect to this daemon to issue tasks and collect information about the configuration and resources of the host system and guests.

Thus, start and enable this service to run on system boot;

sudo systemctl enable --now libvirtd

Check the status;

systemctl status libvirtd

● libvirtd.service - Virtualization daemon
     Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled)
     Active: active (running) since Mon 2022-09-12 19:23:14 EAT; 12s ago
TriggeredBy: ● libvirtd-ro.socket
             ● libvirtd-admin.socket
             ○ libvirtd-tls.socket
             ● libvirtd.socket
             ○ libvirtd-tcp.socket
       Docs: man:libvirtd(8)
             https://libvirt.org
   Main PID: 8537 (libvirtd)
      Tasks: 21 (limit: 32768)
     Memory: 14.1M
        CPU: 293ms
     CGroup: /system.slice/libvirtd.service
             ├─8537 /usr/sbin/libvirtd --timeout 120
             ├─8645 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
             └─8647 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper

Sep 12 19:23:14 localhost.localdomain dnsmasq[8645]: compile time options: IPv6 GNU-getopt DBus no-UBus no-i18n IDN2 DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth crypto>
Sep 12 19:23:14 localhost.localdomain dnsmasq-dhcp[8645]: DHCP, IP range 192.168.122.2 -- 192.168.122.254, lease time 1h
Sep 12 19:23:14 localhost.localdomain dnsmasq-dhcp[8645]: DHCP, sockets bound exclusively to interface virbr0
Sep 12 19:23:14 localhost.localdomain dnsmasq[8645]: reading /etc/resolv.conf
Sep 12 19:23:14 localhost.localdomain dnsmasq[8645]: using nameserver 10.0.2.3#53
Sep 12 19:23:14 localhost.localdomain dnsmasq[8645]: read /etc/hosts - 2 addresses
Sep 12 19:23:14 localhost.localdomain dnsmasq[8645]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Sep 12 19:23:14 localhost.localdomain dnsmasq-dhcp[8645]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Sep 12 19:23:14 localhost.localdomain dnsmasq[8645]: reading /etc/resolv.conf
Sep 12 19:23:14 localhost.localdomain dnsmasq[8645]: using nameserver 10.0.2.3#53

By default, the libvirtd daemon listens for requests on a local Unix domain socket. Using the -l | --listen command line option, the libvirtd daemon can be instructed to additionally listen on a TCP/IP socket. The TCP/IP socket to use is defined in the libvirtd configuration file.

Launching KVM Virtual Machine Manager

If you are running a desktop system, then you can launch the Virtual Machine manager from your applications or command line;

Install KVM on Oracle Linux

To launch it from command line;

virt-manager
Install KVM on Oracle Linux

If you are launching Virt-manager as standard user, you may be prompted to enter your administrator password to run it, “system policy prevents management of local virtualized systems”.

To fix this, add the standard user to libvirt group (Replace USERNAME with your user account).

sudo usermod -aG libvirt USERNAME

And that concludes our simple guide on installing KVM on Oracle Linux.

Other Tutorials

Change Windows Boot Device from IDE to Virtio on KVM

Easy Way to Extend KVM Virtual Machine Disk Size

Start and Stop KVM Virtual Machines from Command Line

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment