How to install KVM on CentOS 7 / RHEL 7 Headless Server

To install KVM on a headless CentOS 7 / RHEL 7 server, follow these steps:

  1. Verify Hardware: Check if your hardware supports virtualization. Run the following command to check:
egrep -c '(vmx|svm)' /proc/cpuinfo

If the output is greater than 0, your hardware supports virtualization.

  1. Install KVM and QEMU:
sudo yum install qemu-kvm qemu-img virt-manager libvirt libvirt-python libvirt-client virt-install virt-viewer bridge-utils
  1. Start and enable libvirtd:
sudo systemctl start libvirtd.service
sudo systemctl enable libvirtd.service
  1. Check if KVM is installed correctly:
virsh list --all
  1. Create a virtual network:
sudo nmcli connection add type bridge con-name br0 ifname br0
sudo nmcli connection modify br0 ipv4.addresses "192.168.122.1/24"
sudo nmcli connection modify br0 ipv4.method manual
sudo nmcli connection modify br0 bridge.stp no
sudo nmcli connection up br0
  1. Create a virtual machine:
virt-install --name=centos7 --ram=2048 --disk path=/var/lib/libvirt/images/centos7.qcow2,size=10 --vcpus=1 --os-type=linux --os-variant=centos7.0 --network bridge=br0 --graphics none --console pty,target_type=serial --location='http://mirror.centos.org/centos/7/os/x86_64/' --extra-args='console=ttyS0,115200n8 serial'

Now, you should have KVM installed on your CentOS 7 / RHEL 7 headless server.

(https://www.wmpg.org)

Leave a Comment