> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gcore.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a volume

> Create a blank Gcore volume, a boot volume from an image, or a volume from a snapshot.

## Customer Portal

A blank volume, or a volume restored from a snapshot, can be created in the same region as the Virtual Machine that will use it. A volume can also be created together with a new [Virtual Machine](https://docs.gcore.com/cloud/virtual-instances/create-an-instance.md).

## Create a volume

The **Volumes** page creates a blank volume. The **Snapshots** page creates a volume from an existing snapshot.

> [tab] From the Volumes page
>
> 1\. In the Gcore Customer Portal, navigate to **Cloud** > **Storage**.
>
> 2\. Click **Create Volume**.
>
> ![Volumes page with numbered storage and create volume tabs](https://mintcdn.com/gcore/sgf4_7UBAOp9SmxG/images/docs/cloud/virtual-instances/volumes/manage-a-volume/create-volume.png?fit=max\&auto=format\&n=sgf4_7UBAOp9SmxG\&q=85\&s=944267f3ce44db8897aac8e5d449a892)
>
> 3\. The **Create volume** side panel opens on the Volumes page. Volume settings can be customized here.
>
> ![Dialog with options for configuring new volume](https://mintcdn.com/gcore/sgf4_7UBAOp9SmxG/images/docs/cloud/virtual-instances/volumes/manage-a-volume/new-volume-volumes-page.png?fit=max\&auto=format\&n=sgf4_7UBAOp9SmxG\&q=85\&s=66f50ccaf21ae7ee49c603c703e12c97)
>
> 4\. Specify the required disk space in GB. If the size exceeds the current limit, request a [quota increase](https://docs.gcore.com/cloud/getting-started/request-a-quota-increase.md#how-to-send-a-request).
>
> 5\. Select the [volume type](https://docs.gcore.com/cloud/virtual-instances/volumes/about-volumes.md#available-volume-types). Faster volume types are designed for latency-sensitive transactional operations and storing critical data. Slower volumes are more suitable for archived or non-critical data and for less frequent operations.
>
> 6\. (Optional) Attach the volume to an existing [Virtual Machine](https://docs.gcore.com/cloud/virtual-instances/create-an-instance.md) in the same region.
>
> 7\. Enter a volume name using Latin letters, numbers, underscores, spaces, and dots. The name is 3-63 characters long.
>
> > [!TIP]
> >
> > Volume names in the Customer Portal or API do not need to match device names in the operating system (sda, sdb, or sdc). For OS operations, use Universally Unique Identifiers (UUIDs) instead of names.
>
> 8\. (Optional) Select the **Add tags** checkbox and specify tags as key-value pairs.
>
> 9\. Click **Create**.
>
> The volume will appear on the **Volumes** page.

> [tab] From a volume snapshot
>
> To duplicate or back up Virtual Machine data, create a volume from an existing [snapshot](https://docs.gcore.com/cloud/virtual-instances/snapshots/take-a-snapshot-of-your-file-system.md). A snapshot must exist in the same region first.
>
> 1\. In the Gcore Customer Portal, navigate to **Cloud** > **Storage** > **Snapshots**.
>
> 2\. Select the target snapshot and click the three-dot icon to open snapshot settings.
>
> ![Snapshots tab with expanded settings menu](https://mintcdn.com/gcore/sgf4_7UBAOp9SmxG/images/docs/cloud/virtual-instances/volumes/manage-a-volume/new-volume-snapshot.png?fit=max\&auto=format\&n=sgf4_7UBAOp9SmxG\&q=85\&s=63a0fe340766efd0b9a97b823391144e)
>
> 3\. Click **Create Volume**.
>
> 4\. Select the Virtual Machine to attach the new volume to.
>
> 5\. Click **Create**.
>
> ![Create volume dialog with options to select Virtual Machine and add volume name](https://mintcdn.com/gcore/sgf4_7UBAOp9SmxG/images/docs/cloud/virtual-instances/volumes/manage-a-volume/create-volume-from-snapshot.png?fit=max\&auto=format\&n=sgf4_7UBAOp9SmxG\&q=85\&s=cc3e2f4e62e49cba55f0ad45e1c51ec1)
>
> The volume will appear on the **Volumes** page.

An existing volume can be attached, resized, or deleted in [Manage a volume](https://docs.gcore.com/cloud/virtual-instances/volumes/manage-a-volume.md).

## REST API

A blank volume, or a volume restored from a snapshot, can be created in one project and region. `source` selects which body the call sends.

> [!NOTE]
>
> An [API token](https://docs.gcore.com/account-settings/api-tokens.md) is required, along with a [project ID](https://docs.gcore.com/api-reference/cloud/projects/list-projects.md) and a [region ID](https://docs.gcore.com/api-reference/cloud/regions/list-regions.md).

Open a bash terminal and set these as environment variables before running the examples:

```bash theme={null}
export GCORE_API_KEY="{YOUR_API_KEY}"
export GCORE_CLOUD_PROJECT_ID="{YOUR_PROJECT_ID}"
export GCORE_CLOUD_REGION_ID="{YOUR_REGION_ID}"
export SNAPSHOT_ID="{SNAPSHOT_ID}"
```

`SNAPSHOT_ID` is the UUID of an existing snapshot in the same region. The snapshot example reads it. The blank-volume example does not.

## Create a volume

A [volume](https://docs.gcore.com/api-reference/cloud/volumes/create-volume.md) is created with `source` set to `new-volume` or `snapshot`.

| Parameter | Required | Description |
| - | - | - |
| `name` | Yes | Display name. Latin letters, numbers, underscores, spaces, and dots. 3-63 characters. |
| `source` | Yes | `new-volume` for blank storage. `snapshot` to restore from a snapshot. |
| `size` | Blank volume | Size in GiB. When `source` is `snapshot`, omit `size` or set it to the snapshot size. |
| `snapshot_id` | Snapshot | UUID of a snapshot in the same region. |
| `type_name` | No | `standard` by default. Also `ssd_hiiops`, `ssd_lowlatency`, `cold`, or `ultra`. Available types vary by region. `ssd_local` cannot be created as a standalone volume. When `source` is `snapshot` and `type_name` is omitted, the type comes from the snapshot volume. |

> [tab] Blank volume
>
> A blank volume sets `source` to `new-volume` and passes `size`.
>
> > [tab] Python SDK
> >
> > ```python theme={null}
> > from gcore import Gcore
> >
> > client = Gcore()
> > volume = client.cloud.volumes.create_and_poll(
> >     name="data-volume",
> >     source="new-volume",
> >     size=10,
> >     type_name="standard",
> > )
> > print(f"Volume: {volume.id}")
> > ```
>
> > [tab] Go SDK
> >
> > ```go theme={null}
> > package main
> >
> > import (
> >     "context"
> >     "fmt"
> >     "log"
> >
> >     gcore "github.com/G-Core/gcore-go"
> >     "github.com/G-Core/gcore-go/cloud"
> > )
> >
> > func main() {
> >     client := gcore.NewClient()
> >     ctx := context.Background()
> >
> >     volume, err := client.Cloud.Volumes.NewAndPoll(ctx, cloud.VolumeNewParams{
> >         OfNewVolume: &cloud.VolumeNewParamsBodyNewVolume{
> >             Name:     "data-volume",
> >             Size:     10,
> >             TypeName: "standard",
> >         },
> >     })
> >     if err != nil {
> >         log.Fatalf("create volume: %v", err)
> >     }
> >     fmt.Printf("Volume: %s\n", volume.ID)
> > }
> > ```
>
> > [tab] curl
> >
> > ```bash theme={null}
> > curl -X POST "https://api.gcore.com/cloud/v1/volumes/$GCORE_CLOUD_PROJECT_ID/$GCORE_CLOUD_REGION_ID" \
> >   -H "Authorization: APIKey $GCORE_API_KEY" \
> >   -H "Content-Type: application/json" \
> >   -d '{
> >     "name": "data-volume",
> >     "source": "new-volume",
> >     "size": 10,
> >     "type_name": "standard"
> >   }'
> > ```
> >
> > The response is a task ID. Poll `GET /cloud/v1/tasks/` every 5 seconds until `state` is `FINISHED`. The volume ID is in `created_resources.volumes`.

> [tab] From a snapshot
>
> A restored volume sets `source` to `snapshot` and passes `snapshot_id`. `name` is also required.
>
> > [tab] Python SDK
> >
> > ```python theme={null}
> > import os
> >
> > from gcore import Gcore
> >
> > client = Gcore()
> > volume = client.cloud.volumes.create_and_poll(
> >     name="volume-from-snapshot",
> >     source="snapshot",
> >     snapshot_id=os.environ["SNAPSHOT_ID"],
> > )
> > print(f"Volume: {volume.id}")
> > ```
>
> > [tab] Go SDK
> >
> > ```go theme={null}
> > package main
> >
> > import (
> >     "context"
> >     "fmt"
> >     "log"
> >     "os"
> >
> >     gcore "github.com/G-Core/gcore-go"
> >     "github.com/G-Core/gcore-go/cloud"
> > )
> >
> > func main() {
> >     client := gcore.NewClient()
> >     ctx := context.Background()
> >
> >     volume, err := client.Cloud.Volumes.NewAndPoll(ctx, cloud.VolumeNewParams{
> >         OfSnapshot: &cloud.VolumeNewParamsBodySnapshot{
> >             Name:       "volume-from-snapshot",
> >             SnapshotID: os.Getenv("SNAPSHOT_ID"),
> >         },
> >     })
> >     if err != nil {
> >         log.Fatalf("create volume: %v", err)
> >     }
> >     fmt.Printf("Volume: %s\n", volume.ID)
> > }
> > ```
>
> > [tab] curl
> >
> > ```bash theme={null}
> > curl -X POST "https://api.gcore.com/cloud/v1/volumes/$GCORE_CLOUD_PROJECT_ID/$GCORE_CLOUD_REGION_ID" \
> >   -H "Authorization: APIKey $GCORE_API_KEY" \
> >   -H "Content-Type: application/json" \
> >   -d "{
> >     \"name\": \"volume-from-snapshot\",
> >     \"source\": \"snapshot\",
> >     \"snapshot_id\": \"$SNAPSHOT_ID\"
> >   }"
> > ```
> >
> > The response is a task ID. Poll `GET /cloud/v1/tasks/` every 5 seconds until `state` is `FINISHED`. The volume ID is in `created_resources.volumes`.

The SDK methods poll automatically and return the created volume. Read the ID from `volume.id`.

An existing volume can be attached, resized, detached, or deleted in [Manage a volume](https://docs.gcore.com/cloud/virtual-instances/volumes/manage-a-volume.md).

## Terraform

A boot volume can be created from an OS image, a blank data disk from empty storage, or a volume from a snapshot. The full attribute reference is on the [`gcore_cloud_volume`](https://registry.terraform.io/providers/G-Core/gcore/latest/docs/resources/cloud_volume) resource page.

## Create a volume

The most common use case is `source = "image"`. This creates a boot volume from an OS image and is required when provisioning a Virtual Machine. Use `"new-volume"` for a blank data volume, or `"snapshot"` to restore from an existing snapshot.

For a boot volume, pass the image UUID via a variable. To find the UUID, open the Gcore Customer Portal, navigate to **Cloud** > **Images**, and copy the ID from the image details. IDs are region-specific. Use the ID from the region where the volume is created.

```hcl theme={null}
variable "image_id" {
  type        = string
  description = "OS image UUID (region-specific). Find it in Cloud > Images."
}

resource "gcore_cloud_volume" "boot" {
  project_id = var.project_id
  region_id  = var.region_id
  name       = "boot-volume"
  source     = "image"
  image_id   = var.image_id
  size       = 20
  type_name  = "standard"
}

output "boot_volume_id" {
  value = gcore_cloud_volume.boot.id
}
```

For a blank data volume:

```hcl theme={null}
resource "gcore_cloud_volume" "example" {
  project_id = var.project_id
  region_id  = var.region_id
  name       = "data-volume"
  source     = "new-volume"
  size       = 10
  type_name  = "standard"
}

output "volume_id" {
  value = gcore_cloud_volume.example.id
}
```

For a volume restored from a snapshot, set `source` to `"snapshot"` and pass `snapshot_id`. Leave `size` unset, or set it to the snapshot size. When `type_name` is omitted, the type comes from the snapshot volume.

```hcl theme={null}
variable "snapshot_id" {
  type        = string
  description = "Snapshot UUID in the same region as the volume."
}

resource "gcore_cloud_volume" "from_snapshot" {
  project_id  = var.project_id
  region_id   = var.region_id
  name        = "volume-from-snapshot"
  source      = "snapshot"
  snapshot_id = var.snapshot_id
}

output "snapshot_volume_id" {
  value = gcore_cloud_volume.from_snapshot.id
}
```

An existing volume can be attached, resized, retyped, deleted, or imported in [Manage a volume](https://docs.gcore.com/cloud/virtual-instances/volumes/manage-a-volume.md).
