Virsh vol-clone: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 15: Line 15:


{{Warn|The virsh man page does not explicitly require it, but it is probably better to make sure the source volume is not in use while cloning.}}
{{Warn|The virsh man page does not explicitly require it, but it is probably better to make sure the source volume is not in use while cloning.}}
For qcow2 volumes for qcow2 images which don't support full allocation, --prealloc-metadata can be used. --prealloc-metadata preallocates metadata and 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=
=Examples=

Revision as of 18:54, 2 July 2017

External

Internal

Overview

The operation clones the source volume within the same storage pool, It allocates space for the target volume and copies the content across. Various optimizations are applied depending on the source volume format.

virsh vol-clone --pool <storage-pool-name> <source-volume-name> <new-volume-name>

The virsh man page does not explicitly require it, but it is probably better to make sure the source volume is not in use while cloning.

For qcow2 volumes for qcow2 images which don't support full allocation, --prealloc-metadata can be used. --prealloc-metadata preallocates metadata and 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

Cloning a Raw Format Volume

virsh vol-clone --pool main-storage-pool test-volume test-volume.raw
virsh vol-list --pool main-storage-pool

Cloning a qcow2 Format Volume

virsh vol-clone --pool main-storage-pool test-volume test-volume.raw
virsh vol-list --pool main-storage-pool