VIRT-INSTALL(1)

โœจ VIRT-INSTALL โ€” like, the manual page, bestie โœจ

okay so you found the virt-install man page (it lives in the Virtualization Support section of the manual, section 1, iykyk) and honestly? it's a lot. but don't panic, we're gonna get through it together ๐Ÿ’–


๐ŸŒธ NAME ๐ŸŒธ

virt-install โ€” provision new virtual machines ๐Ÿ‘‘


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

virt-install [OPTION]...

๐Ÿ’… DESCRIPTION ๐Ÿ’…

So virt-install is this command line tool that creates brand new KVM, Xen, or Linux container guests, using the libvirt hypervisor management library. and if you wanna just, like, start, there's an EXAMPLES section at the end of this document. go look. it's giving tutorial energy โœจ

The tool supports graphical installations (think VNC or SPICE, cute) and also text mode installs over serial console. and you can configure your guest with one or more virtual disks, network interfaces, audio devices, physical USB or PCI devices, among others. so many others. she's flexible ๐Ÿ’…

The installation media? could be a local ISO or CDROM, or a distro install tree hosted remotely over HTTP, FTP, or sitting in a local directory. In the install tree case, virt-install fetches just the minimal files needed to kick off the installation process, and then the guest fetches the rest of the OS distribution as needed. efficient queen. also supported: PXE booting, and importing an existing disk image (which skips the install phase entirely, slay).

Given suitable command line arguments, virt-install can run completely unattended, with the guest 'kickstarting' itself too ๐ŸŽ€. that means easy automation of guest installs. you can do it manually, or โ€” way simpler โ€” with the --unattended option.

Many arguments have sub options, specified like opt1=foo,opt2=bar, etc. Try --option=? to see a complete list of sub options for that argument, example: virt-install --disk=? ๐Ÿซถ

Most options are not required. If a suitable --osinfo value is specified or detected, all defaults get filled in and reported in the terminal output. Otherwise, the minimum required options are --memory, guest storage (--disk or --filesystem), and an install method choice. that's it. that's the bar ๐Ÿ“


๐ŸŒˆ CONNECTING TO LIBVIRT ๐ŸŒˆ

--connect

Syntax: --connect URI

Connect to a non-default hypervisor. If you don't specify this, libvirt will try and choose the most suitable default. she'll figure it out ๐Ÿ’…

Some valid options here are:

  • qemu:///system โ€” For creating KVM and QEMU guests to be run by the system libvirtd instance. This is the default mode that virt-manager uses, and what most KVM users want. (yes, probably you)
  • qemu:///session โ€” For creating KVM and QEMU guests for libvirtd running as the regular user.
  • xen:/// โ€” For connecting to Xen.
  • lxc:/// โ€” For creating linux containers.

๐Ÿ’– GENERAL OPTIONS ๐Ÿ’–

General configuration parameters that apply to all types of guest installs. universal. iconic.

-n, --name

Syntax: -n, --name NAME

Name of the new guest virtual machine instance. This must be unique amongst all guests known to the hypervisor on the connection โ€” including those not currently active ๐Ÿ˜ญ. To re-define an existing guest, use the virsh(1) tool to shut it down (virsh shutdown) & delete (virsh undefine) it prior to running virt-install. no duplicate names. periodt.

--memory

Syntax: --memory OPTIONS

Memory to allocate for the guest, in MiB. This deprecates the -r/--ram option. Sub options are available, like memory, currentMemory, maxMemory and maxMemory.slots, which all map to the identically named XML values.

Back compat values: memory maps to the <currentMemory> element, and maxmemory maps to the <memory> element. (yes, it's a little confusing. we don't make the rules ๐Ÿ™ˆ)

To configure memory modules which can be hotunplugged, see the --memdev description.

Use --memory=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#memory-allocation>

--memorybacking

Syntax: --memorybacking OPTIONS

This option influences how virtual memory pages are backed by host pages. โœจ

Use --memorybacking=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#memory-backing>

--arch

Syntax: --arch ARCH

Request a non-native CPU architecture for the guest virtual machine. If omitted, the host CPU architecture will be used in the guest. she'll match the host by default ๐Ÿฆ‹

--machine

Syntax: --machine MACHINE

The machine type to emulate. This will typically not need to be specified for Xen or KVM, but it's useful for choosing machine types of more exotic architectures. for the niche situations ๐Ÿ’…

--metadata

Syntax: --metadata OPT=VAL,[...]

Specify metadata values for the guest. Possible options include name, uuid, title, and description. This option deprecates -u/--uuid and --description.

Use --metadata=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#general-metadata>

--events

Syntax: --events OPT=VAL,[...]

Specify events values for the guest. Possible options include on_poweroff, on_reboot, and on_crash. (so you get to decide what happens when things go down ๐Ÿ˜ญ)

Use --events=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#events-configuration>

--resource

Syntax: --resource OPT=VAL,[...]

Specify resource partitioning for the guest.

Use --resource=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#resource-partitioning>

--sysinfo

Syntax: --sysinfo OPT=VAL,[...]

Configure sysinfo/SMBIOS values exposed to the VM OS. Examples:

  • --sysinfo host โ€” Special type that exposes the host's SMBIOS info into the VM.
  • --sysinfo emulate โ€” Special type where hypervisor will generate SMBIOS info into the VM.
  • --sysinfo bios.vendor=custom or --sysinfo smbios,bios.vendor=custom โ€” The default type is smbios and allows users to specify SMBIOS info manually.

Use --sysinfo=? to see a list of all available sub options.

Complete details at <https://libvirt.org/formatdomain.html#operating-system-booting> and <https://libvirt.org/formatdomain.html#smbios-system-information> for the smbios XML element.

--xml

Syntax: --xml ARGS

Make direct edits to the generated XML using XPath syntax. Take an example like

virt-install --xml ./@foo=bar --xml ./newelement/subelement=1

This will alter the generated XML to contain:

<domain foo='bar' ...>
  ...
  <newelement>
    <subelement>1</subelement>
  </newelement>
</domain>

The --xml option has 4 sub options:

  • --xml xpath.set=XPATH[=VALUE] โ€” The default behavior if no explicit suboption is set. Takes the form XPATH=VALUE unless paired with xpath.value. See below for how value is interpreted.
  • --xml xpath.value=VALUE โ€” xpath.set will be interpreted only as the XPath string, and xpath.value will be used as the value to set. May help sidestep problems if the string you need to set contains a = equals sign. If value is empty, it's treated as unsetting that particular node.
  • --xml xpath.create=XPATH โ€” Create the node as an empty element. Needed for boolean elements like <readonly/>
  • --xml xpath.delete=XPATH โ€” Delete the entire node specified by the xpath, and all its children. gone. poof ๐Ÿ’€

xpath subarguments

Similar to the --xml option, most top level options have xpath.* suboptions. For example, --disk xpath1.set=./@foo=bar,xpath2.create=./newelement would generate XML alterations like

<disk foo="bar">
  <newelements/>
</disk>

This is useful for setting XML options per device, when virt-install does not support those options yet. (future-proofing era โœจ)

--qemu-commandline

Syntax: --qemu-commandline ARGS

Pass options directly to the qemu emulator. Only works for the libvirt qemu driver. The option can take a string of arguments, for example:

--qemu-commandline="-display gtk,gl=on"

Environment variables are specified with env, for example:

--qemu-commandline=env=DISPLAY=:0.1

Complete details about the libvirt feature: <https://libvirt.org/drvqemu.html#pass-through-of-arbitrary-qemu-commands>

--vcpus

Syntax: --vcpus OPTIONS

