Skip to content

Storage / Task

Create a volume

Updated · 3 min read

Create an empty volume or a volume from a protected snapshot with the origin CLI or the GraphQL API, and check that it becomes AVAILABLE.

On this page6 sections

Create a standalone volume when you need a disk that isn’t tied to one instance’s lifetime. You can create an empty volume of a given size, or a volume that starts with the data of a snapshot.

Before you begin

Create an empty volume

  1. Optional: list the storage classes and pick one whose available is true. Omit the class to get the default, gp1. See Storage classes.

    terminal
    origin storage list-storage-classes
  2. Create the volume. --size is in GiB and defaults to 8.

    terminal
    origin storage create-volume --project-urn <project-urn> \
      --size 100 --storage-class gp1

    With the API, use the createVolume mutation:

    GraphQL
    mutation {
      pvs {
        createVolume(input: {
          projectUrn: "<project-urn>"
          sizeInGib: 100
          storageClass: "gp1"
        }) {
          urn
          status
        }
      }
    }

    The new volume reports CREATING. Note its urn.

  3. Check the volume’s status until it reports AVAILABLE.

    terminal
    origin storage get-volume --volume-urn <volume-urn>

Create a volume from a snapshot

A volume created from a snapshot starts with the data the snapshot captured. The snapshot must belong to the project you create the volume in. A snapshot in another project is refused as not found, even within the same organization.

The platform checks three more rules before it creates anything:

  • The snapshot reports status: COMPLETED.
  • The snapshot reports protectionStatus: PROTECTED.
  • The size you ask for is at least the size of the volume the snapshot was taken from, shown as the snapshot’s volumeSizeInGib. A larger size gives you the extra space.

If a rule doesn’t hold, the request is refused with an error that names the rule. Nothing is created.

  1. Check the snapshot’s status, protectionStatus, and volumeSizeInGib.

    terminal
    origin storage get-snapshot --snapshot-urn <snapshot-urn>
  2. Create the volume, passing a size of at least volumeSizeInGib. In the CLI, always pass --size: its default of 8 GiB is refused for a snapshot of a larger volume.

    terminal
    origin storage create-volume --project-urn <project-urn> \
      --snapshot-urn <snapshot-urn> --size 100

    With the API, add snapshotUrn to the createVolume input.

  3. Check the volume’s status until it reports AVAILABLE.

    terminal
    origin storage get-volume --volume-urn <volume-urn>

If this fails

If the volume reports ERROR instead of AVAILABLE, its creation failed and statusReason says why. Delete it and create a new one. For refused requests, such as PRODUCT_UNAVAILABLE or a quota error, see Troubleshoot storage.

Next steps