|
3 | 3 | // * virt/virtual_machines/cloning_vms/virt-cloning-vm-disk-into-new-datavolume.adoc |
4 | 4 | // * virt/virtual_machines/cloning_vms/virt-cloning-vm-disk-to-new-block-storage-pvc.adoc |
5 | 5 |
|
6 | | -// `blockstorage` conditionals are used (declared in the "*-block" assembly) to separate content |
7 | | - |
8 | 6 | :_content-type: PROCEDURE |
9 | 7 | [id="virt-cloning-pvc-of-vm-disk-into-new-datavolume_{context}"] |
10 | | -= Cloning the persistent volume claim of a virtual machine disk into a new data volume |
| 8 | += Cloning the PVC of a VM disk into a new data volume |
11 | 9 |
|
12 | | -You can clone a persistent volume claim (PVC) of an existing virtual machine disk |
| 10 | +You can clone the persistent volume claim (PVC) of an existing (virtual machine) VM disk |
13 | 11 | into a new data volume. The new data volume can then be used for a new virtual |
14 | 12 | machine. |
15 | 13 |
|
16 | 14 | [NOTE] |
17 | 15 | ==== |
18 | | -When a data volume is created independently of a virtual machine, the lifecycle |
19 | | -of the data volume is independent of the virtual machine. If the virtual machine |
20 | | -is deleted, neither the data volume nor its associated PVC is deleted. |
| 16 | +When a data volume is created independently of a VM, the lifecycle of the data volume is independent of the VM. If the VM is deleted, neither the data volume nor its associated PVC is deleted. |
21 | 17 | ==== |
22 | 18 |
|
23 | 19 | .Prerequisites |
24 | 20 |
|
25 | | -* Determine the PVC of an existing virtual machine disk to use. You must power |
26 | | -down the virtual machine that is associated with the PVC before you can clone it. |
27 | | -* Install the OpenShift CLI (`oc`). |
28 | | -ifdef::blockstorage[] |
29 | | -* At least one available block persistent volume (PV) that is the same size as or larger than the source PVC. |
30 | | -endif::[] |
| 21 | +* The VM must be stopped. |
31 | 22 |
|
32 | 23 | .Procedure |
33 | 24 |
|
34 | | -. Examine the virtual machine disk you want to clone to identify the name and |
35 | | -namespace of the associated PVC. |
36 | | - |
37 | | -. Create a YAML file for a data volume that specifies the name of the |
38 | | -new data volume, the name and namespace of the source PVC, |
39 | | -ifdef::blockstorage[] |
40 | | -`volumeMode: Block` so that an available block PV is used, |
41 | | -endif::[] |
42 | | -and the size of the new data volume. |
43 | | -+ |
44 | | -For example: |
| 25 | +. Create a YAML file for a data volume as shown in the following example: |
45 | 26 | + |
46 | 27 | [source,yaml] |
47 | 28 | ---- |
48 | 29 | apiVersion: cdi.kubevirt.io/v1beta1 |
49 | 30 | kind: DataVolume |
50 | 31 | metadata: |
51 | | - name: <cloner-datavolume> <1> |
| 32 | + name: <datavolume> <1> |
52 | 33 | spec: |
53 | 34 | source: |
54 | 35 | pvc: |
55 | | - namespace: "<source-namespace>" <2> |
56 | | - name: "<my-favorite-vm-disk>" <3> |
57 | | - pvc: |
58 | | - accessModes: |
59 | | - - ReadWriteOnce |
60 | | - resources: |
61 | | - requests: |
62 | | - storage: <2Gi> <4> |
63 | | -ifdef::blockstorage[] |
64 | | - volumeMode: Block <5> |
65 | | -endif::[] |
| 36 | + namespace: "<source_namespace>" <2> |
| 37 | + name: "<my_vm_disk>" <3> |
| 38 | + storage: {} |
66 | 39 | ---- |
67 | | -<1> The name of the new data volume. |
68 | | -<2> The namespace where the source PVC exists. |
69 | | -<3> The name of the source PVC. |
70 | | -<4> The size of the new data volume. You must allocate enough space, or the |
71 | | -cloning operation fails. The size must be the same as or larger than the source PVC. |
72 | | -ifdef::blockstorage[] |
73 | | -<5> Specifies that the destination is a block PV |
74 | | -endif::[] |
| 40 | +<1> Specify the name of the new data volume. |
| 41 | +<2> Specify the namespace of the source PVC. |
| 42 | +<3> Specify the name of the source PVC. |
75 | 43 |
|
76 | | -. Start cloning the PVC by creating the data volume: |
| 44 | +. Create the data volume by running the following command: |
77 | 45 | + |
78 | 46 | [source,terminal] |
79 | 47 | ---- |
80 | | -$ oc create -f <cloner-datavolume>.yaml |
| 48 | +$ oc create -f <datavolume>.yaml |
81 | 49 | ---- |
82 | 50 | + |
83 | 51 | [NOTE] |
84 | 52 | ==== |
85 | | -Data volumes prevent a virtual machine from starting before the PVC is prepared, |
86 | | -so you can create a virtual machine that references the new data volume while the |
87 | | -PVC clones. |
| 53 | +Data volumes prevent a VM from starting before the PVC is prepared. You can create a VM that references the new data volume while the |
| 54 | +PVC is being cloned. |
88 | 55 | ==== |
0 commit comments