Table of Contents

How to install KVM Guest OS with virt-install (CUI)

man virt-install

VIRT-INSTALL(1)          Virtual Machine Install Tools         VIRT-INSTALL(1)

NAME
       virt-install - provision new virtual machines

SYNOPSIS
       virt-install [OPTION]...

DESCRIPTION
       virt-install is a command line tool for creating new KVM, Xen, or Linux container guests using the "libvirt"
       hypervisor management library.

       virt-install tool supports graphical installations using (for example) VNC or SPICE, as well as text mode installs
       over serial console. 


   General Options

       --vcpus=VCPUS[,maxvcpus=MAX][,sockets=#][,cores=#][,threads=#]
         Number of virtual cpus to configure for the guest. If axvcpusis specified, the guest will be able to hotplug up to
         MAX vcpus while the guest is running, but will startup with VCPUS.

         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.



   Storage Configuration
       --disk=DISKOPTS
         Specifies media to use as storage for the guest, with various options. The general format of a disk string is

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

         To specify media, the command can either be:

             --disk /some/storage/path,opt1=val1

         or explicitly specify one of the following arguments:

         path
             A path to some storage media to use, existing or not. Existing media can be a file or block device.

             Specifying a non-existent path implies attempting to create the new storage, and will require specifyng a izevalue.
             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.

         size
             size (in GB) to use if creating new storage

         sparse
             whether to skip fully allocating newly created storage. Value is 'true' or 'false'.
             Default is 'true' (do not fully allocate) unless it isn't supported by the underlying storage type.


   Virtualization Type 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 connecting to a Xen hypervisor on a machine without hardware virtualization support.
         This parameter is implied if 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 the  "--hvm" are specified, this will be assumed.
EXAMPLES

       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

         # virt-install \
              --connect qemu:///system \
              --virt-type kvm \
              --name demo \
              --ram 500 \
              --disk path=/var/lib/libvirt/images/demo.img,size=8 \
              --graphics vnc \
              --cdrom /dev/cdrom \
              --os-variant fedora13

       Install a Fedora 9 plain QEMU guest, using LVM partition, virtual networking, booting from PXE, using VNC server/viewer

         # virt-install \
              --connect qemu:///system \
              --name demo \
              --ram 500 \
              --disk path=/dev/HostVG/DemoVM \
              --network network=default \
              --virt-type qemu
              --graphics vnc \
              --os-variant fedora9

       Run a Live CD image under Xen fullyvirt, in diskless environment

         # virt-install \
              --hvm \
              --name demo \
              --ram 500 \
              --nodisks \
              --livecd \
              --graphics vnc \
              --cdrom /root/fedora7live.iso

       Install a paravirtualized Xen guest, 500 MB of RAM, a 5 GB of disk, and Fedora Core 6 from a web server, in text-only mode,
       with old style --file options:

         # virt-install \
              --paravirt \
              --name demo \
              --ram 500 \
              --file /var/lib/xen/images/demo.img \
              --file-size 6 \
              --graphics none \
              --location 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.

         # virt-install \
              --name demo
              --ram 512
              --disk /home/user/VMs/mydisk.img
              --import


How to create a KVM image

If you use virt-install, you must not create a KVM images.


Install KVM Guest OS with virt-install

text mode

virt-install \
    --connect qemu:///system \
    --name test-server6 \
    --ram=1024 \
    --vcpus=2 \
    --hvm \
    --virt-type=kvm
    --cdrom=/var/lib/libvirt/images/CentOS-6.3-x86_64-bin-DVD1.iso  \
    --os-type=Linux \
    --disk=/var/lib/libvirt/images/test-server.img,format=qcow2 \
    --network bridge=br0 \
    --nographics \
    --vnc --vncport=5900 --vnclisten=0.0.0.0 \ 
    --keymap ja \
    --extra-args='console=tty0 console=ttyS0,115200n8'

pxe install

virt-install \
    --connect qemu:///system \
    --name test-server6 \
    --ram=1024 \
    --vcpus=2 \
    --hvm \
    --virt-type=kvm
    --pxe  \
    --os-type=Linux \
    --disk=/var/lib/libvirt/images/test-server.img,size=50 \
    --network bridge=br0 \
    --nographics \
    --vnc --vncport=5900 --vnclisten=0.0.0.0 \ 
    --keymap ja \
    --extra-args='console=tty0 console=ttyS0,115200n8'




Install acpi after kvm guest os installed

acpi for shutdown from host os

# yum install acpid
# chkconfig acpid on