Install VM from command line with virt-install

This method worked for me:

virt-install --name=centos \
--memory=8196 --vcpus=2 \
--location=/var/lib/libvirt/images/CentOS-7-x86_64-Minimal-1511.iso \
--disk /var/lib/libvirt/images/centos7.qcow2,device=disk,bus=virtio,size=8 \
--network bridge:br0 \
--os-type=linux  \
--nographics \
--extra-args='console=tty0 console=ttyS0,115200n8 serial'

virt-install tries to extract kernel and initrd files from the ISO image. With --debug you can see the whole activities of it including loop-mounting, searching for those files, etc.

Starting install...
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (Installer:182) scratchdir=/var/lib/libvirt/boot
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:184) Preparing mount at /var/lib/libvirt/boot/virtinstmnt.dwcpql
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (OSDistro:65) Attempting to detect distro:
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/.treeinfo
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/Fedora
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/Server
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/Client
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/RedHat
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/CentOS
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/SL
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/directory.yast
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/current/images/MANIFEST
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/daily/MANIFEST
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/current/images/MANIFEST
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/install/netboot/version.info
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/initrd.gz
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (OSDistro:990) Doesn't look like an Ubuntu Distro.
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/VERSION
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/VERSION
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/boot/platform/i86xpv/kernel/unix
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/platform/i86xpv/kernel/unix
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/STARTUP/XNLOADER.SYS
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/images/pxeboot/vmlinuz
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/images/boot.iso
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/boot/boot.iso
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/current/images/netboot/mini.iso
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:169) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.dwcpql/install/images/boot.iso
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] DEBUG (ImageFetcher:205) Cleaning up mount at /var/lib/libvirt/boot/virtinstmnt.dwcpql
[Wed, 03 Jun 2015 07:56:40 virt-install 29692] ERROR (cli:445) Could not find an installable distribution at '/home/yaegashi/debian-8.0.0-amd64-netinst.iso'

I suppose virt-install doesn't support Debian netinst ISO images with --location (but somehow Ubuntu supported?).

To boot a kernel with --extra-args, virt-install needs to have those kernel and corresponding initrd files. --cdrom simply attaches ISO to the guest's CD drive, that's insufficient to work with --extra-args.

If you want use --extra-args, I recommend you to use "netboot" kernel/initrd files by specifying Debian installer URL of your nearest mirror, like --location http://ftp.us.debian.org/debian/dists/stable/main/installer-amd64/ as described in the manual.


The difference is in the iso files that are used.

It's not related to the way virt-install is used (--location used with http URL versus --location used with path to a local iso file).

Here's a command that works when using the Debian online repositories as --location (including getting output to complete the installation until first boot (then two other steps are necessary to finally get into the new VM, but that's another story):

virt-install --virt-type kvm --name test8 --memory 2048 --disk path=/var/lib/libvirt/images/test8-1.qcow2,size=5 --disk path=/var/lib/libvirt/images/test8-2.qcow2,size=2 --location http://ftp.at.debian.org/debian/dists/stable/main/installer-amd64/ --graphics none --extra-args='console tty0 console=ttyS0,115200n8 serial'

You can take the exact same command, but using the above mentioned Centos ISO file as --location, and it works as well (except that the connection to the serial console does not seem to work at first, but in principle the installation starts using --location and the ISO file):

virt-install --virt-type kvm --name test8 --memory 2048 --disk path=/var/lib/libvirt/images/test8-1.qcow2,size=5 --disk path=/var/lib/libvirt/images/test8-2.qcow2,size=2 --location /softwarestorage/CentOS-7-x86_64-Minimal-1511.iso --graphics none --extra-args='console tty0 console=ttyS0,115200n8 serial'

Output is:

Starting install...
Retrieving file .treeinfo...                                                                                                                                                                | 2.2 kB     00:00 ... 
Retrieving file vmlinuz...                                                                                                                                                                  | 9.8 MB     00:00 ... 
Retrieving file initrd.img...                                                                                                                                                               |  73 MB     00:00 ... 
Creating domain...                                                                                                                                                                          |    0 B     00:00     
Connected to domain test8
Escape character is ^]

But if you use the Debian ISO file for --location, you get the error:

virt-install --virt-type kvm --name test8 --memory 2048 --disk path=/var/lib/libvirt/images/test8-1.qcow2,size=5 --disk path=/var/lib/libvirt/images/test8-2.qcow2,size=2 --location /softwarestorage/debian-8.5.0-amd64-CD-1.iso --graphics none --extra-args='console tty0 console=ttyS0,115200n8 serial'

Starting install...
Retrieving file info...                                                                                                                                                                     |  150 B     00:00 ... 
ERROR    Could not find an installable distribution at '/softwarestorage/debian-8.5.0-amd64-CD-1.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 test8
otherwise, please restart your installation.

IMHO this proves that there's something missing / anything "wrong" with the Debian ISO (not sure at the moment where i got it from, but maybe someone can download a fresh one and repeat the tests...)

Tags:

Kvm