Add disks from a storage pool to VMs


You can create disks in a Hyperdisk Storage Pool and then attach the disk to a virtual machine (VM) instance, or you can create disks in the storage pool when creating a VM.

Provisioning disk capacity

If you create an Advanced capacity storage pool, you can use thin provisioning. You can create disks in the storage pool with a cumulative size that exceeds the provisioned capacity of the pool. The used capacity of the storage pool is defined by the total data in use and not by the amount of disk space that you've provisioned. You can provision disks with an aggregate capacity of up to 500% of the provisioned capacity of an Advanced capacity storage pool.

If you are creating disks in a Standard capacity storage pool, then you create disks in the storage pool until the total size of all disks in the storage pool reaches the storage pool's provisioned capacity. The disks in a storage pool with Standard capacity behave similarly to non-pool disks, where capacity is consumed when you create the disks.

Provisioning disk IOPS

When creating disks in a storage pool, the IOPS that you provision for a disk must be less than the available IOPS in the Hyperdisk Storage Pool. The available IOPS is the provisioned IOPS for the storage pool minus the used IOPS for all the disks created in the storage pool.

Provisioning disk throughput

When creating disks in a storage pool, the throughput that you provision for a disk must be less than the available throughput in the Hyperdisk Storage Pool. The available throughput is the provisioned throughput for the storage pool minus the used throughput for all disks created in the storage pool.

If any of the conditions in the previous paragraph are not true, then the request to create a disk in the storage pool fails and the disk is not created.

Before you begin

  • If you haven't already, set up authentication. Authentication is the process by which your identity is verified for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine as follows.

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    gcloud

    1. Install the Google Cloud CLI, then initialize it by running the following command:

      gcloud init
    2. Set a default region and zone.

    REST

    To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.

      Install the Google Cloud CLI, then initialize it by running the following command:

      gcloud init

Required roles and permissions

To get the permissions that you need to create a Hyperdisk Balanced or Hyperdisk Throughput disk in a storage pool, ask your administrator to grant you the following IAM roles on the project:

  • Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1)
  • To connect to a VM instance that can run as a service account: Service Account User (v1) (roles/iam.serviceAccountUser role)

For more information about granting roles, see Manage access.

These predefined roles contain the permissions required to create a Hyperdisk Balanced or Hyperdisk Throughput disk in a storage pool. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

The following permissions are required to create a Hyperdisk Balanced or Hyperdisk Throughput disk in a storage pool:

  • To create disks in a storage pool and attach the disks to a VM instance:
    • compute.disks.create on the project
    • compute.instances.attachDisk on the VM
    • compute.disks.use on the volume that you want to attach to the VM
    • compute.storagePools.use on the storage pool you are creating disks in
  • To format and mount the attached volume: compute.instances.setMetadata on the VM

You might also be able to get these permissions with custom roles or other predefined roles.

For the permissions needed to create an instance, see Required permissions.

Limitations

Review the following limitations for creating disks in a Hyperdisk Storage Pool:

  • You can create only Hyperdisk Balanced disks in a Hyperdisk Balanced Storage Pool and you can create only Hyperdisk Throughput disks in a Hyperdisk Throughput Storage Pool.
  • Only new disks in the same project and zone can be created in a storage pool.
  • To create boot disks in a storage pool, you must use a Hyperdisk Balanced Storage Pool.
  • Moving disks in or out of a storage pool is not permitted. To move a disk in or out of a storage pool, you have to recreate the disk from a snapshot. For more information, see Change the disk type.
  • You can create up to 1,000 disks in a storage pool.
  • You can't create regional disks in a storage pool.

Create disks in the storage pool

You can use the Google Cloud console, Google Cloud CLI, or REST to create a disk in a storage pool.

Console

Using the Google Cloud console, you can create a new disk in a storage pool either through the Storage pools page or the Disks page.

On the Storage pools page:

  1. In the Google Cloud console, go to the Storage pools page.

    Go to the Storage pools page

  2. Click the name of the storage pool that you would like to create a disk in.

  3. On the Manage storage pool page, click +Create New Disk.

  4. In the Add new disk panel, enter a Name for the disk.

  5. Specify or change any values for which you don't want to use the default value.

  6. When finished specifying the disk properties, click Save.

  7. On the Manage storage pool page, you should see the new disk listed in the Storage pool disks section.

