Knowledge: Using virt-install for KVM Guest Installations

The most simple way to install KVM guests is to use a tool called virt-install, which wraps the installation in a single command. virt-install is being developed as a supporting tool for virt-manager. Depending on the host distribution, this program is part of a package called virt-install or virtinst, which has to be installed with the distribution’s respective packaging tools.
All examples below were tested with virt-install v1.4.3.

Installation from ISO

In our examples for regular installs, we always describe the bare minimum virtual machine configuration, i.e. consisting of a single virtual CD/DVD drive, a single virtio disk (backed by a QEMU image) and a virtio network interface attached to the libvirt default network.
Using virt-install, installation of such a KVM guest,
e.g. on Ubuntu 18.04 (aka Bionic Beaver), can be achieved in a single command as follows:
   $ virt-install --name bionic --disk size=10 --memory=2000 \
       --cdrom /var/lib/libvirt/images/bionic-server-s390x.iso
This will define and start the virtual machine, boot the ISO image (Ubuntu 18.04), and bring up the serial console with the installer up and running. Now all that is left to be done is to follow the installation instructions, let the guest reboot, and you are done!
However, note that the virtual machine is not yet configured for maximum efficiency. Fine-tuning can be done using virsh edit according to our disk performance hints & tips.

Network Installation

As seen, virt-install does not require the user to create an XML domain definition file. Besides, it can help to avoid downloading the ISO at all, at least for some distributions! This is possible due to virt-install understanding the repository structures of the most common distributions. E.g., to install an instance of Debian 9, you can use the following command:
   virt-install --name stretch --disk size=10 --memory=2000 --location \
This will fetch the necessary binaries, i.e. installer kernel and initial ramdisk, from the web server, and start the VM using these instead of an ISO image.
Another interesting feature that can be used in combination with the location-based installation is the possibility to pass additional kernel parameters to the installer system. This allows to perform an unattended installation by providing a respective configuration file:
  • kickstart file for Red Hat installs,
  • autoyast for SUSE, or
  • preseed Ubuntu, Debian, or any of its other derivatives.
It is even possible to have the configuration file inserted into the initial ramdisk on the fly:
   virt-install --name fedora --disk size=10 --memory=2000 --location \ \
       --initrd-inject=f28.ks --extra-args inst.ks=file:///f28.ks
For example, the following minimal kickstart file can be used for an unattended Fedora 28 install:
   ignoredisk --only-use=vda
   clearpart --all
   bootloader --location=mbr --driveorder=vda
   rootpw super!secret:-O
   timezone Europe/Athens

Distributions for IBM Z and LinuxONE

Some distributions do not offer bootable ISO images, while others do not have publicly accessible repositories. The following table contains an overview of the tested setups. Note that older Linux distribution releases may require manual tweaks to work.

Repository Install
Alpine Linux 3.8.0 Yes -
ClefOS 7.4 or later No
Debian Stretch (9.4) or later No
Fedora 28 or later No
openSUSE Factory Yes
RHEL 7.5 Yes -
SLES 12 SP2 or later Yes -
Eoan (20.04) or later

To work around distros not offering a bootable ISO image, it is still possible to mount the image in the host and to boot the install kernel and initial ramdisk. However, it will be necessary to provide some kind of network access to the contents of the ISO or to a repository.
In case there is no publicly accessible repository for a distribution, it still may be possible to set up a local repository on-site. Check your distribution's documentation for details.
Likewise, even if a public repository exists, it may be worthwhile to set up a local mirror of that repository to speed up installations.


virt-install offers a variety of possibilities to install KVM guests easily. We have highlighted the two most common scenarios: Installing from an ISO image or a remote repository. More options exist, e.g. by directly booting install kernels, or using PXE for network installs. But they require additional setup beyond the scope of this article.


virt-install man page:

virt-install examples on Ubuntu:

1 comment:

  1. virt-install recently got mediated device support for ccw host devices. This means we can easily install directly onto a passed through dasd disk: virt-install ... --hostdev ,address.type=ccw,address.cssid=0xfe,address.ssid=0x0,address.devno=0x1111 --disk none --extra-args "rd.dasd=1111"