Volume Clone Support

Creating a new volume as a duplicate of an existing volume

Longhorn supports CSI volume cloning.

Volume Cloning

Clone a Volume Using YAML

Suppose that you have the following source-pvc:

  1. apiVersion: v1
  2. kind: PersistentVolumeClaim
  3. metadata:
  4. name: source-pvc
  5. spec:
  6. storageClassName: longhorn
  7. accessModes:
  8. - ReadWriteOnce
  9. resources:
  10. requests:
  11. storage: 10Gi

You can create a new PVC that has the exact same content as the source-pvc by applying the following yaml file:

  1. apiVersion: v1
  2. kind: PersistentVolumeClaim
  3. metadata:
  4. name: cloned-pvc
  5. spec:
  6. storageClassName: longhorn
  7. dataSource:
  8. name: source-pvc
  9. kind: PersistentVolumeClaim
  10. accessModes:
  11. - ReadWriteOnce
  12. resources:
  13. requests:
  14. storage: 10Gi

Note: In addition to the requirements listed at CSI volume cloning, the cloned-pvc must have the same resources.requests.storage as the source-pvc.

Clone Volume Using the Longhorn UI

Clone a volume

  1. Go to the Volume page.
  2. Select a volume, and then click Clone Volume in the Operation menu.
  3. (Optional) Configure the settings of the new volume.
  4. Click OK.

Clone a Volume Using a Snapshot

  1. Go to the Volume page.
  2. Click the name of the volume that you want to clone.
  3. In the Snapshot and Backups section of the details screen, identify the snapshot that you want to use and then click Clone Volume.
  4. (Optional) Configure the settings of the new volume.
  5. Click OK.
Volume Clone Support - 图1

Clone Multiple Volumes (Bulk Cloning)

  1. Go to the Volume page.
  2. Select the volume you want to clone.
  3. Click Clone Volume button on top of the table.
  4. (Optional) Configure the settings of the new volumes
  5. Click OK

Note:

  • The Longhorn UI pre-fills certain fields and prevents you from modifying the values to ensure that those match the settings of the source volume.
  • Longhorn automatically attaches the new volume, clones the source volume, and then detaches the new volume.

Volume Creation

  1. Go to the Volume page.
  2. Click Create Volume.
  3. Select the data source (Volume or Volume Snapshot) that you want to use.
  4. If you select Volume Snapshot, choose a snapshot.
  5. Specify the volume name.
  6. Click OK.
Volume Clone Support - 图2

History

Available since v1.2.0