Red Hat Training
A Red Hat training course is available for Red Hat Enterprise Linux
14.12. Storage Volume Commands
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 filecommand 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.
The file argument specifies the XML file and path containing the volume definition. The
--inputpool pool-or-uuidoption 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”.
vol-create-ascommand 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.
--allocationis the initial size to be allocated in the volume, also as a scaled integer defaulting to bytes.
--formatis 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-pathis the source backing volume to be used if taking a snapshot of an existing volume.
--backing-vol-format stringis 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.
184.108.40.206. Creating a storage volume from an XML file
vol-create pool-or-uuid filecreates 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-dumpxmlcommand 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:
--inactiveoption lists the inactive guest virtual machines (that is, guest virtual machines that have been defined but are not currently active).
--alloption lists all guest virtual machines.
220.127.116.11. Cloning a storage volume
vol-clonecommand clones an existing storage volume. Although the
--pool pool-or-uuidvol-name-or-key-or-path name
vol-create-frommay also be used, it is not the recommended way to clone a storage volume. The
--pool pool-or-uuidoption 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.