This section covers all commands for creating, deleting, and managing storage volumes. It is best to do this once you have created a storage pool as the storage pool name or UUID will be required. For information on storage pools refer to Chapter 12, Storage Pools
. For information on storage volumes refer to, Chapter 13, Volumes
14.12.1. Creating Storage Volumes
vol-create-from pool-or-uuid file command creates a storage volume, using another storage volume as a template for its contents. This command requires a pool-or-uuid which is the name or UUID of the storage pool to create the volume in.
--inputpool pool-or-uuid vol-name-or-key-or-path
argument specifies the XML file and path containing the volume definition. The
option specifies the name or uuid of the storage pool the source volume is in. The vol-name-or-key-or-path
argument specifies the name or key or path of the source volume. For some examples, refer to Section 13.1, “Creating Volumes”
command creates a volume from a set of arguments. The pool-or-uuid
argument contains the name or UUID of the storage pool to create the volume in.
vol-create-as pool-or-uuid name capacity
name is the name of the new volume. capacity is the size of the volume to be created, as a scaled integer, defaulting to bytes if there is no suffix.
--allocation is the initial size to be allocated in the volume, also as a scaled integer defaulting to bytes.
--format is used in file based storage pools to specify the volume file format which is a string of acceptable formats separated by a comma. Acceptable formats include
--backing-vol vol-name-or-key-or-path is the source backing volume to be used if taking a snapshot of an existing volume.
--backing-vol-format string is the format of the snapshot backing volume which is a string of formats separated by a comma. Accepted values include:
host_device. These are, however, only meant for file based storage pools.
22.214.171.124. Creating a storage volume from an XML file
vol-create pool-or-uuid file creates a storage volume from a saved XML file. This command also requires the pool-or-uuid, which is the name or UUID of the storage pool in which the volume will be created. The file argument contains the path with the volume definition's XML file. An easy way to create the XML file is to use the
vol-dumpxml command to obtain the definition of a pre-existing volume, modify it and then save it and then run the
virsh vol-dumpxml --pool storagepool1 appvolume1 > newvolume.xml
virsh edit newvolume.xml
virsh vol-create differentstoragepool newvolume.xml
Other options available include:
--inactive option lists the inactive guest virtual machines (that is, guest virtual machines that have been defined but are not currently active).
--all option lists all guest virtual machines.
126.96.36.199. Cloning a storage volume
vol-clone command clones an existing storage volume. Although the
--pool pool-or-uuid vol-name-or-key-or-path name
vol-create-from may also be used, it is not the recommended way to clone a storage volume. The
--pool pool-or-uuid option is the name or UUID of the storage pool to create the volume in. The vol-name-or-key-or-path argument is the name or key or path of the source volume. Using a name argument refers to the name of the new volume.