Fast path to a running guest - virt-install

With a single virt-install command, configure and define a virtual server, and install and run a guest.

Before you begin:
  • You need a source for your guest installation. The source can be an ISO file in the host file system, or a Web location that provides the installation files.
  • Ensure that virt-install is available. Depending on your distribution, the package name for this tool might be virtinst or virt-install.
  • Use virt-xml to run a transient guest without defining a virtual server that persists beyond the guest shutdown.

The sections that follow show basic examples for running a virt-install command. See the man page for more options.

Installing from an ISO file

Issue a command of this form:
# virt-install --name=<vs_name> --disk size=<disk_size_in_GB> --memory=<vs_memory_size_in_MB> \
--cdrom <filepath_to_iso>
In the command:
<vs_name>
is the name of the virtual server to be created.
<disk_size_in_GB>
is the size, in GB, of the virtual disk on which the guest is to be installed. The disk is backed by an image file in the file system of the host.
<vs_memory_size_in_MB>
is the size, in MB, of the memory of the virtual server to be created.
<filepath_to_iso>
is the file path to the ISO file in the host file system. During the installation, the file is accessed through a virtual DVD drive.

The virt-install tool defines the virtual server. It then starts the virtual server, boots the specified ISO image with the installer, and displays the installation dialog on the console. Follow the instructions to complete the installation.

When the installation is completed the guest is rebooted from the virtual disk where it is installed. You do not need to edit the domain configuration-XML file. virt-install makes the required post-installation changes for you.

Example:
# virt-install --name=a_server --disk size=10 --memory=1000 \
--cdrom /var/lib/libvirt/images/linux-s390x.iso

Installing from a network location

Issue a command of this form:
# virt-install --name=<vs_name> --disk size=<disk_size_in_GB> --memory=<vs_memory_size_in_MB> \
--location <url>
In the command <url> specifies a download site and protocol. See the virt-install man page for examples of download sites for some of the major distributions.

The other variables have the same meaning as in Installing from an ISO file.

Example:
# virt-install --name=b_server --disk size=10 --memory=1000 \
--location https://download.fedoraproject.org/pub/fedora-secondary/releases/28/Server/s390x/os/

The virt-install tool defines the virtual server. It then starts the virtual server, boots the installer, and displays the installation dialog on the console.

Tip: With --location, you can optionally use the --extra-args parameter to specify a distribution-specific configuration file for an unattended installation. Examples of such configuration files are kickstart, autoyast, or a preseed file. You can also use the --initrd-inject parameter to dynamically add a configuration file to the initial RAM disk.
Example:
# virt-install --name=b_server --disk size=10 --memory=1000 \
--location https://download.fedoraproject.org/pub/fedora-secondary/releases/28/Server/s390x/os/ \
--extra-args inst.ks=file:///f28.ks --initrd-inject=f28.ks

When the installation is completed the guest is rebooted from the virtual disk where it is installed. You do not need to edit the domain configuration-XML file. virt-install makes the required post-installation changes for you.

Customizing your virtual server

Edit the domain configuration-XML file to customize the virtual server according to your needs.