On the Create Disk page:

  1. In the Google Cloud console, go to Disks > Create a disk page.

    Go to the Create a disk page

  2. Enter a Name for the disk.

  3. Select the zone that contains the storage pool you want to create the disk in.

  4. For the Disk type, choose the disk type that matches the Hyperdisk Storage Pool, either Hyperdisk Throughput or Hyperdisk Balanced.

  5. Modify the values in the Size, Provisioned IOPS, and Provisioned Throughput fields, as necessary.

  6. In the Storage pool section, select Enable storage pool, then choose the name of the storage pool to create the disk in. Only storage pool that exist in the selected zone appear in the list.

  7. When finished specifying the disk information, click Create.

gcloud

To create one or more disks in a storage pool, use the gcloud compute disks create command.

gcloud compute disks create DISK_NAME \
    --zone=ZONE \
    --storage-pool=STORAGE_POOL_NAME \
    --size=SIZE \
    --type=DISK_TYPE \
    --provisioned-iops=PROVISIONED_IOPS \
    --provisioned-throughput=PROVISIONED_THROUGHPUT

Replace the following:

  • DISK_NAME: a unique name for the disk. You can provide a list of disk names specified by spaces to create multiple disks with the same attributes.
  • ZONE: the zone where the storage pool was created. Specify this value in region-zone format, for example us-central1-a.
  • STORAGE_POOL_NAME: the name of the storage pool to create the disk in
  • SIZE: Optional: the provisioned capacity of the new disk. The value must be a whole number followed by a size unit of GB for gibibyte, or TB for tebibyte. If no size is specified, 100 GB is used as the default value.
  • DISK_TYPE: the type of disk to create. This must match the type of the Hyperdisk Storage Pool, either hyperdisk-balanced or hyperdisk-throughput.
  • PROVISIONED_IOPS: Optional: the IOPS to provision for the disk. You can use this flag only with Hyperdisk Balanced disks.
  • PROVISIONED_THROUGHPUT: Optional: the throughput in mebibyte (MB) per second to provision for the disk.

REST

To create one or more disks in a storage pool, construct a POST using the disks.insert method. Include the name, sizeGb, type, storagePool, provisionedIops, and provisionedThroughput properties. To create this disk as an empty and unformatted non-boot disk, don't specify a source image or a source snapshot.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/disks

{
    "name": "DISK_NAME",
    "description": "DESCRIPTION",
    "type": "https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/diskTypes/DISK_TYPE",
    "sizeGb": "DISK_SIZE",
    "storagePool": "STORAGE_POOL_NAME",
    "provisionedIops": "IOPS_LIMIT",
    "provisionedThroughput": "THROUGHPUT_LIMIT",
}

Replace the following:

  • PROJECT_ID: the project ID
  • ZONE: the zone in which the storage pool is located, for example, us-central1-a. This is the zone that the disk will be created in.
  • DISK_NAME: a unique name for the disk.
  • DESCRIPTION: Optional: a text string that describes the disk.
  • DISK_TYPE: the type of disk, which must match the storage pool type. Use either hyperdisk-throughput or hyperdisk-balanced.
  • DISK_SIZE: Optional: The size of the new disk. The value must be a whole number followed by a size unit of GB for gibibytes or TB for tebibytes. If no size is specified, 100 GB is used as the default value.
  • STORAGE_POOL_NAME: the name of the storage pool to create the disk in.
  • IOPS_LIMIT: Optional: the IOPS to provision for the disk. You can use this flag only with Hyperdisk Balanced disks.
  • THROUGHPUT_LIMIT: Optional: The throughput in mebibytes (MB) per second to provision for the disk.

Aftering creating the disk, you can attach the disk to a VM.

Create a VM that uses disks in the storage pool

When creating a VM, you configure a boot disk, and you can optionally create additional data (non-boot) disks, which are automatically attached to the VM. The following sections explain how to create each type of disk in a storage pool as part of the VM creation process.

Create the boot disk for a VM in a storage pool

