Virsh vol-create-as: Difference between revisions
(25 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
* [[virsh#Commands|virsh]] | * [[virsh#Commands|virsh]] | ||
* [[Linux_Virtualization_Operations# | * [[Linux_Virtualization_Operations#Virtualization_Host_Storage_Volume_Operations|Virtualization Operations - Storage Volume Creation]] | ||
=Overview= | =Overview= | ||
Creates a [[Linux_Virtualization_Concepts#Storage_Volume|storage volume]]. | Creates a [[Linux_Virtualization_Concepts#Storage_Volume|storage volume]] from the given set of command-line arguments, unlike <code>[[Virsh_vol-create#Overview|vol-create]]</code>, which requires an XML file configuration. | ||
< | <syntaxhighlight lang='bash'> | ||
virsh vol-create-as --pool <pool-name> --name <volume-name> --capacity <capacity> --format <fomat> | virsh vol-create-as --pool <pool-name> --name <volume-name> --capacity <capacity> --format <fomat> | ||
</ | </syntaxhighlight> | ||
= | The <code>[[#--format|--format]]</code> is important, it could be "[[Linux_Virtualization_Concepts#raw|raw]]" or "[[Linux_Virtualization_Concepts#qcow2|qcow2]]". However, "qcow2" volumes are usually not required to be created manually, they can be create as part of the virtual machine provisioning with <code>[[Virt-install#Virtual_Machine_Creation|virt-install]]</code>. | ||
Before creating the volume, see: {{Internal|Linux_Virtualization_Naming_Conventions#Storage_Volume_Naming_Convention|Storage Volume Naming Convention}} | |||
For command line examples, see [[#Examples|Examples]] below. | |||
After creation, the corresponding virtualization host filesystem file should be visible in the directory corresponding to the storage pool (ex. <code>/main-storage-pool/docker-backend-storage.raw</code> or <code>/main-storage-pool/dp.qcow2</code>). | |||
=Naming Convention= | |||
{{Internal|Linux_Virtualization_Naming_Conventions#Storage_Volume_Naming_Convention|Storage Volume Naming Convention}} | {{Internal|Linux_Virtualization_Naming_Conventions#Storage_Volume_Naming_Convention|Storage Volume Naming Convention}} | ||
Line 58: | Line 66: | ||
Preallocate metadata for qcow2 images that don't support full allocation. This option creates a sparse image file with metadata, resulting in higher performance compared to images with no preallocation and only slightly higher initial disk space usage. | Preallocate metadata for qcow2 images that don't support full allocation. This option creates a sparse image file with metadata, resulting in higher performance compared to images with no preallocation and only slightly higher initial disk space usage. | ||
= | =Examples= | ||
==Create a New Raw Block Storage Volume== | |||
< | <syntaxhighlight lang='bash'> | ||
virsh vol-create-as --pool main-storage-pool --name test- | virsh vol-create-as --pool main-storage-pool --name test-nfs.raw --capacity 1G --format raw | ||
</ | </syntaxhighlight> |
Latest revision as of 00:39, 30 July 2023
External
Internal
Overview
Creates a storage volume from the given set of command-line arguments, unlike vol-create
, which requires an XML file configuration.
virsh vol-create-as --pool <pool-name> --name <volume-name> --capacity <capacity> --format <fomat>
The --format
is important, it could be "raw" or "qcow2". However, "qcow2" volumes are usually not required to be created manually, they can be create as part of the virtual machine provisioning with virt-install
.
Before creating the volume, see:
For command line examples, see Examples below.
After creation, the corresponding virtualization host filesystem file should be visible in the directory corresponding to the storage pool (ex. /main-storage-pool/docker-backend-storage.raw
or /main-storage-pool/dp.qcow2
).
Naming Convention
Options
--pool
The pool name or pool UUID. The "--pool" label is optional if the pool name is specified as the first argument.
--name
The storage volume name. The "--name" label is optional if the storage volume name is specified as the second argument.
--capacity
The capacity, followed by one of the suffixes 'b', 'k', 'M', 'G', 'T'. The capacity is specified in bytes if there is no suffix. The "--capacity" label is optional if the capacity is specified as the third argument.
--print-xml
If specified, the volume is not created, only the XML of the volume object is printed out.
--allocation
The initial size to be allocated in the volume, as a scaled integer defaulting to bytes.
--format
Acceptable format types: "raw", "bochs", "qcow", "qcow2", "qed", "host_device", and "vmdk". These are, however, only meant for file based storage pools. By default the qcow version that is used is version 3.
--backing-vol
The source backing volume to be used if taking a snapshot of an existing volume.
--backing-vol-format
The format of the snapshot backing volume; raw, bochs, qcow, qcow2, qed, vmdk, host_device.
--prealloc-metadata
Preallocate metadata for qcow2 images that don't support full allocation. This option creates a sparse image file with metadata, resulting in higher performance compared to images with no preallocation and only slightly higher initial disk space usage.
Examples
Create a New Raw Block Storage Volume
virsh vol-create-as --pool main-storage-pool --name test-nfs.raw --capacity 1G --format raw