Install KVM guest using VNC

It's simple enough to install a headless (without display) distro using KVM, but when it comes to installing a guest with a user interface, this needs to be done over VNC, and here's how to do it:

sudo virt-install --name YOUR-VM-NAME --ram 12288 --disk path=~/kvm/images/DISK-NAME.qcow2,size=100 --vcpus 8 --os-type linux --os-variant generic --network bridge=br0 --graphics vnc,listen= --noautoconsole --cdrom /home/base4/ubuntu-17.04-desktop-amd64.iso

The important part of the above command are the following two parameters:

--graphics vnc,listen=

--graphics vnc,listen= instructs virt-install to use a VNC display

--noautoconsole instructs virt-install not to wait for a console connection

By default VNC will use the first available screen on port 5900. To check this you can run the following command on the HOST:

sudo virsh vncdisplay YOUR-VM-NAME

The following should be returned:


To check that VNC is running on port 5900:

netstat -tln|grep :59

The following should be returned:

tcp 0 0* LISTEN

The final step to connect to VNC of the guest VM is to open your VNC viewer on any PC on the same network and connect using the following:


Where is the address of the HOST and 5900 is the default VNC port.

You will now connect up to the VM using VNC to complete the installation using the GUI.