To create a VM that uses a boot disk in a storage pool, you must first create a Hyperdisk Balanced Storage Pool. You can then create a VM that supports Hyperdisk Balanced disks. The machine type, disk type, and storage pool must all be available in the zone that you choose.

Console

  1. In the Google Cloud console, go to the VM Instances page.

    Go to VM instances

  2. Click Create Instance.

  3. Enter a name for the instance.

  4. Set the zone to the same zone where the storage pool is located.

  5. Choose a machine type that supports Hyperdisk Balanced, for example H3.

  6. In the Boot disk section, click Change.

  7. In the Boot disk panel, set the Boot disk type to Hyperdisk Balanced.

  8. Configure the properties for the disk.

  9. Expand Show advanced configuration.

  10. Under the heading Storage pool, select Enable storage pool.

  11. Choose the storage pool to create the disk in from the list.

  12. When finished with the disk configuration, click Select.

  13. Finish configuring the VM properties.

  14. Click Create.

    The console creates the VM in the specified zone, and creates the boot disk in the selected storage pool.

gcloud

You can create the boot disk for a new VM in the storage pool using the gcloud compute instances create command and including the storage-pool property for the boot disk.

gcloud compute instances create VM_NAME \
    --zone=ZONE \
    --machine-type=MACHINE_TYPE \
    --create-disk=boot=yes,type=hyperdisk-balanced,size=DISK_SIZE,provisioned-throughput=THROUGHPUT, \
    provisioned-iops=IOPS,image=projects/IMAGE_PROJECT/global/images/IMAGE, \
    storage-pool=STORAGE_POOL_NAME

Replace the following:

  • VM_NAME: the name of the VM.
  • ZONE: the region and zone to create the VM in, using the format us-central1-a.
  • MACHINE_TYPE: the machine type of the VM, for example, m3-ultramem-32.
  • DISK_SIZE: the size, in GiB, of the boot disk
  • THROUGHPUT: the throughput to provision for the disk
  • IOPS: the IOPS to provision for the disk
  • IMAGE_PROJECT: the project that contains the image
  • IMAGE or IMAGE_FAMILY: specify one of the following:

    • IMAGE: a specific version of a public image. For example, debian-12-bookworm-v20240213
    • IMAGE_FAMILY: an image family. This creates the VM from the most recent, non-deprecated OS image.

    For example, if you specify "sourceImage": "projects/debian-cloud/global/images/family/debian-12", Compute Engine creates a VM using the latest version of the OS image in the debian-12 image family.

  • STORAGE_POOL_NAME: the name of the storage pool to create the new disk in.

REST

You can create the boot disk for a new VM in the storage pool by constructing a POST request for the instances.insert method and including the storagePool property for the boot disk.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances

{
   "name": "VM_NAME",
   "machineType": "zones/ZONE/machineTypes/MACHINE_TYPE",
   "disks": [
      {
         "deviceName": "BOOT_DISK_DEVICE_NAME",
         "initializeParams": {
            "diskSizeGb": "DISK_SIZE",
            "diskType": "DISK_TYPE",
            "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"
            "boot": true,
            "provisionedIops": "IOPS_LIMIT",
            "provisionedThroughput": "THROUGHPUT_LIMIT",
            "storagePool": "POOL_URL"
         }
      }
   ]
}

Replace the following:

  • PROJECT_ID: the project ID
  • ZONE: the zone in which the storage pool is located, for example, us-central1-a. This is the zone that VM and boot disk are created in.
  • VM_NAME: the name of the VM.
  • MACHINE_TYPE: the machine type of the VM, for example, m3-ultramem-32.
  • BOOT_DISK_DEVICE_NAME: the device name for the boot disk
  • DISK_SIZE: the size, in GiB, of the boot disk
  • DISK_TYPE: the disk type, specified as a URI
  • IMAGE_PROJECT: the project that contains the image
  • IMAGE or IMAGE_FAMILY: specify one of the following:

    • IMAGE: a specific version of a public image, for example, debian-12-bookworm-v20240213
    • IMAGE_FAMILY: an image family

    This creates the VM from the most recent, non-deprecated OS image. For example, if you specify "sourceImage": "projects/debian-cloud/global/images/family/debian-12", Compute Engine creates a VM using the latest version of the OS image in the debian-12 image family.

  • IOPS_LIMIT: the IOPS to provision for the disk

  • THROUGHPUT_LIMIT: the throughput to provision for the disk

  • POOL_URL: the storage pool in which the new disk is created. You can provide this as a partial or full URL to the resource. For example, the following are valid values:

    • https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/storagePools/STORAGE_POOL_NAME
    • projects/PROJECT_ID/zones/ZONE/storagePools/STORAGE_POOL_NAME
    • zones/ZONE/storagePools/STORAGE_POOL_NAME

