Skip to main content
Versi: Latest

Create a Volume

Create an Empty Volume

Header Section

  1. Set the Volume Name.
  2. (Optional) Provide a Description for the Volume.

Basics Tab

  1. Choose New in Source.
  2. Select an existing StorageClass.
  3. Configure the Size of the volume.

create-empty-volume

caution
  • If the replica count of the selected StorageClass is 1 and the volume is attached to a virtual machine, then the virtual machine is considered non-migratable.

  • When a volume is created, it copied the related parameters from the selected StorageClass to itself. If you change the parameters of the StorageClass later, it does not write back to the volume.

Oversized Volumes

In Hypervisor v1.0, which uses Longhorn v1.8.1, oversized volumes (for example, 999999 Gi in size) are marked Not Ready and cannot be deleted.

To resolve this issue, perform the following steps:

  1. Temporarily remove the PVC webhook rule.

    RULE_INDEX=$(kubectl get \
    validatingwebhookconfiguration longhorn-webhook-validator -o json \
    | jq '.webhooks[0].rules | map(.resources[0] == "persistentvolumeclaims") | index(true)')

    if [ -n "$RULE_INDEX" -a "$RULE_INDEX" != "null" ]; then
    kubectl patch validatingwebhookconfiguration longhorn-webhook-validator \
    --type='json' \
    -p="[{'op': 'remove', 'path': '/webhooks/0/rules/$RULE_INDEX'}]"
    fi
  2. Wait for the related PVC to be deleted.

  3. Restore the PVC webhook rule to re-enable validation.

    kubectl patch validatingwebhookconfiguration longhorn-webhook-validator \
    --type='json' \
    -p='[{"op": "add", "path": "/webhooks/0/rules/-", "value": {"apiGroups":[""],"apiVersions":["v1"],"operations":["UPDATE"],"resources":["persistentvolumeclaims"],"scope":"Namespaced"}}]'

Create an Image Volume

Header Section

  1. Set the Volume Name.
  2. (Optional) Provide a Description for the Volume.

Basics Tab

  1. Choose VM Image in Source.
  2. Select an existing Image.
  3. Configure the Size of the volume.
important

When creating volumes from a VM image, ensure that the volume size is greater than or equal to the image size. The volume may become corrupted if the configured volume size is less than the size of the underlying image. This is particularly important for qcow2 images because the virtual size is typically greater than the physical size.

By default, Hypervisor will set the volume size to the virtual size of the image.

create-image-volume