Using virt-install to create a Ubuntu VM with iso / access to virsh console

installationkvm-virtualizationvirsh

I am trying to set up a Ubuntu server VM (CLI only) on a Debian host (CLI only) using virt-install (version 1.0.1).

But following install:

sudo virt-install --name=<name> --disk path=/home/locadm/kvm/images/ubuntu/bionic-image1.img,format=raw,device=disk,bus=virtio,cache=none --memory=1024 --vcpu=1 --cdrom=./ubuntu-18.04.4-live-server-amd64.iso

I get:

WARNING CDROM media does not print to the text console by default, so you likely will not see text install output. You might want to use –location.
Starting install…
Creating domain… | 0 B 00:00
Connected to domain
Escape character is ^]

There is no response to any keyboard input (except the escape command).
I used this when creating the VM:

--cdrom=<LOCAL PATH TO ISO>

From what i've read I could instead use:

--location=<URL PATH TO INSTALLER> \
--extra-args console=ttyS0

(which may resolve the issue)

but the problem is I have no internet connection so cannot use a url. I have tried mounting the iso file and specifying that as a location but that failed.

Best Answer

I decided to give up on Ubuntu for the time being although this solution would probably work for a ubuntu iso also.

I did the following:

  1. Create disk:

qemu-img create -f raw disk.img +2G

  1. Download netinst VM iso from here:

https://www.debian.org/distrib/netinst

i.e. I copied the file https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.3.0-amd64-netinst.iso to the VM host.

  1. VM setup

virt-install --accelerate --hvm --connect qemu:///system --cdrom debian-10.3.0-amd64-netinst.iso --name <vm_name> --ram 256 --disk path=disk.img,size=3 --vnc

  1. On a Windows 10 machine (on the same network) I set up a SSH tunnel (using Putty / Powershell) for VNC to my new VM:

ssh -N -T <username>@<vm_host_machine> -L 5900:127.0.0.1:5906 -v

I worked out that the port for my new VM was 5906 using the following command on the VM host:

virsh vncdisplay <vm_name>

  1. Back on Windows 10 machine:

I opened "VNC Viewer" and created a new vnc server connection (File > New connection) to "localhost:5900" and voila a GUI with the Debian installer for my new VM popped up!

Convoluted but it works.