Thursday, January 12, 2012

Create storage infrastructure with libvirt

Libvirt is defacto library to manage virtual machines. This will show how you can create a storage pool that can be used later to allocate space for vms.


my storage space is located under /storage and the type is a regular directory as i want to store image files in there. this is low performance but will do for my dev machines.

first you need to create the directory

mkdir /storage

# then you need to have an xml file as follow - see type is dir and path is /storage

<pool type="dir">
        <name>storage_01</name>
        <target>
          <path>/storage</path>
        </target>

</pool>

# than go into virsh and define the new pool - define will make the pool  persistent into the /etc/libvirt/

virsh# pool-list
virsh# pool-autostart pool_name
<name>sparse.img</name>
<allocation>0</allocation>
<capacity unit="T">1</capacity>
<target>
  <path>/var/lib/virt/images/sparse.img</path>
  <permissions>
    <owner>107</owner>
    <group>107</group>
    <mode>0744</mode>
    <label>virt_image_t</label>
  </permissions>
</target>
</volume>

2 comments:

Sathees said...

That was a nice and good practical example

Anonymous said...

What's so practical about it? It stops short of being practical by not going into how to use the storage pool.