Shammer's Philosophy

My private adversaria

Create VM with virt-install on KVM

There is a command to create VMs in KVM, it is virt-install.
This is an alternative of virt-manager which is a GUI management appliction for KVM to enable a lot of management operations for KVM host specified in creating VMs.
For example, following command can create Debian wheezy or jessie VM.

# virt-install -n VM1 --os-type=Linux --os-variant=debianwheezy --ram=512 --vcpus=1 --disk pool=default,size=16,format=qcow2 --serial pty --console pty --location /var/lib/libvirt/images/ISO/XXX.iso --network bridge:$BridgeName

But, there is a problem. When creating Debian, --location option can't work correctly like below.

# virt-install -n VM1 --os-type=Linux --os-variant=debianwheezy --ram=512 --vcpus=1 --disk pool=default,size=16,format=qcow2 --console pty --serial pty --location /var/lib/libvirt/images/debian-8.6.0-amd64-netinst.iso --network bridge:mgmtbr
WARNING  No 'console' seen in --extra-args, a 'console=ttyS0' kernel argument is likely required to see text install output from the guest.

Starting install...
Retrieving file info...                                  |  160 B     00:00 ... 
ERROR    Could not find an installable distribution at '/var/lib/libvirt/images/debian-8.6.0-amd64-netinst.iso'
The location must be the root directory of an install tree.
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///system start VM1
otherwise, please restart your installation.
#

According to other site, the reason is in a Debian ISO file. Workaround is using --cdrom option instead of --location, but there is no output about installation progress information on console. Console stops like below.

# virt-install -n VM2 --os-type=Linux --os-variant=debianwheezy --ram=512 --vcpus=1 --disk pool=default,size=16,format=qcow2 --console pty --serial pty --cdrom /var/lib/libvirt/images/debian-8.6.0-amd64-netinst.iso --network bridge:mgmtbr
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...
Allocating 'VM2.qcow2'                                   |  16 GB     00:00     
Creating domain...                                       |    0 B     00:00     
Connected to domain VM2
Escape character is ^]

...(No output anymore)

This is bothering... I want to know about progress but there is no information output. At this point, installation process doesn't progress, installation process stopped at the TOP of installation screen.
There is a workaround also, it is using --graphics option and enables VCS. Command is like below.

# virt-install -n VM3 --os-type=Linux --os-variant=debianwheezy --ram=512 --vcpus=1 --disk pool=default,size=16,format=qcow2 --graphics vnc,port=5903,listen=0.0.0.0,password=XXXXXXXX --console pty --serial pty --cdrom /var/lib/libvirt/images/debian-8.6.0-amd64-netinst.iso --network bridge:mgmtbr

Using above option, virt-install will be finished within a second but installation process still exists and VNC client can connect the session.
If there is a VNC client, --graphics option is helpful when installing DebianVM with virt-install. If there is no VNC client or you hate preparing it, virt-manager might be an only way to create DebianVM on KVM.