# Create a volume

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.

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 [#before-you-begin]

<BeforeYouBegin>

- The URN of the project to create the volume in.
- Permission `pvs.volume.create` on the project. See [Roles](/docs/iam/roles).
- An active organization. See [Organization review status](/docs/platform/organizations/review-status).
- A billing account that can pay. For card-managed billing, that means a verified payment method. See [Add a payment method](/docs/platform/billing/payment-method).
- Enough volume storage quota for the full size of the new volume. See [Limits](/docs/platform/reference/limits).
- To create from a snapshot: a snapshot in the same project that reports `status: COMPLETED` and `protectionStatus: PROTECTED`. See [Create and protect a snapshot](/docs/storage/snapshots/create-and-protect).

</BeforeYouBegin>

## Create an empty volume [#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](/docs/storage/volumes/storage-classes).

   ```sh
   origin storage list-storage-classes
   ```

1. Create the volume. `--size` is in GiB and defaults to 8.

   ```sh
   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`.

1. Check the volume’s status until it reports `AVAILABLE`.

   ```sh
   origin storage get-volume --volume-urn <volume-urn>
   ```

## Create a volume from a snapshot [#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`.

   ```sh
   origin storage get-snapshot --snapshot-urn <snapshot-urn>
   ```

1. 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.

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

   With the API, add `snapshotUrn` to the `createVolume` input.

1. Check the volume’s status until it reports `AVAILABLE`.

   ```sh
   origin storage get-volume --volume-urn <volume-urn>
   ```

## If this fails [#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](/docs/storage/troubleshooting).

## Next steps [#next-steps]

- [Attach and detach volumes](/docs/compute/instance-storage/attach-detach) – connect the volume to an instance, running or stopped.
- [Create and protect a snapshot](/docs/storage/snapshots/create-and-protect)

## Related [#related]

- [Volume states](/docs/storage/volumes/volume-states)
- [`create-volume` command](/docs/storage/reference/cli#create-volume)

