Virt Install Tool For Virtualization With KVM and Qemu For Linux


Virtualization and cloud computing is future of the IT. There are a lot of tools and architectures to make virtual the systems. Every big vendor have their original or clone virtualization technology or ecosystem. Linux provides KVM, Qemu for opensource, fast virtualization. Open source cloud ecosystem Openstack is mainly positioned on KVM,Libvirt and Qemu. In this tutorial we will look how to use virt-install tool to create new virtual machines.

Installation

virt-install is a tool provided by tools set. We will install it like below.

Ubuntu, Debian, Mint, Kali:

$ sudo apt install virtinst

Fedora, CentOS, RedHat:

$ yum install virt-install

Help

Virt-install supports a lot of different option. These options can be listed like below.

$ virt-install -h
Help
Help

Syntax

We will use following syntax for virt-install command.

virt-install --name NAME --ram RAM STORAGE INSTALL [options]

Specify Name

Every guest instance have a name to specify themselves. We can set the name of the guest instance with the -n or --name options. In the example we set vm name as test1 .

In order to run virt-install there are 3 mandatory options name , ram and disk image

$ sudo virt-install --name test1 --ram 300  --disk ./debian8.qcow2

Specify Disk File

Disk image is specified with --disk parameter. Disk image can be different types like qcow2 , vmdk , vdi etc.

http://www.poftut.com/linux-qemu-img-command-tutorial-examples-create-change-shrink-disk-images/

$ virt-install --name test1 --ram 300  --disk ./debian8.qcow2

Specify Ram

Ram can be specified with --ram option. Provided value will accepted as MB .

In this example we set ram as 500MB

$ virt-install --name test1 --ram 500  --disk ./debian8.qcow2

Specify Graphics

There are different graphic options. Here are those

  • VNC
  • Spice
  • Console
LEARN MORE  How To Specify Host, Port and Protocol For Tcpdump?

VNC

GUI connection to the vm can be setup with VNC protocol. We can specify VNC like below --graphics vnc option.

$ virt-install --name test1 --ram 500  --disk ./debian8.qcow2 --graphics vnc

Spice

Spice is a new protocol developed for virtuliazation. It is faster and better than VNC. Spice can be enabled with --graphics spice option.

$ virt-install --name test1 --ram 500  --disk ./debian8.qcow2 --graphics spice

Console

We can connect guests serial console to the our host console. This is useful if operating system has no GUI. We will use --console pty,target_type=serial --graphics none

$ virt-install --name test1 --ram 500  --disk ./debian8.qcow2 --console pty,target_type=serial --graphics none

Disable

We can disable the graphics completely with --graphics none option.

$ virt-install --name test1 --ram 500  --disk ./debian8.qcow2 --graphics none

Specify CPU

CPU type and feature set can be specified with--cpu option. In order to use host system CPU features use --cpu host . Or we can use coredue CPU with --cpu coredue option.

$ virt-install --name test1 --ram 500  --disk ./debian8.qcow2 --cpu host

Specify Network Interface

Another usefull feature is using host operating system networks to connect guest operating system. We will use -network option to specify related network resource. In this example we set host operating system bridge named virbr0 as network switch.

$ virt-install --name test1 --ram 500  --disk ./debian8.qcow2 --network bridge=virbr0

Specify Operating System Type

Linux KVM and qemu supports a lot of operating systems like BSD, Windows, Solaris etc. If we specify the operating system family and type qemu will arrange default options related with guest operating system. Some of the options offered by qemu are;

  • Windows
    • Windows XP
    • Windows 7
    • Windows Server 2008
    • Windows Server 2012
    • Windows Server 2016
  • Linux
    • Ubuntu
    • Debian
    • RedHat
    • Fedora
  • Unix
    • FreeBSD
LEARN MORE  What Is RAM (Random Access Memory)?

In the example we will specify Debian 8 as operating system type for qemu with --os-type and --os-variant options.

$ virt-install --name test1 --ram 500  --disk ./debian8.qcow2 --os-type linux --os-variant debian8

Disable GUI Console

We can disable related console if we do not need any GUI or the guest system do not provide any GUI. We will use --graphics none

$ virt-install --name test1 --ram 500  --disk ./debian8.qcow2 --graphics none

Leave a Comment