Create additional disks in a storage pool during VM creation

When creating disks in a storage pool during VM creation, the machine type, disk type, and storage pool must be available in the zone that you choose.

Console

Use the following steps to use the console to create a new VM with additional, non-boot disks:

  1. In the Google Cloud console, go to the VM Instances page.

    Go to VM instances

  2. Click Create Instance.

  3. Enter a name for the instance.

  4. Set the zone to the same zone where the storage pool is located.

  5. Choose a machine type that supports disk type used by the storage pool.

  6. Expand the Advanced options section.

  7. Expand Disks.

  8. Click + Add new disk.

  9. In the Add new disk panel, enter the information for the disk. Set the Disk type to the match the storage pool type.

  10. Under Storage Pool, select Enable storage pool.

  11. In the Select a storage pool field, select the storage pool to create the disk in from the list.

  12. When finished with the disk configuration, click Save.

  13. Finish configuring the VM properties.

  14. Click Create.

    The console creates the VM in the specified zone, and creates the non-boot disk in the selected storage pool.

gcloud

You can create new disks in a storage pool during VM creation by using the gcloud compute instances create command and including the storage-pool property for the disk.

gcloud compute instances create VM_NAME \
    --zone=ZONE \
    --machine-type=MACHINE_TYPE \
    --create-disk=auto-delete=yes,boot=yes,device-name=BOOT_DISK_DEVICE_NAME,image=IMAGE_NAME, \
    size=BOOT_DISK_SIZE,type=BOOT_DISK_TYPE
    --create-disk=auto-delete=yes,boot=no,device-name=DATA_DISK_DEVICE_NAME,size=DATA_DISK_SIZE, \
    type=DATA_DISK_TYPE,provisioned-iops=IOPS,provisioned-throughput=THROUGHPUT, \
    storage_pool=STORAGE_POOL_NAME

Replace the following:

  • VM_NAME: the name of the VM.
  • ZONE: the region and zone to creat the VM in, using the format us-central1-a
  • MACHINE_TYPE: the machine type of the VM
  • BOOT_DISK_DEVICE_NAME: the device name for the boot disk
  • IMAGE_NAME: the name of the operating system image to install on the boot disk, for example, debian-12-bookworm-v20240213
  • BOOT_DISK_SIZE: the size, in GiB, of the boot disk
  • BOOT_DISK_TYPE: the disk type
  • DATA_DISK_DEVICE_NAME: the disk device name for the data disk
  • DATA_DISK_SIZE: the size of the data disk, in GiB
  • DATA_DISK_TYPE: the data disk type, either hyperdisk-balanced or hyperdisk-throughput
  • IOPS: the IOPS to provision for the disk
  • THROUGHPUT: the throughput to provision for the disk
  • STORAGE_POOL_NAME: the unique name for the storage pool that you want to create the disk in.

REST

You can create new disks in a storage pool during VM creation by constructing a POST request for the instances.insert method and including the storagePool property for the additional disks.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances

{
   "name": "VM_NAME",
   "machineType": "zones/ZONE/machineTypes/MACHINE_TYPE",
   "disks": [
      {
        "initializeParams":{
            "sourceImage":"projects/IMAGE_PROJECT/global/images/IMAGE"
        },
        "boot":true
      },
      {
        "deviceName": "DEVICE_NAME",
        "initializeParams": {
           "diskSizeGb": "DISK_SIZE",
           "diskType": "DISK_TYPE",
           "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"
           "provisionedIops": "IOPS_LIMIT",
           "provisionedThroughput": "THROUGHPUT_LIMIT",
           "storagePool": "POOL_URL"
        }
      }
   ]
}

