Virsh vol-clone: Difference between revisions
(Created page with "=Internal= * virsh =Overview= virsh vol-clone --pool <storage-pool-name> <source-volume-name> <new-volume-name> =Example= virsh vol-clone --pool main...") |
|||
(18 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=External= | |||
* https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Virtualization_Deployment_and_Administration_Guide/sect-Storage_Volumes-Cloning_volumes.html | |||
* https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Virtualization_Deployment_and_Administration_Guide/sect-Managing_guest_virtual_machines_with_virsh-Storage_Volume_Commands.html#sect-Creating_storage_volumes-Cloning_a_storage_volume | |||
=Internal= | =Internal= | ||
* [[virsh#Commands|virsh]] | * [[virsh#Commands|virsh]] | ||
* [[Linux_Virtualization_Operations#Virtualization_Host_Storage_Operations|Other Virtualized Storage Operations]] | |||
=Overview= | =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> | virsh vol-clone --pool <storage-pool-name> <source-volume-name> <new-volume-name> | ||
= | {{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= | |||
==Cloning a Raw Volume== | |||
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. | |||
virsh vol-clone --pool main-storage-pool test-volume test-volume.raw | virsh vol-clone --pool main-storage-pool test-volume test-volume.raw | ||
virsh vol-list --pool main-storage-pool | |||
==Cloning a qcow2 Volume== | |||
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|Also, consider what you are cloning - some guests may contain software that, once duplicated, by break the state of the cluster. This was the case when an OpenShift node was cloned with etcd and OpenShift node daemons pre-installed. It is always best to clone a neutral template that was specifically prepared for that.}} | |||
virsh vol-clone --pool ''storage-pool-name'' --prealloc-metadata ''source-volume'' ''target-volume'' | |||
Example: | |||
virsh vol-clone --pool main-storage-pool --prealloc-metadata template.qcow2 node1.qcow2 | |||
Vol node1.qcow2 cloned from template.qcow2 | |||
virsh vol-list --pool main-storage-pool | virsh vol-list --pool main-storage-pool |
Latest revision as of 02:36, 18 October 2017
External
- https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Virtualization_Deployment_and_Administration_Guide/sect-Storage_Volumes-Cloning_volumes.html
- https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Virtualization_Deployment_and_Administration_Guide/sect-Managing_guest_virtual_machines_with_virsh-Storage_Volume_Commands.html#sect-Creating_storage_volumes-Cloning_a_storage_volume
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 Volume
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.
virsh vol-clone --pool main-storage-pool test-volume test-volume.raw virsh vol-list --pool main-storage-pool
Cloning a qcow2 Volume
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.
Also, consider what you are cloning - some guests may contain software that, once duplicated, by break the state of the cluster. This was the case when an OpenShift node was cloned with etcd and OpenShift node daemons pre-installed. It is always best to clone a neutral template that was specifically prepared for that.
virsh vol-clone --pool storage-pool-name --prealloc-metadata source-volume target-volume
Example:
virsh vol-clone --pool main-storage-pool --prealloc-metadata template.qcow2 node1.qcow2 Vol node1.qcow2 cloned from template.qcow2 virsh vol-list --pool main-storage-pool