Stay organized with collections Save and categorize content based on your preferences.
Linux Windows
You can either create a blank Persistent Disk volume, or create a disk from a data source. You can use Persistent Disk as a boot disk for a virtual machine (VM) instance, or as a data disk that you attach to a VM.
This document explains how to create a blank, non-boot zonal Persistent Disk volume and attach it to your VM.
For other types of disk creation and addition, see the following:
To create a boot disk that you can later use to create a VM, see Create a customized boot disk.
To add a Google Cloud Hyperdisk disk to your VM, see Add Hyperdisk storage to a VM.
To add a disk to a VM that is part of a managed instance group (MIG), see Updating VM configuration in a MIG.
Select the tab for how you plan to use the samples on this page:
ConsoleWhen you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloudInstall the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update
.To use the Terraform samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
Install the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update
.
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
RESTTo 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.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
Create and attach a non-boot zonal disk by using the Google Cloud console, the Google Cloud CLI, or REST.
Persistent Disk type variablesThe following table lists the reference values of each Persistent Disk type. When you create a Persistent Disk volume with the Google Cloud CLI, REST, or the Cloud Client Libraries for Compute Engine, indicate the Persistent Disk type you want to create by providing its corresponding value from the table.
If you create a disk in the Google Cloud console, the default disk type is pd-balanced
. If you create a disk using the gcloud CLI or REST, the default disk type is pd-standard
.
pd-balanced
Performance (SSD) Persistent Disk pd-ssd
Standard Persistent Disk pd-standard
Extreme Persistent Disk pd-extreme
You should specify a custom device name when attaching the disk to a VM. The name you specify is used to generate a symlink for the disk in the guest OS, making identification easier.
Caution: If you add a custom device name to a disk after you attach the disk to a VM, Compute Engine temporarily detaches the disk from the VM, which might disrupt your workloads. Permissions required for this taskTo perform this task, you must have the following permissions:
compute.disks.create
on the project before you can create a new diskcompute.instances.attachDisk
on the VMcompute.disks.use
permission on the disk to attachGo to the VM instances page.
Click the name of the VM where you want to add a disk.
On the details page, click Edit.
Under Additional disks, click Add new disk.
Specify a name for the disk, configure the disk's properties, and select Blank as the Source type.
Optional: Under the heading Device name, select the option Use a custom device name. The name you enter is used to generate a symlink for the disk, which makes disk identification easier.
Click Done to complete the disk's configuration.
Click Save to apply your changes to the VM and add the new disk.
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
Use the gcloud compute disks create
command to create the zonal Persistent Disk volume.
gcloud compute disks create DISK_NAME \ --size DISK_SIZE \ --type DISK_TYPE
Replace the following:
DISK_NAME
: the name of the new disk.DISK_SIZE
: the size, in gigabytes, of the new disk. Acceptable sizes range, in 1 GB increments, from 10 GB to 65,536 GB inclusive.DISK_TYPE
: full or partial URL for the type of the Persistent Disk volume. For example, https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/diskTypes/pd-ssd
.After you create the disk, attach it to any running or stopped VM. Use the gcloud compute instances attach-disk
command:
gcloud compute instances attach-disk VM_NAME \ --disk DISK_NAME --device-name=DEVICE_NAME
Replace the following:
VM_NAME
: the name of the VM where you are adding the new zonal Persistent Disk volumeDISK_NAME
: the name of the new disk that you are attaching to the VM.DEVICE_NAME
: Optional: a name that the guest OS uses to identify the disk.Use the gcloud compute disks describe
command to see a description of your disk.
To create a disk, use the google_compute_disk
resource.
To attach the disk to a VM, use the google_compute_instance
resource.
To learn how to apply or remove a Terraform configuration, see Basic Terraform commands.
RESTConstruct a POST
request to create a zonal Persistent Disk by using the disks.insert
method. Include the name
, sizeGb
, and type
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", "sizeGb": "DISK_SIZE", "type": "DISK_TYPE" }
Replace the following:
PROJECT_ID
: your project ID.ZONE
: the zone where your VM and new disk are located.DISK_NAME
: the name of the new disk.DISK_SIZE
: the size, in gigabytes, of the new disk. Acceptable sizes range, in 1 GB increments, from 10 GB to 65,536 GB inclusive.DISK_TYPE
: full or partial URL for the type of Persistent Disk. For example, https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/diskTypes/pd-ssd
.Construct a POST request to the compute.instances.attachDisk
method, and include the URL to the zonal Persistent Disk volume that you just created:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME/attachDisk { "source": "/compute/v1/projects/PROJECT_ID/zones/ZONE/disks/DISK_NAME", "deviceName": DEVICE_NAME }
Replace the following:
PROJECT_ID
: your project IDZONE
: the zone where your VM and new disk are locatedVM_NAME
: the name of the VM where you are adding the new Persistent Disk volumeDISK_NAME
: the name of the new diskDEVICE_NAME
: Optional: a name that the guest OS uses to identify the disk.After you create the new disk and attach it to a VM, you must format and mount the disk, so that the operating system can use the available storage space.
What's nextExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This document outlines how to create a blank, non-boot zonal Persistent Disk volume and attach it to a virtual machine (VM) instance in Google Cloud."],["Authentication is required to access Google Cloud services and APIs, which can be achieved through the Google Cloud console, gcloud CLI, Terraform, or REST API, each requiring different setup steps."],["When creating a Persistent Disk, users can specify the disk's name, size (ranging from 10 GB to 65,536 GB), and type, with the option to assign a custom device name for easier identification within the guest OS."],["Attaching a created disk to a VM requires specific permissions, including `compute.disks.create`, `compute.instances.attachDisk`, and `compute.disks.use`, and can be done using the Google Cloud console, gcloud CLI, or REST API."],["After attaching a disk to a VM, it is necessary to format and mount it so that the operating system can recognize and utilize the additional storage space."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4