Virt-install

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

External

Internal

Overview

virt-install is a command-line utility for provisioning new virtual machines. It comes as part of the "virt-install" RPM package.

virt-install needs root privileges to work.

Documentation

virt-install --help

Mandatory Options

Guest Virtual Machine Name

The name of the guest virtual machine must be specified with --name or -n:

--name test-01

Memory Amount

virt-install needs the amount of memory allocated to the guest, in MiB, which must be specified with --memory:

--memory 1024

Guest Storage Specification

One of the following must be specified:

--disk

Specifies guest storage, relative to the storage provided by the virtualization host. The most common option is to refer storage from a storage pool, but other options are also available.

--disk size=10

Specified a new 10 GiB image on the default storage pool.

--disk /storage-pool-path/volume-path,size=8,sparse=false,cache=none
--disk device=cdrom,bus=scsi
--disk=?

--nodisks

Installation Method Option

--os-type

The quest operating system type.

Example:

--os-type=linux

--os-variant

This is an important option, used to optimize guest configuration. Valid "--os-variant" values can be obtained with osinfo-query os command

Example:

--os-variant=rhel7.3

Distribution Tree Installation Source

The distribution tree installation source is specified with --location. virt-install can fetch a bootable kernel/initrd pair to launch the install.

--location

The location of the installation media. Examples:

--location file:///path
--location http://host/path
--location nfs:host:/path

--cdrom

--cdrom CDROM specifies a CD-ROM installation media.

Optional Installation Method Option

--boot

--boot BOOT_OPTS is used to configure guest boot settings:

--boot hd,cdrom,menu=on
--boot init=/sbin/init

--pxe

Boot from the network using the PXE protocol.

--import

Build guest around an existing disk image.

--extra-args=

--extra-args EXTRA_ARGS Additional arguments to pass to the install kernel booted from --location.

Optional Configuration

Graphics

Specifies the type of graphical tool to use for interactive installation or can be set to "none" for a fully automated installation.

--graphics none|spice|...

Network Specification

The network specification is optional, if not defined, a ? will be configured on the guest. Otherwise, it can be specified with '--network NETWORK-SPEC', as follows:

TODO

--network bridge=mybr0

If using a bridge, the bridge must be previously created, as described here Bridged Networking Configuration.

--network network=my_libvirt_virtual_net
--network network=mynet,model=virtio,mac=00:11..
--network none

--vcpus

Specifies the number of virtual CPUs for the guest.

Virtualization Platform Options

-v, --hvm

This guest should be a fully virtualized guest.

-p, --paravirt

This guest should be a paravirtualized guest.

--container

This guest should be a container guest.

--virt-type

Represents the hypervisor name to use ("kvm", "qemu", "xen", etc.)

Access to a Host Directory

"--filesystem" can be used to specify a host directory to be available on the guest.

Example:

--filesystem /my/host/source/dir,/dir/in/guest

Examples

Text-Based Anaconda Guest Installation

virt-install --name testvm-01 --memory 1024 --os-type=linux --os-variant=rhel7.3 --location /mnt/RHEL7DVD --graphics none \
--disk=/main-storage-pool/testvm-01.img,size=4 \
--extra-args="console=tty0 console=ttyS0,115200n8"


TO TEST:

NAT:

virt-install --network=default --name=rhel7-machine --ram=756 --vcpus=4 --os-type=linux --os-variant=rhel7

External DHCP server:

virt-install --network=br0 \ --name=rhel7-machine --ram=756 --vcpus=4 \ --os-type=linux --os-variant=rhel7


Static IPV4 Address:

virt-install \ --network=br0 \
--name=rhel7-machine --ram=756 --vcpus=4 \ --os-type=linux --os-variant=rhel7 \ --extra-args="ip=192.168.1.2::192.168.1.1:255.255.255.0:test.example.com:eth0:n one

The arguments of the --extra-args parameter specify the static network setting, using the following structure:

ip=[ip]::[gateway]:[netmask]:[hostname]:[interface]:[autoconf]