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 compute instance, or as a data disk that you attach to an instance.
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 an instance, see Create a customized boot disk.
To add a Google Cloud Hyperdisk disk to an instance, see Add Google Cloud Hyperdisk storage to an instance.
To add a disk to an instance that is part of a managed instance group (MIG), see Apply new VM configurations in a MIG.
Before you begin
-
If you haven't already, set up authentication.
Authentication verifies your identity for access to Google Cloud services and APIs. To run
code or samples from a local development environment, you can authenticate to
Compute Engine by selecting one of the following options:
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
-
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud initIf you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
- Set a default region and zone.
Terraform
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.
-
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.