Use a LVM volume group with libvirt

A short howto how to use a LVM volume group with libvirt on Debian Squeeze (used for KVM VMs in my case). I assume your VG already exists and is dedicated for libvirt usage. In my case it’s /dev/vg1.

First of all, create the XML definition for the storage pool in /etc/libvirt/storage/vg1.xml. This is the minimal configuration needed, libvirt will extend it with things like UUID when you define it.

<pool type='logical'>
  <name>vg1</name>
  <target>
    <path>/dev/vg1</path>
  </target>
</pool>

Now you can tell libvirt about the new storage pool and let it start automatically.

$ virsh pool-define /etc/libvirt/storage/vg1.xml
$ virsh pool-start vg1
$ virsh pool-autostart vg1
$ virsh pool-info vg1

Creating virtual machines inside that storage pool is easy as pie:

$ virt-install -d --hvm --vnc --name=vm01 
    --ram 512 --disk pool=vg1,size=10,bus=virtio,cache=none 
    --network network=default,model=virtio 
    --location=http://ftp.debian.org/debian/dists/squeeze/main/installer-amd64/ 
    --os-type=linux --os-variant=debiansqueeze

Cheers!

  • I’ll post the same information to my blog, thanks for
    ideas and great article.

  • Foo Bar

    –accelerate Prefer KVM or KQEMU (in that order) if installing a QEMU guest. This behavior is now the default, and this option is deprecated. To install a plain QEMU guest, use ‘–virt-type qemu’