INTRODUCTION
This chapter explains how you can set up LVM-based virtual machines instead of virtual machines that use disk images. Virtual machines that use disk images are very slow and heavy on disk IO.
In this example I’m using a CentOS 6.2 host with the LVM volume group /dev/VolGroup00 that has about 465GB of space. /dev/VolGroup00 contains two logical volumes,/dev/VolGroup00/LogVol00 and /dev/VolGroup00/LogVol01 that consume about 104GB of space – the rest is not allocated and can be used to create logical volumes for our virtual machines:
#vgdisplay
— Volume group —
VG Name Vol_www
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 194.82 GiB
PE Size 4.00 MiB
Total PE 49875
Alloc PE / Size 24032 / 93.88 GiB
Free PE / Size 25843 / 100.95 GiB
VG UUID LCdZgy-jVrp-S92Q-RQeI-H87G-jiko-4fmaHF

# lvdisplay
— Logical volume —
LV Name /dev/vg_www/lv_root
VG Name vg_www
LV UUID n5remv-KYEE-O0Ry-g2r6-OrUe-rjyV-x65rHu
LV Write Access read/write
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:0
— Logical volume —
LV Name /dev/vg_www/lv_home
VG Name vg_www
LV UUID CnvnGP-sDL8-OtBU-OzTT-VjZQ-ZIUo-yzISkX
LV Write Access read/write
LV Status available
# open 1
LV Size 40.00 GiB
Current LE 10240
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:2
I want to create the virtual machine vm02 now which uses the logical volume /dev/VolGroup00/vm02. I want the virtual machine to have a disk space of 10GB, so I create the logical volume /dev/VolGroup00/vm02 as follows:
#lvcreate -L10G -n vm02 vg_www
Afterwards we can run
#virt-install –prompt –network bridge=br0 –virt-type=xen
again:
Would you like a fully virtualized guest (yes or no)? This will allow you to run unmodified operating systems.
<– no
What is the name of your virtual machine?
<– vm02
How much RAM should be allocated (in megabytes)?
<– 1024
What would you like to use as the disk (file path)?
<– /dev/vg_www/vm02
What is the install URL?
<– http://ftp.tu-chemnitz.de/pub/linux/centos/6.3/os/x86_64
As the disk file path, we specify our new volume group /dev/vg_www/vm02. Please note that virt-install doesn’t ask for the disk space anymore because the disk space is determined by the size of the logical volume (10GB).














