Use virt-install to install LVM based virtual machines (PVM).

There are few different options while you want to install virtual servers. you can also use default utility available with xen. virt-install is very famous among others. Its very simple and easy to use. In this article I will explain you how to install LVM based virtual server. I will assume that you have installation try available so that we can use kick start method to do quick install. If you don’t have installation tree available then please visit my previous article. “How to create local yum repository” available at

Lets start :
In my case physical volume is /dev/sda2. to find out which device is setup as PV in your system, you can use

pvscan OR pv command

This command will also show you volume group name identified by VG.
if you want to find out VolumeGroup name then you can use vgscan command also. NOW…

First of all we will need to create a logical volume which will be a disk for your virtual server. There is no need to format this lvm as we are going to use it as a raw disk. to create a disk use following command. I presume that you have enough unused disk space available in your volume group.

#lvcreate -L20G -n xenvm00 VolGroup00

well done. now you have your disk (logical volume) named xenvm00 ready to install virtual machine.
use following command to install virtual machine.

  1. #virt-install -p –name=xenvm00 –location= –bridge=xenbr0 –file=/dev/VolGroup00/xenvm00 –ram=2048 -x “ks=

    In above command :
    -p specifies it is para virtualized system,
    –name specifies hostname of virtual system you are installing.
    –location tells the location of your local centos / redhat / fedora repository. Please change it as per your convenience.
    –bridge tells which network device to specify for VM.
    –file specifies the disk for installation for your virtual system.
    –ram specifirs how much memory to be allocated.
    -x is for extra arguments. in this scenario we have spceified kick start file location. sample kick start file is also listed below.

    Follow the screen and answer the questions asked. as we are installing it through kickstart method, it will ask you minimum questions only…

  1. #Sample kickstart configuration

    url –url

    network –device eth0 –bootproto static –ip 192.168.X.Y –netmask 255.255.X.Y –gateway 192.168.X.Z –nameserver ns1,ns2 –hostname xenvm00
    lang en_US.UTF-8
    langsupport –default=en_GB.UTF-8 en_GB.UTF-8 en_US.UTF-8
    keyboard uk

    rootpw –iscrypted $1$1kdfjalsr8099404=-459qkfjdfoiaisfoalasdkfasdf0aw348r0
    firewall –enabled
    selinux –permissive
    authconfig –enableshadow –enablemd5
    timezone [put your timezone]
    bootloader –location=mbr –append=”console=ttyS0,115200 rhgb quiet”

    clearpart –all
    part /boot –fstype ext3 –size=256
    part pv.2 –size=0 –grow
    volgroup vg0 –pesize=32768 pv.2
    logvol swap –fstype swap –name=lvswap –vgname=vg0 –size=2048
    logvol / –fstype ext3 –name=lvroot –vgname=vg0 –size=4096
    logvol /usr –fstype ext3 –name=lvusr –vgname=vg0 –size=2048
    logvol /var –fstype ext3 –name=lvvar –vgname=vg0 –size=2048
    logvol /tmp –fstype ext3 –name=lvtmp –vgname=vg0 –size=2048

    #List of required packages to install. please add / remove packages or package groups as per your
    #very straight forward and easy.



    rpm –import

    chkconfig pcscd off
    chkconfig ntpd on
    chkconfig kudzu off
    chkconfig iptables off
    chkconfig ip6tables off
    chkconfig firstboot off
    chkconfig xinetd off
    chkconfig smartd off
    chkconfig isdn off
    chkconfig rhnsd off
    chkconfig gpm off
    chkconfig xfs off
    chkconfig cups-config-daemon off
    chkconfig cups off
    chkconfig yum-updatesd off
    chkconfig bluetooth off
    chkconfig portmap on
    chkconfig nfs on
    chkconfig nfslock on
    chkconfig nscd on

    # make sure default runlevel is 3
    sed -i “s/^id:5:init/id:3:init/g” /etc/inittab

    #enable listening to break on serial
    sed -i “s/^kernel.sysrq = 0/kernel.sysrq = 1/g” /etc/sysctl.conf

    echo “ttyS0” >> /etc/securetty
    echo “as:123456:respawn:/sbin/agetty ttyS0 115200 -h vt100-nav” >> /etc/inittab

    # dom0_mem
    sed -i “s/\(.*kernel.*xen.gz.*$\)/\1 dom0_mem=1024M/” /boot/grub/grub.conf
    cat > /etc/xen/xend-config.sxp <(xend-unix-server yes)
    (xend-relocation-server yes)
    (xend-unix-path /var/lib/xend/xend-socket)
    (xend-relocation-port 8002)
    (xend-relocation-address ”)
    (xend-relocation-hosts-allow ‘^localhost$ ^xen$’)
    (network-script ‘network-bridge netdev=bond0’)
    (vif-script vif-bridge)
    (dom0-min-mem 256)
    (dom0-cpus 0)

    (vncpasswd ”)

Leave a Reply

Your email address will not be published. Required fields are marked *