@JS's Notes

Site with notes from my work.

KVM on CentOS 8

My test platform: CentOS Linux release 8.1.1911 (Core)

Requirements

User with root privileges or non-root user with sudo privileges. Make sure that your hardware platform supports virtualization by running the following command:

$ grep -e 'vmx' /proc/cpuinfo   # Intel platforms
$ grep -e 'svm' /proc/cpuinfo   # AMD platforms
$ lsmod | grep kvm              # Confirm that KVM modules are loaded in the kernel

Update your operating system packages and install some essential packages for basic administration:

$ sudo dnf update -y            # Reboot if required
$ sudo dnf install -y curl wget vim unzip epel-release mc
Cockpit installation
$ sudo dnf install cockpit cockpit-machines -y
$ sudo systemctl start cockpit.socket
$ sudo systemctl enable --now cockpit.socket
$ systemctl status cockpit.socket

Add the cockpit service in the system firewall:

$ sudo firewall-cmd --add-service=cockpit --permanent
$ sudo firewall-cmd --reload

To access the cockpit web console, open a web browser and use the following URL:

https://SERVER_IP:9090/
KVM installation
$ sudo dnf module install virt 
$ sudo dnf install virt-install virt-viewer
$ sudo virt-host-validate
  QEMU: Checking for hardware virtualization                                 : PASS
  QEMU: Checking if device /dev/kvm exists                                   : PASS
  QEMU: Checking if device /dev/kvm is accessible                            : PASS
  QEMU: Checking if device /dev/vhost-net exists                             : PASS
  QEMU: Checking if device /dev/net/tun exists                               : PASS
  QEMU: Checking for cgroup 'cpu' controller support                         : PASS
  QEMU: Checking for cgroup 'cpuacct' controller support                     : PASS
  QEMU: Checking for cgroup 'cpuset' controller support                      : PASS
  QEMU: Checking for cgroup 'memory' controller support                      : PASS
  QEMU: Checking for cgroup 'devices' controller support                     : PASS
  QEMU: Checking for cgroup 'blkio' controller support                       : PASS
  QEMU: Checking for device assignment IOMMU support                         : WARN (No ACPI DMAR table found, IOMMU either disabled in BIOS or not supported by this hardware platform)

Start and enable the libvirtd daemon:

$ sudo systemctl start libvirtd.service
$ sudo systemctl enable libvirtd.service
$ systemctl status libvirtd.service
Set up network bridge via Cockpit
  1. From the Cockpit main interface, click on Networking and click Add Bridge button.
  2. Enter the bridge name (e.g br0) and select port devices (e.g enp2s0) representing the Ethernet interface. Then click Apply.
  3. Look at the list of Interfaces, the new bridge should appear there.
Creating and managing VM via Cockpit
  1. From the Cockpit main interface, click on the Virtual Machines option and click on Create VM button.
  2. Enter the Connection, VM Name, Installation Source Type, Installation Source, Storage, Size and Memory Size. The OS Vendor and Operating System should be picked automatically after entering Installation Source. Also, check the option to immediately start the VM, then click Create.
  3. When the guest OS installation is complete, reboot the VM, then go to Disks and detach/remove the cdrom/ISO device/image under the VMs disks. Then click Run to start the VM.