provision new virtual machines
virt-install - provision new virtual machines
virt-install [ OPTION ]...
virt-install is a command line tool for creating new KVM , Xen, or Linux container guests using the libvirt hypervisor management library. See the EXAMPLES section at the end of this document to quickly get started.
virt-install tool supports both text based & graphical installations, using VNC or SDL graphics, or a text serial console. The guest can be configured to use one or more virtual disks, network interfaces, audio devices, physical USB or PCI devices, among others.
The installation media can be held locally or remotely on NFS , HTTP , FTP servers. In the latter case virt-install will fetch the minimal files necessary to kick off the installation process, allowing the guest to fetch the rest of the OS distribution as needed. PXE booting, and importing an existing disk image (thus skipping the install phase) are also supported.
Given suitable command line arguments, virt-install is capable of running completely unattended, with the guest kickstarting itself too. This allows for easy automation of guest installs. An interactive mode is also available with the --prompt option, but this will only ask for the minimum required options.
Most options are not required. Minimum requirements are --name, --ram, guest storage (--disk, --filesystem or --nodisks), and an install option.
If running on a host with the Xen kernel (checks against /proc/xen)qemu:///system If running on a bare metal kernel as root (needed for KVM installs)qemu:///session If running on a bare metal kernel as non-root
It is only necessary to provide the --connect argument if this default prioritization is incorrect, eg if wanting to use QEMU while on a Xen kernel.
General Options virsh(1)
CPU topology can additionally be specified with sockets, cores, and threads. If values are omitted, the rest will be autofilled prefering sockets over cores over threads.--cpuset=CPUSET
The nodeset string must use escaped-quotes if specifying any other option.--cpu MODEL[,+feature][,-feature][,match=MATCH][,vendor=VENDOR]
Specific CPU features can be specified in a number of ways: using one of libvirts feature policy values force, require, optional, disable, or forbid, or with the shorthand +feature and -feature, which equal force=feature and disable=feature respectively
Some examples:--cpu core2duo,+x2apic,disable=vmx Expose the core2duo CPU model, force enable x2apic, but do not expose vmx--cpu host Expose the host CPUs configuration to the guest. This enables the guest to take advantage of many of the host CPUs features (better performance), but may cause issues if migrating the guest to a host without an identical CPU .--description
Installation Method options
With libvirt 0.9.4 or later, network URL installs work for remote connections. virt-install will download kernel/initrd to the local machine, and then upload the media to the remote host. This option requires the URL to be accessible by both the local and remote host.
The LOCATION can take one of the following forms:DIRECTORYPath to a local directory containing an installable distribution imagenfs:host:/path or nfs://host/path An NFS server location containing an installable distribution imagehttp://host/path An HTTP server location containing an installable distribution imageftp://host/path An FTP server location containing an installable distribution imageSome distro specific url samples: http://download.fedoraproject.org/pub/fedora/linux/releases/10/Fedora/i386/os/Debian/Ubuntu http://ftp.us.debian.org/debian/dists/etch/main/installer-amd64/Suse http://download.opensuse.org/distribution/11.0/repo/oss/Mandriva ftp://ftp.uwsg.indiana.edu/linux/mandrake/official/2009.0/i586/--pxe
--initrd-inject=/path/to/my.ks --extra-args ks=file:/my.ks--os-type=OS_TYPE
By default, virt-install will attempt to auto detect this value from the install media (currently only supported for URL installs). Autodetection can be disabled with the special value none
See --os-variant for valid options.--os-variant=OS_VARIANT
By default, virt-install will attempt to auto detect this value from the install media (currently only supported for URL installs). Autodetection can be disabled with the special value none.
If the special value list is passed, virt-install will print the full list of variant values and exit. The printed format is not a stable interface, DO NOT PARSE IT .
If the special value none is passed, no os variant is recorded and OS autodetection is disabled.
Values for some recent OS options are:win7 : Microsoft Windows 7
--boot can be specified in addition to other install options (such as --location, --cdrom, etc.) or can be specified on its own. In the latter case, behavior is similar to the --import install option: there is no install phase, the guest is just created and launched as specified.
Some examples:--boot cdrom,fd,hd,network,menu=on Set the boot device priority as first cdrom, first floppy, first harddisk, network PXE boot. Additionally enable BIOS boot menu prompt.--boot kernel=KERNEL,initrd=INITRD,kernel_args=console=/dev/ttyS0 Have guest permanently boot off a local kernel/initrd pair, with the specified kernel options.
Storage Configuration path A path to some storage media to use, existing or not. Existing media can be a file or block device. If installing on a remote host, the existing media must be shared as a libvirt storage volume.
Specifying a non-existent path implies attempting to create the new storage, and will require specifyng a size value. If the base directory of the path is a libvirt storage pool on the host, the new storage will be created as a libvirt storage volume. For remote hosts, the base directory is required to be a storage pool if using this method.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.Other available options: device Disk device type. Value can be cdrom, disk, or floppy. Default is disk. If a cdrom is specified, and no install method is chosen, the cdrom is used as the install media.bus
Disk bus type. Value can be ide, scsi, usb, virtio or xen. The default is hypervisor dependent since not all hypervisors support all bus types.perms Disk permissions. Value can be rw (Read/Write), ro (Readonly), or sh (Shared Read/Write). Default is rwsize size (in GB ) to use if creating new storagesparse whether to skip fully allocating newly created storage. Value is true or false. Default is true (do not fully allocate).
The initial time taken to fully-allocate the guest virtual disk (sparse=false) will be usually by balanced by faster install times inside the guest. Thus use of this option is recommended to ensure consistently high performance and to avoid I/O errors in the guest should the host filesystem fill up.cache The cache mode to be used. The host pagecache provides cache memory. The cache value can be none, writethrough, or writeback. writethrough provides read caching. writeback provides read and write caching.format Image format to be used if creating managed storage. For file volumes, this can be raw, qcow2, vmdk, etc. See format types in <http://libvirt.org/storage.html> for possible values. This is often mapped to the driver_type value as well.
With libvirt 0.8.3 and later, this option should be specified if reusing and existing disk image, since libvirt does not autodetect storage format as it is a potential security issue. For example, if reusing an existing qcow2 image, you will want to specify format=qcow2, otherwise the hypervisor may not be able to read your disk image.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.io
Disk IO backend. Can be either threads or native.error_policy How guest should react if a write error is encountered. Can be one of stop, none, or enospaceserial 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-WMAP9A966149See the examples section for some uses. This option deprecates
The following explicit options can be specified:type The type or the source directory. Valid values are mount (the default) or template for OpenVZ templates.mode The access mode for the source directory from the guest OS . Only used with QEMU and type=mount. Valid modes are passthrough (the default), mapped, or squash. See libvirt domain XML documentation for more info.source The directory on the host to share.target The mount location to use in the guest.--nodisks
Networking Configuration Connect to a bridge device in the host called BRIDGE. Use this option if the host has static networking config & the guest requires full outbound and inbound connectivity to/from the LAN . Also use this if live migration will be used with this guest.network=NAME Connect to a virtual network in the host called NAME. Virtual networks can be listed, created, deleted using the virsh command line tool. In an unmodified install of libvirt there is usually a virtual network with a name of default. Use a virtual network if the host has dynamic networking (eg NetworkManager), or using wireless. The guest will be NATed to the LAN by whichever connection is active.user Connect to the LAN using SLIRP . Only use this if running a QEMU guest as an unprivileged user. This provides a very limited form of NAT .If this option is omitted a single
Other available options are:model Network device model as seen by the guest. Value can be any nic model supported by the hypervisor, e.g.: e1000, rtl8139, virtio, ...mac
Fixed MAC address for the guest; If this parameter is omitted, or the value RANDOM is specified a suitable address will be randomly generated. For Xen virtual machines it is required that the first 3 pairs in the MAC address be the sequence 00:16:3e, while for QEMU or KVM virtual machines it must be 52:54:00.--nonetworks
General format of a graphical string is--graphics TYPE,opt1=arg1,opt2=arg2,...type The display type. This is one of:
Setup 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 will run on the first free port number at 5900 or above. The actual VNC display allocated can be obtained using the vncdisplay command to virsh (or virt-viewer(1) can be used which handles this detail for the use).
Setup a virtual console in the guest and display an SDL window in the host to render the output. If the SDL window is closed the guest may be unconditionally terminated.
Export the guests console using the Spice protocol. Spice allows advanced features like audio and USB device streaming, as well as improved graphical performance.
Using spice graphic type will work as if those arguments were given:--video qxl --channel spicevmcnone
No graphical console will be allocated for the guest. Fully virtualized guests (Xen FV or QEmu/KVM) will need to have a text console configured on the first serial port in the guest (this can be done via the --extra-args option). Xen PV will set this up automatically. The command virsh console NAME can be used to connect to the serial device.port Request a permanent, statically assigned port number for the guest console. This is used by vnc and spicetlsport Specify the spice tlsport.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. This is use by vnc and spicekeymap Request that the virtual VNC console be configured to run with a specific keyboard layout. If the special value local is specified, virt-install will attempt to configure to use the same keymap as the local system. A value of none specifically defers to the hypervisor. Default behavior is hypervisor specific, but typically is the same as local. This is used by vncpassword Request a VNC password, required at connection time. Beware, this info may end up in virt-install log files, so dont use an important password. This is used by vnc and spicepasswordvalidto Set an expiration date for password. After the date/time has passed, all new graphical connections are denyed until a new password is set. This is used by vnc and spice
The format for this value is YYYY-MM-DDTHH:MM:SS , for example 2011-04-01T14:30:15--vnc
Virtualization Type options
Device Options --host-device pci_0000_00_1b_0 A node device name via libvirt, as shown by virsh nodedev-list--host-device 001.003 USB by bus, device (via lsusb).--host-device 0x1234:0x5678 USB by vendor, product (via lsusb).--host-device 1f.01.02 PCI device (via lspci).--soundhw
This deprecates the old boolean --sound model (which still works the same as a single --soundhw default)--watchdog MODEL[,action=ACTION] reset Forcefully reset the guest (the default)poweroff Forcefully power off the guestpause Pause the guestnone Do nothingshutdown Gracefully shutdown the guest (not recommended, since a hung guest probably wont respond to a graceful shutdown)MODEL
Use the recommended settings:
Use the i6300esb with the poweroff action
--watchdog i6300esb,action=poweroff--parallel=CHAROPTS --serial pty Pseudo TTY . The allocated pty will be listed in the running guests 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 .--serial pipe,path=PIPEPATH Named pipe (see pipe(7))--serial tcp,host=HOST:PORT,mode=MODE,protocol=PROTOCOL TCP net console. MODE is either bind (wait for connections on HOST:PORT ) or connect (send output to HOST:PORT ), default is connect. HOST defaults to 127.0.0.1, but PORT is required. PROTOCOL can be either raw or telnet (default raw). If telnet, the port acts like a telnet server or client. Some examples:
Connect to localhost, port 1234:
Wait for connections on any address, port 4567:
Wait for telnet connection on localhost, port 2222. The user could then connect interactively to this console via telnet localhost 2222:
--serial tcp,host=:2222,mode=bind,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 is only set if BIND_PORT is specified). Some examples:
Send output to default syslog port (may need to edit /etc/rsyslog.conf accordingly):
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--channel
Some of the types of character device redirection are:--channel SOURCE ,target_type=guestfwd,target_address=HOST:PORT Communication channel using QEMU usermode networking stack. The guest can connect to the channel using the specified HOST:PORT combination.--channel SOURCE ,target_type=virtio[,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, this will be exposed in the guest at /sys/class/virtio-ports/vport0p1/NAME--channel spicevmc,target_type=virtio[,name=NAME] Communication channel for QEMU spice agent, using virtio serial (requires 2.6.34 or later host and guest). NAME is optional metadata, and can be any string, such as the default com.redhat.spice.0 that specifies how the guest will see the channel.--console
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 http://fedoraproject.org/wiki/Features/VirtioSerial for more info. virtio console requires libvirt 0.8.3 or later.--video=VIDEO
Mode is one of host, host-certificates, or passthrough. Additional options are: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 guestSee http://libvirt.org/formatdomain.html#elementsSmartcard
If the guest has an install phase, you will need to use --print-step to specify exactly what XML output you want. This option implies --quiet.--print-step
Install a Fedora 13 KVM guest with virtio accelerated disk/network, creating a new 8GB storage file, installing from media in the hosts CDROM drive, auto launching a graphical VNC viewer# http://download.fedora.redhat.com/pub/fedora/linux/core/6/x86_64/os/Run a Live http://download.fedora.redhat.com/pub/fedora/linux/core/6/x86_64/os/Create a guest from an existing disk image mydisk.img using defaults for the rest of the options.
Written by Daniel P. Berrange, Hugh Brock, Jeremy Katz, Cole Robinson and a team of many other contributors. See the AUTHORS file in the source distribution for the complete list of credits.
Please see http://virt-manager.org/page/BugReporting
Copyright © 2006-2011 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 http://www.gnu.org/licenses/gpl.html. There is NO WARRANTY , to the extent permitted by law.