Number of virtual cpus to configure for the guest. If maxvcpus is specified, the guest will be able to hotplug up to MAX vcpus while the guest is running, but will startup with VCPUS. (grow while running, that's main character energy ๐Ÿ‘‘)

CPU topology can additionally be specified with sockets, dies, cores, and threads. If values are omitted, the rest will be autofilled preferring cores over sockets over threads. Cores are preferred because this matches the characteristics of modern real world silicon and thus a better fit for what guest OS will be expecting to deal with. (she's practical like that ๐Ÿ’…)

cpuset sets which physical cpus the guest can use. CPUSET is a comma separated list of numbers, which can also be specified in ranges or cpus to exclude. Example:

0,2,3,5     : Use processors 0,2,3 and 5
1-5,^3,8    : Use processors 1,2,4,5 and 8

If the value auto is passed, virt-install attempts to automatically determine an optimal cpu pinning using NUMA data, if available. letting the algorithm cook ๐Ÿ”ฅ

Use --vcpus=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#cpu-allocation>

--numatune

Syntax: --numatune OPTIONS

Tune NUMA policy for the domain process. Example invocations

--numatune 1,2,3,4-7
--numatune 1-3,5,memory.mode=preferred

Specifies the numa nodes to allocate memory from. This has the same syntax as the --vcpus cpuset= option. mode can be one of interleave, preferred, or strict (the default). See man 8 numactl for information about each mode.

Use --numatune=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#numa-node-tuning>

--memtune

Syntax: --memtune OPTIONS

Tune memory policy for the domain process. Example invocations

--memtune 1000
--memtune hard_limit=100,soft_limit=60,swap_hard_limit=150,min_guarantee=80

Use --memtune=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#memory-tuning>

--blkiotune

Syntax: --blkiotune OPTIONS

Tune blkio policy for the domain process. Example invocations

--blkiotune 100
--blkiotune weight=100,device.path=/dev/sdc,device.weight=200

Use --blkiotune=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#block-i-o-tuning>

--cpu

Syntax:

--cpu
MODEL[,+feature][,-feature][,match=MATCH][,vendor=VENDOR],...

Configure the CPU model and CPU features exposed to the guest. The only required value is MODEL, which is a valid CPU model as known to libvirt.

Libvirt's feature policy values are force, require, optional, disable, or forbid โ€” or with the shorthand +feature and -feature, which equal force=feature and disable=feature respectively. cute little shortcuts ๐ŸŽ€


more coming, bestie โ€” this page keeps going and we are NOT skipping a single flag ๐Ÿ’œ

okay so if you specify an exact CPU model, virt-install will automatically copy over the CPU features that are available on the host, and it does this to mitigate recent CPU speculative execution side channel and Microarchitectural Store Buffer Data security vulnerabilities. lowkey heroic of it. ๐Ÿ’…

But โ€” and this is the part where you lean in โ€” that has some impact on performance, and it will break migration to hosts that don't have the security patches. ๐Ÿ™ˆ

To control this behavior there's a secure parameter. Possible values are on and off, and the default is on. It is highly recommended to leave this enabled and make sure all your virtualization hosts have fully up-to-date microcode, kernel & virtualization software installed. no cap, just update your stuff bestie. โœจ

Some examples:

  • --cpu core2duo,+x2apic,disable=vmx โ€” Expose the core2duo CPU model, force enable x2apic, but do not expose vmx.
  • --cpu host-model โ€” Expose the host CPUs configuration to the guest. This lets the guest take advantage of many of the host CPUs features (better performance), but it may cause issues if you migrate the guest to a host without an identical CPU. ๐Ÿฆ‹
  • --cpu numa.cell0.memory=1234,numa.cell0.cpus=0-3,numa.cell1.memory=5678,numa.cell1.cpus=4-7 โ€” Example of specifying two NUMA cells. This will generate XML like:
<cpu>
  <numa>
    <cell cpus="0-3" memory="1234"/>
    <cell cpus="4-7" memory="5678"/>
  </numa>
</cpu>
  • --cpu host-passthrough,cache.mode=passthrough โ€” Example of passing through the host cpu's cache information. ๐ŸŽ€
  • --cpu maximum โ€” Expose the most feature-rich CPU possible. Useful when running a foreign architecture guest, for example a riscv64 guest on an x86_64 host. Not recommended when using KVM to run a same-architecture guest.

Use --cpu=? to see a list of all available sub options. Complete details at https://libvirt.org/formatdomain.html#cpu-model-and-topology


--cputune

Syntax: --cputune OPTIONS

Tune CPU parameters for the guest. ๐Ÿงš

Configure which of the host's physical CPUs the domain VCPU will be pinned to. Example invocation:

--cputune vcpupin0.vcpu=0,vcpupin0.cpuset=0-3,vcpupin1.vcpu=1,vcpupin1.cpuset=4-7

Use --cputune=? to see a list of all available sub options. Complete details at https://libvirt.org/formatdomain.html#cpu-tuning

--security, --seclabel

Syntax:

--security, --seclabel
type=TYPE[,label=LABEL][,relabel=yes|no],...

Configure domain seclabel domain settings. Type can be either 'static' or 'dynamic'. 'static' configuration requires a security LABEL. Specifying LABEL without TYPE implies static configuration.

Use --security=? to see a list of all available sub options. Complete details at https://libvirt.org/formatdomain.html#security-label

--keywrap

Syntax: --keywrap OPTIONS

Specify domain <keywrap> XML, used for S390 cryptographic key management operations. ๐Ÿ”

Use --keywrap=? to see a list of all available sub options. Complete details at https://libvirt.org/formatdomain.html#key-wrap

--iothreads

Syntax: --iothreads OPTIONS

Specify domain <iothreads> and/or <iothreadids> XML. For example, to configure <iothreads>4</iothreads>, use --iothreads 4

Use --iothreads=? to see a list of all available sub options. Complete details at https://libvirt.org/formatdomain.html#iothreads-allocation

--features

Syntax: --features FEAT=on|off,...

Set elements in the guest's <features> XML on or off. Examples include acpi, apic, eoi, privnet, and hyperv features. Some examples:

  • --features apic.eoi=on โ€” Enable APIC PV EOI.
  • --features hyperv.vapic.state=on,hyperv.spinlocks.state=off โ€” Enable hyperv VAPIC, but disable spinlocks.
  • --features kvm.hidden.state=on โ€” Allow the KVM hypervisor signature to be hidden from the guest.
  • --features pvspinlock=on โ€” Notify the guest that the host supports paravirtual spinlocks, for example by exposing the pvticketlocks mechanism.
  • --features gic.version=2 โ€” This is relevant only for ARM architectures. Possible values are "host" or a version number.
  • --features smm.state=on โ€” This enables System Management Mode of hypervisor. Some UEFI firmwares may require this feature to be present. (QEMU supports SMM only with q35 machine type.)

Use --features=? to see a list of all available sub options. Complete details at https://libvirt.org/formatdomain.html#hypervisor-features

--clock

Syntax: --clock offset=OFFSET,TIMER_OPT=VAL,...

Configure the guest's <clock> XML. Some supported options:

  • --clock offset=OFFSET โ€” Set the clock offset, ex. 'utc' or 'localtime'.
  • --clock TIMER_present=no โ€” Disable a boolean timer. TIMER here might be hpet, kvmclock, etc.
  • --clock TIMER_tickpolicy=VAL โ€” Set a timer's tickpolicy value. TIMER here might be rtc, pit, etc. VAL might be catchup, delay, etc. Refer to the libvirt docs for all values.

Use --clock=? to see a list of all available sub options. Complete details at https://libvirt.org/formatdomain.html#time-keeping

--pm

Syntax: --pm OPTIONS

Configure guest power management features. Example:

--pm suspend_to_memi.enabled=on,suspend_to_disk.enabled=off

Use --pm=? to see a list of all available sub options. Complete details at https://libvirt.org/formatdomain.html#power-management

--launchSecurity

Syntax: --launchSecurity TYPE[,OPTS]

Enable launch security for the guest, e.g. AMD SEV. Example invocations:

# This will use a default policy 0x03
# No dhCert provided, so no data can be exchanged with the SEV firmware
--launchSecurity sev

# Explicit policy 0x01 - disables debugging, allows guest key sharing
--launchSecurity sev,policy=0x01

# Provide the session blob obtained from the SEV firmware
# Provide dhCert to open a secure communication channel with SEV firmware
--launchSecurity sev,session=BASE64SESSIONSTRING,dhCert=BASE64DHCERTSTRING

SEV has further implications on usage of virtio devices, so refer to the EXAMPLES section to see a full invocation of virt-install with --launchSecurity. ๐Ÿ‘‘

Use --launchSecurity=? to see a list of all available sub options. Complete details at https://libvirt.org/formatdomain.html#launch-security


๐Ÿ’– INSTALLATION OPTIONS ๐Ÿ’–

-c, --cdrom

Syntax: --cdrom PATH

ISO file or CDROM device to use for VM install media. After install, the virtual CDROM device will remain attached to the VM, but with the ISO or host path media ejected. ๐ŸŽ€

-l, --location

Syntax: -l, --location OPTIONS

Distribution tree installation source. virt-install can recognize certain distribution trees and fetches a bootable kernel/initrd pair to launch the install.

--location allows things like --extra-args for kernel arguments, and using --initrd-inject. If you want to use those options with CDROM media, you can pass the ISO to --location as well โ€” which works for some, but not all, CDROM media. ๐Ÿฆ‹

The LOCATION can take one of the following forms:

  • https://host/path โ€” An HTTP server location containing an installable distribution image.
  • ftp://host/path โ€” An FTP server location containing an installable distribution image.
  • ISO โ€” Extract files directly from the ISO path.
  • DIRECTORY โ€” Path to a local directory containing an installable distribution image. Note that the directory will not be accessible by the guest after initial boot, so the OS installer will need another way to access the rest of the install media. ๐Ÿ’€

Some distro specific url samples:

Additionally, --location can take 'kernel' and 'initrd' sub options. These paths are relative to the specified location URL/ISO and allow selecting specific files for kernel/initrd within the install tree. This can be useful if virt-install/libosinfo doesn't know where to find the kernel in the specified --location.

For example, if you have an ISO that libosinfo doesn't know about called my-unknown.iso, with a kernel at 'kernel/fookernel' and initrd at 'kernel/fooinitrd', you can make this work with:

--location my-unknown.iso,kernel=kernel/fookernel,initrd=kernel/fooinitrd

--pxe

Install from PXE. This just tells the VM to boot off the network for the first boot. ๐ŸŒˆ

--import

Skip the OS installation process, and build a guest around an existing disk image. The device used for booting is the first device specified via --disk or --filesystem.

-x, --extra-args

Syntax: -x, --extra-args KERNELARGS

Additional kernel command line arguments to pass to the installer when performing a guest install from --location. One common usage is specifying an anaconda kickstart file for automated installs, such as --extra-args "ks=https://myserver/my.ks"

--initrd-inject

Syntax: --initrd-inject PATH

Add PATH to the root of the initrd fetched with --location. This can be used to run an automated install without requiring a network hosted kickstart file: --initrd-inject=/path/to/my.ks --extra-args "ks=file:/my.ks"

--install

This is a larger entry point for various types of install operations. The command has multiple subarguments, similar to --disk and friends. This option is strictly for VM install operations, essentially configuring the first boot. ๐Ÿ”ฅ

The simplest usage to ex: install fedora29 is:

--install fedora29

And virt-install will fetch a --location URL from libosinfo, and populate defaults from there.

Available suboptions:

  • os= โ€” This is os install option described above. The explicit way to specify that would be --install os=fedora29 . os= is the default option if none is specified.
  • kernel=, initrd= โ€” Specify a kernel and initrd pair to use as install media. They are copied into a temporary location before booting the VM, so they can be combined with --initrd-inject and your source media will not be altered. Media will be uploaded to a remote connection if required. โœจ

Example case using local filesystem paths: --install kernel=/path/to/kernel,initrd=/path/to/initrd

Example using network paths. Kernel/initrd will be downloaded locally first, then passed to the VM as local filesystem paths: --install kernel=https://127.0.0.1/tree/kernel,initrd=https://127.0.0.1/tree/initrd

Ok bestie, quick lil reminder before we dive in: these boot thingies are install-time only. If you wanna set the kernel that your VM boots off of forever and ever, that's a whole different vibe โ€” go look at --boot. K? K. ๐Ÿ’–

  • kernel_args=, kernel_args_overwrite=yes|no โ€” this is where you drop install-time kernel arguments (it's the libvirt <cmdline> XML, iykyk). You can team it up with, like, kernel/initrd options or --location media. By default kernel_args acts just like --extra-args and will _append_ onto the args virt-install tries to set on its own for most --location installs. But if you wanna straight-up override the virt-install default? Then you also gotta say kernel_args_overwrite=yes. Slay. โœจ
  • bootdev= โ€” tells it which install bootdev to boot off of for the install phase. Your options are hd, cdrom, floppy, network. This maps to the libvirt <os><boot dev=X> XML. ngl, if you just wanna install off a cdrom or the network, it's probably simpler and more backwards compatible to just use --cdrom or --pxe โ€” but this option gives you fine grained control over the install process if that's what you need. Main character energy only. ๐Ÿ’…
  • no_install=yes|no โ€” this is you telling virt-install "bestie, there's literally no install happening, I just want the VM created." --import is just an alias for this, and so is specifying --boot without any other install options. Also the deprecated --live option is the same as '--cdrom $ISO --install no_install=yes'.

๐Ÿซถ --reinstall DOMAIN

Reinstall a VM you already have. DOMAIN can be a VM name, a UUID, or an ID number โ€” whatever's easiest.

Here's the tea: virt-install grabs the domain XML from libvirt, applies the install config changes you specified, boots the VM for the install process, and then reverts to roughly the same starting XML. Roughly, okay? ๐Ÿ‘€

Only install related options get processed. Everything else โ€” all your other VM config options like --name, --disk, etc. โ€” is completely ignored. Like, they don't even get a vibe check.

If --reinstall is used with --cdrom, an existing CDROM already attached to the VM will be used if one's available. Otherwise, a permanent CDROM device gets added.


๐ŸŒธ --unattended

Syntax:

--unattended [OPTIONS]

This does an unattended install using libosinfo's install script support. Basically it's a whole database of auto install scripts for all the distros: Red Hat kickstarts, Debian installer scripting, Windows unattended installs, and potentially others. The simplest way to use it is to pair it with --install, like:

--install fedora29 --unattended

And a Windows install looks like:

--cdrom /path/to/my/windows.iso --unattended

Sub options are:

  • profile= โ€” pick which libosinfo unattended profile you want. Most distros have a 'desktop' and a 'jeos' profile. virt-install defaults to 'desktop' if you don't say anything. ๐Ÿ˜Œ
  • admin-password-file= โ€” a file to set the VM OS admin/root password from. You can use it as "admin-password-file=/path/to/password-file" or as "admin-password-file=/dev/fd/n", where n is the file descriptor of the password-file. Heads up: only the first line of the file gets considered, including any whitespace characters and excluding new-line. So don't get cute with multi-line files. ๐Ÿ™ˆ
  • user-login= โ€” the user login name to use in th VM. virt-install defaults to your current host username if you don't specify it. Note: if you're running virt-install as "root", you must specify this option. No exceptions.
  • user-password-file= โ€” a file to set the VM user password. Use it as "user-password-file=/path/to/password-file" or as "user-password-file=/dev/fd/n", where n is the file descriptor of the password-file. The username is either the user-login you specified or your current host username. Same deal as before: only the first line counts, whitespace included, new-line excluded. โœจ
  • product-key= โ€” set a Windows product key. That's it, that's the whole thing. ๐Ÿ”‘

๐Ÿฆ‹ --cloud-init

Pass cloud-init metadata to the VM. A cloud-init NoCloud ISO file gets generated and attached to the VM as a CDROM device. The device is only attached for the first boot. This one is particularly useful for distro cloud images, because those have locked login accounts by default โ€” --cloud-init gives you the means to initialize those login accounts, like setting a root password. Obsessed tbh.

The simplest invocation is just plain --cloud-init with no suboptions; this maps to --cloud-init root-password-generate=on,disable=on. See those suboptions for the explanation of how they work. ๐Ÿ‘‘

Use --cloud-init=? to see a list of all available sub options.

Sub options are:

  • root-password-generate=on โ€” generate a brand new root password for the VM. When used, virt-install prints the generated password to the console and pauses for 10 seconds to give you a chance to notice it and copy it. Bestie, do not look away. ๐Ÿ˜ญ
  • disable=on โ€” disables cloud-init in the VM for subsequent boots. Without this, cloud-init may reset auth on every boot, which is not the vibe. ๐Ÿ’€
  • root-password-file= โ€” a file to set the VM root password from. Use it as "root-password-file=/path/to/password-file" or as "root-password-file=/dev/fd/n", where n is the file descriptor of the password-file. And yes, same rule: only the first line is considered, whitespace characters included, new-line excluded. ๐Ÿ“
  • meta-data= โ€” specify a cloud-init meta-data file to add directly to the iso. All other meta-data configuration options on the --cloud-init command line are ignored. Can be a path to a local file or a URL.
  • user-data= โ€” specify a cloud-init user-data file to add directly to the iso. All other user-data configuration options on the --cloud-init command line are ignored. Can be a path to a local file or a URL.
  • root-ssh-key= โ€” specify a public key to inject into the guest, giving you ssh access to the root account. Example: root-ssh-key=/home/user/.ssh/id_rsa.pub. ๐Ÿ”
  • clouduser-ssh-key โ€” specify a public key to inject into the guest, giving you ssh access to the default cloud-init user account. The account name is different per distro cloud image. Some common ones are documented here: <https://docs.openstack.org/image-guide/obtain-images.html>
  • network-config= โ€” specify a cloud-init network-config file to add directly to the iso. Can be a path to a local file or a URL. ๐ŸŒˆ

๐Ÿ‘‘ --boot

Syntax:

--boot BOOTOPTS

Optionally specify the post-install VM boot configuration. This option lets you specify a boot device order, permanently boot off kernel/initrd with option kernel arguments, and enable a BIOS boot menu (which requires libvirt 0.8.3 or later).

--boot can be specified in addition to other install options (like --location, --cdrom, etc.) or it can be specified on its own. In that latter case, the behavior is similar to the --import install option: there's no 'install' phase, the guest just gets created and launched as specified. Simple as that. โœจ

Some examples:

  • --boot cdrom,fd,hd,network โ€” set the boot device priority as first cdrom, first floppy, first harddisk, network PXE boot. Note: s390x guests only support one boot device, so everything except the first device type will be ignored. ๐Ÿ™ˆ
  • --boot kernel=KERNEL,initrd=INITRD,kernel_args="console=/dev/ttyS0" โ€” have the guest permanently boot off a local kernel/initrd pair, with the kernel options you specified.
  • --boot kernel=KERNEL,initrd=INITRD,dtb=DTB โ€” have the guest permanently boot off a local kernel/initrd pair with an external device tree binary. DTB can be required for some non-x86 configurations like ARM or PPC.
  • --boot loader=BIOSPATH โ€” use BIOSPATH as the virtual machine BIOS.
  • --boot bootmenu.enable=on,bios.useserial=on โ€” enable the bios boot menu, and enable sending bios text output over serial console.
  • --boot init=INITPATH โ€” path to a binary that the container guest will init. If a root --filesystem has been specified, virt-install defaults to /sbin/init, otherwise it defaults to /bin/sh.
  • --boot uefi, --boot uefi=on โ€” configure the VM to boot from UEFI. In order for virt-install to know the correct UEFI parameters, libvirt needs to be advertising known UEFI binaries via domcapabilities XML, so this will likely only work if you're using properly configured distro packages. This is the recommended UEFI setup. ๐Ÿ’–
  • --boot uefi=off โ€” don't use UEFI if the VM would normally default to it.
  • --boot uefi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=yes,firmware.feature1.name=enrolled-keys,firmware.feature1.enabled=yes โ€” configure the VM to boot from UEFI with Secure Boot support enabled. Only signed operating systems will be able to boot with this configuration.
  • --boot uefi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=no โ€” configure the VM to boot from UEFI with Secure Boot support disabled. This configuration allows both signed and unsigned operating systems to run. ๐ŸŽ€

Additional information about the secure-boot and enrolled-keys firmware features and how they can be used to influence firmware selection is available at <https://libvirt.org/kbase/secureboot.html>

  • --boot loader=/.../OVMF_CODE.fd,loader.readonly=yes,loader.type=pflash,nvram.template=/.../OVMF_VARS.fd,loader_secure=no โ€” specify that the virtual machine use the custom OVMF binary as boot firmware, mapped as a virtual flash chip. Plus, request that libvirt instantiate the VM-specific UEFI varstore from the custom "/.../OVMF_VARS.fd" varstore template. This setup is not recommended, and should only be used if --boot uefi doesn't know about your UEFI binaries. ๐Ÿ’€

Use --boot=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#operating-system-booting>


๐Ÿ’œ --idmap

Syntax:

--idmap OPTIONS

If the guest configuration declares a UID or GID mapping, the 'user' namespace will be enabled to apply these. A suitably configured UID/GID mapping is a pre-requisite to make containers secure, in the absence of sVirt confinement. ๐Ÿ”

--idmap can be specified to enable user namespace for LXC containers. Example:

--idmap uid.start=0,uid.target=1000,uid.count=10,gid.start=0,gid.target=1000,gid.count=10

Use --idmap=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#container-boot>

๐Ÿ’– GUEST OS OPTIONS ๐Ÿ’–

๐ŸŒธ --osinfo, --os-variant

--osinfo [OSNAME|OPT1=VAL1,...]

Okay bestie so this is the one that makes your guest actually perform well โœจ It optimizes the guest config for one specific operating system. And for most cases you gotta either name an OS or let it detect one from the install media, because otherwise performance-critical stuff like virtio just won't get enabled ๐Ÿ˜ญ

The simplest way to use it is --osinfo OSNAME or --os-variant OSNAME, like for real:

--osinfo fedora32

Here are the suboptions it supports, no cap:

  • name=, short-id= โ€” the OS name/short-id straight from libosinfo. Examples: fedora32, win10
  • id= โ€” the full URL-style libosinfo ID. So like, name=win10 is literally the same thing as id=http://microsoft.com/win/10
  • detect=on|off โ€” whether virt-install should even try to sniff out the OS from the install media you gave it. Heads up: detection only happens for URL and CDROM installs rn, and it is not 100% reliable ๐Ÿ’€
  • require=on|off โ€” if it's on, virt-install will straight up error out if no OS value got set or detected

Some iconic examples, keep these in your notes ๐Ÿ“

--osinfo detect=on,require=on

This one tells virt-install "hey, try to detect from the install media, but if that flops, fail loudly." Which is great because it means your virt-install invocations won't silently fall back to some poorly performing config ๐Ÿซถ

--osinfo detect=on,name=OSNAME

Try detection from the install media, but if it doesn't work out, use OSNAME as the fallback. Very demure, very mindful.

So the vibe is: if you specify any manual --osinfo value, then the default for all the other settings is off or unset.

By default, virt-install will always attempt --osinfo detect=on for appropriate install media. And if no OS gets detected, we fail in most common cases ๐Ÿ˜ณ This fatal error was added in 2022. You can work around it with the fallback example above, or by disabling the require option. And if you literally just need to get back to the old non-fatal behavior ASAP, set this environment variable:

VIRTINSTALL_OSINFO_DISABLE_REQUIRE=1

Run this command to get the list of accepted OS variants:

virt-install --osinfo list

And run osinfo-query os for even more output ๐Ÿ‘‘

Note: --osinfo and --os-variant are aliases for each other. --osinfo is the preferred new-style naming. Periodt.

๐ŸŽ€ STORAGE OPTIONS ๐ŸŽ€

๐Ÿ’พ --disk

--disk OPTIONS

This specifies the media to use as storage for the guest, with a whole buffet of options ๐Ÿ“ The general format of a disk string is:

--disk opt1=val1,opt2=val2,...

The simplest invocation to create a new 10G disk image and its associated disk device is:

--disk size=10

virt-install will generate a path name for you and drop it in the default image location for the hypervisor. If you wanna specify the media instead, the command can be either:

--disk /some/storage/path[,opt1=val1]...

or you can explicitly specify one of these arguments:

  • path โ€” a path to some storage media to use, existing or not. Existing media can be a file or a block device.

Specifying a non-existent path implies you're trying to create new storage, and that's gonna require you to specify a size value. Even for remote hosts, virt-install will try to use libvirt storage APIs to automatically create that path for you โœจ

If the hypervisor supports it, path can also be a network URL, like https://example.com/some-disk.img. For network paths, the hypervisor directly accesses the storage โ€” nothing gets downloaded locally ๐Ÿ’…

  • pool โ€” an existing libvirt storage pool name to create new storage on. Requires specifying a size value.
  • vol โ€” an existing libvirt storage volume to use. This is specified as poolname/volname.

Options that apply to storage creation:

  • size โ€” size (in GiB) to use if creating new storage
  • sparse โ€” whether to skip fully allocating newly created storage. Value is yes or no. Default is yes (do not fully allocate) unless it isn't supported by the underlying storage type.

The initial time taken to fully-allocate the guest virtual disk (sparse=no) will usually be balanced by faster install times inside the guest. So like, using this option is recommended to ensure consistently high performance and to avoid I/O errors in the guest should the host filesystem fill up ๐Ÿ‘€

  • format โ€” disk image format. For file volumes, this can be raw, qcow2, vmdk, etc. See format types at https://libvirt.org/storage.html for possible values. This is often mapped to the driver_type value as well.

If not specified when creating file images, this will default to qcow2.

If you're creating storage, this will be the format of the new image. If you're using an existing image, this overrides libvirt's format auto-detection.

  • backing_store โ€” path to a disk to use as the backing store for the newly created image.
  • backing_format โ€” disk image format of backing_store

Some example device configuration suboptions:

  • device โ€” disk device type. Example values are cdrom, disk, lun or floppy. The default is disk.
  • boot.order โ€” guest installation with multiple disks will need this parameter to boot correctly after being installed. A boot.order parameter takes values 1,2,3,... Devices with a lower value have higher priority. This option applies to other bootable device types as well.
  • target.bus or bus โ€” disk bus type. Example values are ide, sata, scsi, usb, virtio or xen. The default is hypervisor dependent since not all hypervisors support all bus types.
  • readonly โ€” set drive as readonly (takes on or off)
  • shareable โ€” set drive as shareable (takes on or off)
  • cache โ€” the cache mode to be used. The host pagecache provides cache memory. The cache value can be none, writethrough, directsync, unsafe or writeback. writethrough provides read caching. writeback provides read and write caching. directsync bypasses the host page cache. unsafe may cache all content and ignore flush requests from the guest.
  • driver.discard โ€” whether discard (also known as "trim" or "unmap") requests are ignored or passed to the filesystem. The value can be either "unmap" (allow the discard request to be passed) or "ignore" (ignore the discard request). Since 1.0.6 (QEMU and KVM only)
  • driver.name โ€” driver name the hypervisor should use when accessing the specified storage. Typically does not need to be set by the user.
  • driver.type โ€” driver format/type the hypervisor should use when accessing the specified storage. Typically does not need to be set by the user.
  • driver.io โ€” disk IO backend. Can be either "threads", "native" or "io_uring".
  • driver.error_policy โ€” how the guest should react if a write error is encountered. Can be one of "stop", "ignore", or "enospace"
  • serial โ€” serial number of the emulated disk device. This is used in linux guests to set /dev/disk/by-id symlinks. An example serial number might be: WD-WMAP9A966149
  • source.startupPolicy โ€” it defines what to do with the disk if the source file is not accessible.
  • snapshot โ€” defines default behavior of the disk during disk snapshots.

Peep the examples section for some uses ๐Ÿ‘€ This option deprecates -f/--file, -s/--file-size, --nonsparse, and --nodisks.

Use --disk=? to see a list of all available sub options. Complete details at https://libvirt.org/formatdomain.html#hard-drives-floppy-disks-cdroms

๐Ÿฆ‹ --filesystem

Specifies a directory on the host to export to the guest. The most simple invocation is:

--filesystem /source/on/host,/target/point/in/guest

Which will work for recent QEMU and linux guest OS or LXC containers ๐Ÿซถ For QEMU, the target point is just a mounting hint in sysfs, so it will not be automatically mounted. Just so you know.

Some example suboptions:

  • type โ€” the type of the source directory. Valid values are mount (the default) or template for OpenVZ templates.
  • accessmode or mode โ€” the access mode for the source directory from the guest OS. Only used with QEMU and type=mount. Valid modes are mapped (the default), passthrough, or squash. See the libvirt domain XML documentation for more info.
  • source โ€” the directory on the host to share.
  • target โ€” the mount location to use in the guest.

Use --filesystem=? to see a list of all available sub options. Complete details at https://libvirt.org/formatdomain.html#filesystems

๐ŸŒ NETWORKING OPTIONS ๐ŸŒ

-w, --network

Syntax: -w, --network OPTIONS

okay bestie so this one is how you plug your guest into the host's network, and there are like a LOT of flavors here. Here's how you pick a network type:

  • bridge=BRIDGE โ€” connect to a bridge device on the host called BRIDGE. Use this when your host has static networking config and the guest needs full outbound and inbound connectivity to/from the LAN. Also use it if you're gonna do live migration with this guest. ๐Ÿซถ
  • network=NAME โ€” connect to a virtual network on the host called NAME. You can list, create, and delete virtual networks with the virsh command line tool. In an unmodified install of libvirt there's usually a virtual network named default. Use a virtual network if the host has dynamic networking (like NetworkManager) or you're on wireless. The guest gets NATed to the LAN by whichever connection is active.
  • type=direct,source=IFACE[,source.mode=MODE] โ€” direct connect to host interface IFACE using macvtap. ๐Ÿ’…
  • user โ€” connect to the LAN using SLIRP. Only use this if you're running a QEMU guest as an unprivileged user. This gives you a very limited form of NAT.
  • none โ€” tell virt-install not to add any default network interface at all. Periodt.

If you skip --network entirely, a single NIC gets created in the guest. If there's a bridge device on the host with a physical interface attached, that's what gets used for connectivity. Failing that, the virtual network called default is used. And you can pass this option multiple times to set up more than one NIC. ๐Ÿ”ฅ

Some example suboptions:

  • model.type or model โ€” the network device model as seen by the guest. Value can be any nic model your hypervisor supports, e.g.: 'e1000', 'rtl8139', 'virtio', ...
  • mac.address or mac โ€” a fixed MAC address for the guest. If this parameter is omitted, or you specify the value RANDOM, a suitable address gets randomly generated. Heads up: for Xen virtual machines the first 3 pairs in the MAC address are required to be the sequence '00:16:3e', while for QEMU or KVM virtual machines it must be '52:54:00'.
  • filterref.filter โ€” controlling firewall and network filtering in libvirt. Value can be any nwfilter defined by the virsh 'nwfilter' subcommands. You can list available filters by running 'virsh nwfilter-list', e.g.: 'clean-traffic', 'no-mac-spoofing', ...
  • virtualport.* options โ€” configure the device virtual port profile. This is used for 802.Qbg, 802.Qbh, midonet, and openvswitch config.

Use --network=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#network-interfaces>

This option deprecates -m/--mac, -b/--bridge, and --nonetworks. Not me being the upgraded version ๐Ÿ’…

For HOSTDEV format, see the --hostdev documentation. iykyk

  • portForward=[ADDRESS:]HOSTPORT[:GUESTPORT][/PROTO] โ€” simpler option for specifying port forwarding with --network passt networks. Roughly matches podman run -p syntax. HOSTPORT can be represented as a range like 7000-8000, but GUESTPORT can only be a single port. If GUESTPORT isn't provided, host and guest ports are assumed to match.

Examples:

--network passt,portForward=8080:80 \
--network passt,portForward0=7000-8000/udp,portForward1=127.0.0.1:2222:22 \

โœจ GRAPHICS OPTIONS โœจ

So if you don't specify any graphics option, virt-install will try to pick the appropriate graphics if the DISPLAY environment variable is set โ€” otherwise '--graphics none' is used. She decides for you, bestie. ๐ŸŽ€

--graphics

Syntax: --graphics TYPE,opt1=arg1,opt2=arg2,...

Specifies the graphical display configuration. This does not configure any virtual hardware โ€” it's just about how the guest's graphical display can be accessed. Typically you don't need to specify this option; virt-install will try and choose a useful default and launch a suitable connection. โœจ

The general format of a graphical string is

--graphics TYPE,opt1=arg1,opt2=arg2,...

For example:

--graphics vnc,password=foobar

Some supported TYPE values:

  • vnc โ€” set up a virtual console in the guest and export it as a VNC server in the host. Unless the port parameter is also provided, the VNC server runs on the first free port number at 5900 or above. You can get the actual VNC display that got allocated using the vncdisplay command to virsh (or virt-viewer(1) can be used, which handles this detail for you).
  • spice โ€” export the guest's console using the Spice protocol. Spice allows advanced features like audio and USB device streaming, plus improved graphical performance. ๐Ÿ”ฅ

Using the spice graphic type will work as if those arguments were given:

--video qxl --channel spicevmc
  • none โ€” no graphical console gets allocated for the guest. Guests will likely need to have a text console configured on the first serial port in the guest (you can do this via the --extra-args option). The command 'virsh console NAME' can be used to connect to the serial device.

Some supported suboptions:

  • port โ€” request a permanent, statically assigned port number for the guest console. This is used by 'vnc' and 'spice'.
  • tlsPort โ€” specify the spice tlsport.
  • websocket โ€” request a VNC WebSocket port for the guest console.

If -1 is specified, the WebSocket port is auto-allocated.

This is used by 'vnc' and 'spice'.

  • listen โ€” address to listen on for VNC/Spice connections. Default is typically 127.0.0.1 (localhost only), but some hypervisors allow changing this globally (for example, the qemu driver default can be changed in /etc/libvirt/qemu.conf). Use 0.0.0.0 to allow access from other machines.

Use 'none' to specify that the display server should not listen on any port. The display server can then be accessed only locally through the libvirt unix socket (virt-viewer with --attach, for instance).

Use 'socket' to have the VM listen on a libvirt generated unix socket path on the host filesystem.

This is used by 'vnc' and 'spice'.

  • password โ€” request a console password, required at connection time. โš ๏ธ Beware, this info may end up in virt-install log files, so don't use an important password. This is used by 'vnc' and 'spice'.
  • gl.enable โ€” whether to use OpenGL accelerated rendering. Value is 'yes' or 'no'. This is used by 'spice'.
  • gl.rendernode โ€” DRM render node path to use. This is used when 'gl' is enabled.

Use --graphics=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#graphical-framebuffers>

This deprecates the following options: --vnc, --vncport, --vnclisten, -k/--keymap, --sdl, --nographics. Rip bozo, they had a good run ๐Ÿ’€

--autoconsole

Syntax: --autoconsole OPTIONS

Configure what interactive console virt-install will launch for the VM. This option isn't required; the default behavior is adaptive and depends on how the VM is configured. But you can use this option to override the default choice. ๐Ÿฆ‹

  • --autoconsole graphical โ€” use the graphical virt-viewer(1) as the interactive console.
  • --autoconsole text โ€” use the text mode virsh console as the interactive console.
  • --autoconsole none โ€” this is the same as --noautoconsole.
  • --noautoconsole โ€” don't automatically try to connect to the guest console. Same as --autoconsole none.
Note: virt-install exits quickly when this option is specified. If your command requested a multistep install, like --cdrom or --location, after the install phase is complete the VM will be shutoff, regardless of whether a reboot was requested in the VM. If you want the VM to be rebooted, virt-install must remain running. You can use '--wait' to keep virt-install alive even if --noautoconsole is specified. No cap, this one bites people ๐Ÿ˜ญ

๐Ÿ’ซ VIRTUALIZATION OPTIONS ๐Ÿ’ซ

Options to override the default virtualization type choices.

-v, --hvm

Request the use of full virtualization, if both para & full virtualization are available on the host. This parameter may not be available if you're connecting to a Xen hypervisor on a machine without hardware virtualization support. This parameter is implied if you're connecting to a QEMU based hypervisor.

-p, --paravirt

This guest should be a paravirtualized guest. If the host supports both para & full virtualization, and neither this parameter nor --hvm are specified, this will be assumed.

--container

This guest should be a container type guest. This option is only required if the hypervisor supports other guest types as well (so for example this option is the default behavior for LXC and OpenVZ, but it's provided for completeness). ๐Ÿซถ

--virt-type

The hypervisor to install on. Example choices are kvm, qemu, or xen. Available options are listed via 'virsh capabilities' in the <domain> tags.

This deprecates the --accelerate option, which is now the default behavior. To install a plain QEMU guest, use '--virt-type qemu'. She's the main character now, periodt ๐Ÿ‘‘

๐ŸŽ€ DEVICE OPTIONS ๐ŸŽ€

Okay so heads up: all devices have a set of address.* options for configuring the particulars of the device's address on its parent controller or bus. See <https://libvirt.org/formatdomain.html#device-addresses> for the deets. ๐Ÿ’–

--controller

Syntax: --controller OPTIONS

Attach a controller device to the guest.

Some example invocations:

  • --controller usb2 โ€” add a full USB2 controller setup
  • --controller usb3 โ€” add a USB3 controller
  • --controller type=usb,model=none โ€” disable USB entirely
  • --controller type=scsi,model=virtio-scsi โ€” add a VirtIO SCSI controller
  • --controller num_pcie_root_ports=NUM โ€” control the number of default pcie-root-port controller devices we add to the new VM by default, if the VM will use PCIe by default.

Use --controller=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#controllers>

--input

Syntax: --input OPTIONS

Attach an input device to the guest. Example input device types are mouse, tablet, or keyboard. ๐Ÿญ

Use --input=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#input-devices>

--hostdev, --host-device

Syntax: --hostdev, --host-device OPTIONS

Attach a physical host device to the guest. Some example values for HOSTDEV:

  • --hostdev pci_0000_00_1b_0 โ€” a node device name via libvirt, exactly like virsh nodedev-list shows it. iykyk โœจ
  • --hostdev 001.003 โ€” USB, by bus + device (the way lsusb gives it to you).
  • --hostdev 0x1234:0x5678 โ€” USB, by vendor + product (lsusb again, bestie).
  • --hostdev 1f.01.02 โ€” PCI device (hello lspci my beloved ๐Ÿ’–).
  • --hostdev wlan0,type=net โ€” network device, but only inside an LXC container.
  • --hostdev /dev/net/tun,type=misc โ€” character device, also LXC-only vibes.
  • --hostdev /dev/sdf,type=storage โ€” block device, LXC container again.

Hit --hostdev=? to see, like, every available sub option. And the full tea lives at https://libvirt.org/formatdomain.html#host-device-assignment.


๐Ÿ”Š --sound

Syntax: --sound MODEL

Slap a virtual audio device onto the guest, periodt. MODEL is which emulated sound card model you want. Possible values: ich6, ich9, ac97, es1370, sb16, pcspk, or default. And default? It tries to pick the best model the OS you specified actually supports. ๐Ÿ‘‘

Heads up: this deprecates the old --soundhw option. It's giving legacy, bestie. ๐Ÿ’€

Use --sound=? for the full sub option list. Complete details at https://libvirt.org/formatdomain.html#sound-devices.


๐ŸŽง --audio

Sets up host audio output for the guest's --sound hardware. Like, the sound card needs somewhere to actually sing, you know?

Use --audio=? to see all available sub options. Complete details at https://libvirt.org/formatdomain.html#audio-backends. ๐ŸŒธ


๐Ÿ• --watchdog

Syntax: --watchdog MODEL[,action=ACTION]

Attach a virtual hardware watchdog device to the guest. Lowkey dramatic, but for a good reason: this needs a daemon and a device driver inside the guest to work. The watchdog fires off a signal when the virtual machine looks like it's hung. ๐Ÿšจ

ACTION is what libvirt does when the watchdog fires. The values:

  • reset โ€” forcefully reset the guest (this is the default)
  • poweroff โ€” forcefully power off the guest
  • pause โ€” pause the guest
  • none โ€” do absolutely nothing
  • shutdown โ€” gracefully shutdown the guest
Fr fr, shutdown is not recommended โ€” a hung guest probably won't respond to a graceful shutdown. It's giving "asking politely while the building is on fire." ๐Ÿ˜ญ

MODEL is the emulated device model: either i6300esb (the default) or ib700.

Some examples, bestie:

  • --watchdog default โ€” use the recommended settings โœจ
  • --watchdog i6300esb,action=poweroff โ€” use the i6300esb with the poweroff action

Use --watchdog=? to see all available sub options. Complete details at https://libvirt.org/formatdomain.html#watchdog-devices.


๐Ÿ”Œ --serial

Syntax: --serial OPTIONS

Specifies a serial device to attach to the guest, with a whole bunch of options. The general format of a serial string is:

--serial type,opt1=val1,opt2=val2,...

Real talk: --serial and --parallel devices share all the same options, unless it says otherwise. Some of the types of character device redirection are:

  • --serial pty โ€” pseudo TTY. The allocated pty gets listed in the running guest's XML description. ๐Ÿฆ‹
  • --serial dev,path=HOSTPATH โ€” host device. For serial devices this could be /dev/ttyS0. For parallel devices, this could be /dev/parport0.
  • --serial file,path=FILENAME โ€” write output to FILENAME. Simple. Iconic. ๐Ÿ’…
  • --serial tcp,host=HOST:PORT,source.mode=MODE,protocol.type=PROTOCOL โ€” TCP net console. MODE is either bind (wait for connections on HOST:PORT) or connect (send output to HOST:PORT), default is bind. HOST defaults to 127.0.0.1, but PORT is required. PROTOCOL can be either raw or telnet (default raw). If it's telnet, the port acts like a telnet server or client.

Some examples:

Wait for connections on any address, port 4567:

--serial tcp,host=0.0.0.0:4567

Connect to localhost, port 1234:

--serial tcp,host=:1234,source.mode=connect

Wait for a telnet connection on localhost, port 2222. The user could then connect interactively to this console via telnet localhost 2222:

--serial tcp,host=:2222,source.mode=bind,source.protocol=telnet
  • --serial udp,host=CONNECT_HOST:PORT,bind_host=BIND_HOST:BIND_PORT โ€” UDP net console. HOST:PORT is the destination to send output to (default HOST is 127.0.0.1, PORT is required). BIND_HOST:BIND_PORT is the optional local address to bind to (default BIND_HOST is 127.0.0.1, but it's only set if BIND_PORT is specified).

Some examples:

Send output to the default syslog port (may need to edit /etc/rsyslog.conf accordingly):

--serial udp,host=:514

Send output to remote host 192.168.10.20, port 4444 (this output can be read on the remote host using nc -u -l 4444):

--serial udp,host=192.168.10.20:4444
  • --serial unix,path=UNIXPATH,mode=MODE โ€” Unix socket, see unix(7). MODE has similar behavior and defaults as --serial tcp,mode=MODE.

Use --serial=? to see all available sub options. Complete details at https://libvirt.org/formatdomain.html#consoles-serial-parallel-channel-devices. ๐ŸŽ€


๐Ÿงต --parallel

Syntax: --parallel OPTIONS

Specify a parallel device. The format and options are largely identical to serial. Yeah, it's the twin sibling energy. ๐Ÿ‘ฏ

Use --parallel=? to see all available sub options. Complete details at https://libvirt.org/formatdomain.html#parallel-port.


๐Ÿ“ก --channel

Specifies a communication channel device to connect the guest and the host machine. This option uses the same options as --serial and --parallel for specifying the host/source end of the channel. Extra target options are used to say how the guest machine sees the channel. Two-way gossip, basically. ๐Ÿ—ฃ๏ธ

Some of the types of character device redirection are:

  • --channel SOURCE,target.type=guestfwd,target.address=HOST:PORT โ€” communication channel using the QEMU usermode networking stack. The guest can connect to the channel using the specified HOST:PORT combination.
  • --channel SOURCE,target.type=virtio[,target.name=NAME] โ€” communication channel using virtio serial (requires 2.6.34 or later host and guest). Each instance of a virtio --channel line is exposed in the guest as /dev/vport0p1, /dev/vport0p2, etc. NAME is optional metadata and can be any string, such as org.linux-kvm.virtioport1. If specified, it'll be exposed in the guest at /sys/class/virtio-ports/vport0p1/NAME.
  • --channel spicevmc,target.type=virtio[,target.name=NAME] โ€” communication channel for the QEMU spice agent, using virtio serial (requires 2.6.34</mint> or later host and guest โ€” okay bestie, it's 2.6.34or later, you got it).NAME is optional metadata and can be any string, such as the default <mint>com.redhat.spice.0`, which specifies how the guest will see the channel.
  • --channel qemu-vdagent,target.type=virtio[,target.name=NAME] โ€” communication channel for the QEMU vd agent, using virtio serial (requires 2.6.34 or later host and guest). This is the one that lets you copy/paste with VNC guests. ๐Ÿซถ Note that the guest clipboard integration is implemented via spice-vdagent, which must be running even when the guest does not use spice graphics. NAME is optional metadata that specifies how the guest will see the channel, and it should be left as the default com.redhat.spice.0 unless you know what you are doing.
โš ๏ธ That last bit is real: leave the default unless you know what you're doing. Not me being dramatic, that's just the manual. ๐Ÿ˜Œ

Use --channel=? to see all available sub options. Complete details at https://libvirt.org/formatdomain.html#channel.


๐Ÿ–ฅ๏ธ --console

Connect a text console between the guest and host. Certain guest + hypervisor combos can automatically set up a getty in the guest, so you get an out-of-the-box text login (target_type=xen for xen paravirt guests, and possibly target_type=virtio in the future). โœจ

Example:

  • --console pty,target.type=virtio โ€” connect a virtio console to the guest, redirected to a PTY on the host. For supported guests, this exposes /dev/hvc0 in the guest. See https://fedoraproject.org/wiki/Features/VirtioSerial for more info. Heads up: virtio console requires libvirt 0.8.3 or later.

Use --console=? to see all available sub options. Complete details at https://libvirt.org/formatdomain.html#console.


๐ŸŽฌ --video

Syntax: --video OPTIONS

Specify what video device model gets attached to the guest. Valid values for VIDEO are hypervisor specific, but some options for recent kvm are cirrus, vga, qxl, virtio, or vmvga (vmware). ๐Ÿ“บ

Use --video=? to see all available sub options. Complete details at https://libvirt.org/formatdomain.html#video-devices.


๐Ÿ’ณ --smartcard

Syntax: --smartcard MODE[,OPTIONS]

Configure a virtual smartcard device. Yes, actual smartcard, not your little plastic loyalty card. ๐Ÿ’œ

Example MODE values are host, host-certificates, or passthrough. Example suboptions include:

  • type โ€” character device type to connect to on the host. This is only applicable for passthrough mode.

An example invocation:

  • --smartcard passthrough,type=spicevmc โ€” use the smartcard channel of a SPICE graphics device to pass smartcard info to the guest

Use --smartcard=? to see all available sub options. Complete details at https://libvirt.org/formatdomain.html#smartcard-devices.


๐Ÿ”€ --redirdev

Syntax: --redirdev BUS[,OPTIONS]

Add a redirected device. Example suboptions:

  • type โ€” the redirection type. Currently supported is tcp or spicevmc .
  • server โ€” the TCP server connection details, of the form server:port.

Example invocations:

  • --redirdev usb,type=tcp,server=localhost:4000 โ€” add a USB redirected device provided by the TCP server on localhost port 4000.
  • --redirdev usb,type=spicevmc โ€” add a USB device redirected via a dedicated Spice channel. ๐ŸŒˆ

Use --redirdev=? to see all available sub options. Complete details at https://libvirt.org/formatdomain.html#redirected-devices.


๐ŸŽˆ --memballoon

Syntax: --memballoon MODEL[,OPTIONS]

Attach a virtual memory balloon device to the guest. If the memballoon device needs to be explicitly disabled, MODEL='none' is used. Yep, that's the whole trick. ๐ŸŽ€

MODEL is the type of memballoon device provided. The value can be virtio, xen or none. Some examples:

  • --memballoon virtio โ€” explicitly create a virtio memballoon device
  • --memballoon none โ€” disable the memballoon device

Use --memballoon=? to see all available sub options. Complete details at https://libvirt.org/formatdomain.html#memory-balloon-device.


๐Ÿ” --tpm

Syntax: --tpm TYPE[,OPTIONS]

Configure a virtual TPM device. Examples:

  • --tpm /dev/tpm โ€” convenience option for passing through the host's TPM. ๐Ÿ’…
  • --tpm emulator โ€” request an emulated TPM device.
  • --tpm default โ€” request that virt-install fill in a modern recommended default. Bestie said "you pick, I trust you." ๐Ÿซถ
  • --tpm none โ€” request that virt-install disable the TPM device.

Use --tpm=? to see all available sub options. Complete details at https://libvirt.org/formatdomain.html#tpm-device.

  • --rng โ€” bestie, this one sets up a virtual RNG device for your guest ๐Ÿ’–

Syntax: --rng TYPE[,OPTIONS]

Configure a virtual RNG device.

Example TYPE values include random, egd or builtin.

Example invocations:

--rng /dev/urandom

Use the /dev/urandom device to get entropy data, this form implicitly uses the "random" model.

--rng builtin

Use the builtin rng device to get entropy data.

--rng egd,backend.source.host=localhost,backend.source.service=8000,backend.type=tcp

Connect to localhost to the TCP port 8000 to get entropy data.

Use --rng=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#random-number-generator-device>

  • --panic โ€” attaches a panic notifier device to the guest, so when things go ๐Ÿ’€ you actually get told

Syntax: --panic MODEL[,OPTS]

Attach a panic notifier device to the guest. For the recommended settings, use: --panic default

Use --panic=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#panic-device>

  • --shmem โ€” shared memory device time ๐Ÿซถ

Syntax: --shmem NAME[,OPTS]

Attach a shared memory device to the guest. The name must not contain / and must not be directory-specific to . or ..

Use --shmem=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#shared-memory-device>

  • --memdev โ€” adds a memory module that can actually be hotunplugged, which is giving main character energy ngl

Syntax: --memdev OPTS

Add a memory module to a guest which can be hotunplugged. To add a memdev you need to configure hotplugmemory and NUMA for a guest.

Use --memdev=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#memory-devices>

  • --vsock โ€” host/guest vsock interface, lowkey the cutest lil channel

Syntax: --vsock OPTS

Configure a vsock host/guest interface. A typical configuration would be

--vsock cid.auto=yes

Use --vsock=? to see a list of all available sub options. Complete details at <https://libvirt.org/formatdomain.html#vsock>

  • --iommu โ€” drop an IOMMU device into the guest, slay

Syntax: --iommu MODEL[,OPTS]

Add an IOMMU device to the guest.

Use --iommu=? to see a list of all available options. Complete details at <https://libvirt.org/formatdomain.html#iommu-devices>

  • --pstore โ€” so your guest can save its oops/panic logs before it fully crashes out ๐Ÿ˜ญ

Syntax: --pstore OPT=VAL,[...]

Add a pstore device to a guest for storing oops/panic logs before it crashes.

Use --pstore=? to see a list of all available options. Complete details at <https://libvirt.org/formatdomain.html#pstore>


โœจ MISCELLANEOUS OPTIONS โœจ

  • -h, --help โ€” shows the help message and dips. Bye bestie ๐Ÿ‘‹
  • --version โ€” shows the program's version number and exits
  • --autostart โ€” sets the autostart flag for a domain. This causes the domain to be started on host boot up. Iconic, honestly.
  • --transient โ€” use --import or --boot and --transient if you want a transient libvirt VM. These VMs exist only until the domain is shut down or the host server is restarted. Libvirt forgets the XML configuration of the VM after either of these events. Note that the VM's disks will not be deleted. See: <https://wiki.libvirt.org/page/VM_lifecycle#Transient_guest_domains_vs_Persistent_guest_domains>
Fr fr, "forgets the XML" is the whole vibe โ€” your VM config is ephemeral, the disks are not. Know the difference ๐Ÿฆ‹
  • --destroy-on-exit โ€” when the VM console window is exited, destroy (force poweroff) the VM. If you combine this with --transient, this makes the virt-install command work similar to qemu, where the VM is shutdown when the console window is closed by the user.
  • --print-xml โ€” prints the generated XML of the guest instead of defining it ๐Ÿ“

Syntax: --print-xml [STEP]

Print the generated XML of the guest, instead of defining it. By default this WILL do storage creation (can be disabled with --dry-run). This option implies --quiet.

If the VM install has multiple phases, by default this will print all generated XML. If you want to print a particular step, use --print-xml 2 (for the second phase XML).

  • --noreboot โ€” prevents the domain from automatically rebooting after the install has completed.
  • --wait โ€” controls how virt-install waits for the install to finish โณ

Syntax: --wait WAIT

Configure how virt-install will wait for the install to complete. Without this option, virt-install will wait for the console to close (not necessarily indicating the guest has shutdown), or in the case of --noautoconsole, simply kick off the install and exit.

Bare --wait or any negative value will make virt-install wait indefinitely. Any positive number is the number of minutes virt-install will wait. If the time limit is exceeded, virt-install simply exits, leaving the virtual machine in its current state.

  • --dry-run โ€” goes through the whole guest creation process, but does NOT create storage devices, change host device configuration, or actually teach libvirt about the guest. virt-install may still fetch install media, since this is required to properly detect the OS to install.
  • --check โ€” turns some validation checks on or off. Some examples are warning about using a disk that's already assigned to another VM (--check path_in_use=on|off), or warning about potentially running out of space during disk allocation (--check disk_size=on|off). Most checks are performed by default.
  • -q, --quiet โ€” only prints fatal error messages. Minimalist queen ๐Ÿ’…
  • -d, --debug โ€” prints debugging information to the terminal when running the install process. The debugging information is also stored in ~/.cache/virt-manager/virt-install.log even if this parameter is omitted.

๐ŸŒˆ EXAMPLES ๐ŸŒˆ

The simplest invocation to interactively install a Fedora 29 KVM VM with recommended defaults. virt-viewer(1) will be launched to graphically interact with the VM install

# sudo virt-install --install fedora29

Similar, but use libosinfo's unattended install support, which will perform the fedora29 install automatically without user intervention:

# sudo virt-install --install fedora29 --unattended

Install a Windows 10 VM, using 40GiB storage in the default location and 4096MiB of ram, and ensure we are connecting to the system libvirtd instance:

# virt-install \
   --connect qemu:///system \
   --name my-win10-vm \
   --memory 4096 \
   --disk size=40 \
   --osinfo win10 \
   --cdrom /path/to/my/win10.iso

Install a CentOS 7 KVM from a URL, with recommended device defaults and default required storage, but specifically request VNC graphics instead of the default SPICE, and request 8 virtual CPUs and 8192 MiB of memory:

# virt-install \
    --connect qemu:///system \
    --memory 8192 \
    --vcpus 8 \
    --graphics vnc \
    --osinfo centos7.0 \
    --location http://mirror.centos.org/centos-7/7/os/x86_64/

Create a VM around an existing debian9 disk image:

# virt-install \
    --import \
    --memory 512 \
    --disk /home/user/VMs/my-debian9.img \
    --osinfo debian9

Start serial QEMU ARM VM, which requires specifying a manual kernel.

# virt-install \
    --name armtest \
    --memory 1024 \
    --arch armv7l --machine vexpress-a9 \
    --disk /home/user/VMs/myarmdisk.img \
    --boot kernel=/tmp/my-arm-kernel,initrd=/tmp/my-arm-initrd,dtb=/tmp/my-arm-dtb,kernel_args="console=ttyAMA0 rw root=/dev/mmcblk0p3" \
    --graphics none

Start an SEV launch security VM with 4GB RAM, 4GB+256MiB of hard_limit, with a couple of virtio devices:

Note: The IOMMU flag needs to be turned on with driver.iommu for virtio devices. Usage of --memtune is currently required because of SEV limitations, refer to libvirt docs for a detailed explanation.

# virt-install \
    --name foo \
    --memory 4096 \
    --boot uefi \
    --machine q35 \
    --memtune hard_limit=4563402 \
    --disk size=15,target.bus=scsi \
    --import \
    --controller type=scsi,model=virtio-scsi,driver.iommu=on \
    --controller type=virtio-serial,driver.iommu=on \
    --network network=default,model=virtio,driver.iommu=on \
    --rng /dev/random,driver.iommu=on \
    --memballoon driver.iommu=on \
    --launchSecurity sev

๐Ÿ’€ BUGS ๐Ÿ’€

Please see <https://virt-manager.org/bugs>


Copyright (C) Red Hat, Inc, and various contributors. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <https://www.gnu.org/licenses/gpl.html> . There is NO WARRANTY, to the extent permitted by law.


๐ŸŽ€ SEE ALSO ๐ŸŽ€

virsh(1), virt-clone(1), virt-manager(1), the project website <https://virt-manager.org>


okay and that's the whole page, bestie!! ๐Ÿซถโœจ the footer at the bottom is the VIRT-INSTALL(1) tag with its lil date stamp, courtesy of the virt-manager docs crew. go forth and virt-install something iconic ๐Ÿ’–๐ŸŒธ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from