Install Centos 7 guest on KVM host

How to install a Centos 7 guest on a KVM host

Download ISO

wget https://mirrors.edge.kernel.org/centos/7/isos/x86_64/CentOS-7-x86_64-NetInstall-1804.iso

Create guest:

virt-install --name test --ram 1024 --disk path=/guests/web-shard-1.qcow2,size=100,bus=virtio,format=qcow2 --vcpus 1 --os-type linux --os-variant centos7.0 --network bridge=br0 --graphics vnc --location=/var/lib/libvirt/boot/CentOS-7-x86_64-NetInstall-1804.iso

Connect to install

On a separate terminal on the host find out what the VNC port is:

virsh dumpxml test | grep vnc

The output will look something like this:


Open a new ssh terminal to the host with a tunnel for VNC:

ssh user@host.example.com -L 5900:127.0.0.1:5900

Installation

If using the NetInstall ISO you need to specify the repo URL, CentOS 7 is here: https://mirrors.edge.kernel.org/centos/7/os/x86_64/