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:
Create a storage pool definition. For example,
mypool.xml
:<pool type='dir'> <name>mypool</name> <target> <path>/vz/mypool</path> </target> </pool>
Create the pool directory:
# mkdir /vz/mypool
Define and start the pool:
# virsh pool-define mypool.xml Pool mypool defined from mypool.xml # virsh pool-start mypool Pool mypool started
Create a volume definition. For example,
mypool-volume1.xml
:<volume type='file'> <name>volume1</name> <capacity unit='G'>64</capacity> <target> <format type='qcow2'/> </target> </volume>
Create the volume in the storage pool:
# virsh vol-create mypool mypool-volume1.xml Vol disk1 created from mypool-volume1.xml
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'
<...>
Version 9.0 Alpha — Jul 15, 2022