Replace the following:

  • PROJECT_ID: the project ID
  • ZONE: the zone in which the storage pool is located, for example, us-central1-a. This is the zone that VM and boot disk are created in.
  • VM_NAME: the name of the VM.
  • MACHINE_TYPE: the machine type of the VM, for example, m3-ultramem-32.
  • IMAGE_PROJECT: the project that contains the image
  • IMAGE or IMAGE_FAMILY: specify one of the following:

    • IMAGE: a specific version of a public image, for example, debian-12-bookworm-v20240213
    • IMAGE_FAMILY: an image family

    This creates the VM from the most recent, non-deprecated OS image. For example, if you specify "sourceImage": "projects/debian-cloud/global/images/family/debian-12", Compute Engine creates a VM using the latest version of the OS image in the debian-12 image family.

  • DEVICE_NAME: the device name for the data disk

  • DISK_SIZE: the size, in GiB, of the data disk

  • DISK_TYPE: the disk type, specified as a URI

  • IOPS_LIMIT: the IOPS to provision for the disk

  • THROUGHPUT_LIMIT: the throughput to provision for the disk

  • POOL_URL: the storage pool in which the new disk is created. You can provide this as a partial or full URL to the resource. For example, the following are valid values:

    • https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/storagePools/STORAGE_POOL_NAME
    • projects/PROJECT_ID/zones/ZONE/storagePools/STORAGE_POOL_NAME
    • zones/ZONE/storagePools/STORAGE_POOL_NAME

Use storage pool in an instance template

The instance templates used to create managed instance groups (MIGs) can contain the storage pool information. The disks created using the instance template are placed in the specified storage pool.

Console

  1. In the Google Cloud console, go to the Instance templates page.

    Go to Instance templates

  2. Click Create Instance Template.

  3. Enter a name for the instance template.

  4. Choose Regional for the location, and in the Region field, choose the region where the storage pool is located.

  5. Choose a machine type that supports Hyperdisk Balanced, for example C3.

  6. In the Boot disk section, click Change.

  7. In the Boot disk panel, set the Boot disk type to Hyperdisk Balanced.

  8. Configure the properties for the disk.

  9. Expand Show advanced configuration.

  10. Under the heading Storage pool, select Enable storage pool.

  11. Choose the storage pool to create the disk in from the list.

  12. When finished with the disk configuration, click Select.

  13. Finish configuring the VM properties.

  14. Click Create.

    The template creates the VM in the specified zone, and creates the boot disk in the selected storage pool.

gcloud

You can specify in an instance template that the book disk be created in a storage pool by using the gcloud compute instance-templates create command and including the storage-pool property for the boot disk.

gcloud compute instance-templates create TEMPLATE_NAME \
    --instance-template-region=REGION \
    --machine-type=MACHINE_TYPE \
    --create-disk=boot=yes,type=hyperdisk-balanced,size=DISK_SIZE,provisioned-throughput=THROUGHPUT, \
    provisioned-iops=IOPS,image=projects/IMAGE_PROJECT/global/images/IMAGE, \
    storage-pool=STORAGE_POOL_NAME

Replace the following:

  • TEMPLATE_NAME: the name of the instance template.
  • REGION: the region where you want to create the regional instance template. The region must contain the zone where the storage pool is located.
  • MACHINE_TYPE: the machine type to use when creating the VM, for example, h3-standard-88.
  • DISK_SIZE: the size, in GiB, of the disk
  • THROUGHPUT: the throughput to provision for the disk
  • IOPS: the IOPS to provision for the disk
  • IMAGE_PROJECT: the project that contains the image
  • IMAGE or IMAGE_FAMILY: specify one of the following:

    • IMAGE: a specific version of a public image. For example, debian-12-bookworm-v20240213
    • IMAGE_FAMILY: an image family. This creates the VM from the most recent, non-deprecated OS image.

    For example, if you specify "sourceImage": "projects/debian-cloud/global/images/family/debian-12", Compute Engine creates a VM using the latest version of the OS image in the debian-12 image family.

  • STORAGE_POOL_NAME: the name of the storage pool to create the new disk in.