3.2. Creating Storage Pools and Volumes

Aside from regular virtual disks, you can create libvirt storage pools and divide them into volumes. The latter can be asssigned to virtual environments as virtual disks.

Do the following:

  1. Create a storage pool definition. For example, mypool.xml:

    <pool type='dir'>
  2. Create the pool directory:

    # mkdir /vz/mypool
  3. Define and start the pool:

    # virsh pool-define mypool.xml
    Pool mypool defined from mypool.xml
    # virsh pool-start mypool
    Pool mypool started
  4. Create a volume definition. For example, mypool-volume1.xml:

    <volume type='file'>
      <capacity unit='G'>64</capacity>
        <format type='qcow2'/>
  5. Create the volume in the storage pool:

    # virsh vol-create mypool mypool-volume1.xml
    Vol disk1 created from mypool-volume1.xml
  6. Delete the default volume file:

    # rm -f /vz/mypool/volume1

You can now specify volume1 when creating a virtual machine. For example:

# virt-install \
--disk 'source.pool=mypool,source.volume=volume1,boot_order=1,size=64<...>' \

Or when creating a container. For example:

# vzpkg create image centos-7-x86_64 /vz/mypool/volume1
# ploop resize -s 64G /vz/mypool/volume1/DiskDescriptor.xml
# virt-install \
--disk 'source.pool=mypool,source.volume=volume1,boot.order=1'