When you create an instance, you must also create a boot disk for the instance from a public image, a custom image, or a snapshot that was taken from another boot disk. When you create a boot disk, limit the disk size to 2 TB to account for the limitations of MBR partitioning.
Compute Engine automatically creates a boot persistent disk when you create an instance. If you require additional data storage space for your instances, add one or more secondary instance storage options.
You might need to create a standalone boot persistent disk and attach it to an instance later, or resize a boot persistent disk to improve performance and add more space for additional applications or operating system files. That process is described in Add or resize a persistent disk.
As a best practice, do not use regional persistent disks for boot disks. In a failover situation, they do not force-attach to a VM instance.
Before you begin
- If you want to use the command-line examples in this guide:
- Install or update to the latest version of the gcloud command-line tool.
- Set a default region and zone.
- If you want to use the API examples in this guide, set up API access.
Creating a standalone boot persistent disk from an image
You can create a standalone boot persistent disk outside of instance creation and attach it to an instance afterwards.
Console
- Go to the Create a new disk page.
- Under Source type, select Image. Choose an image from the list.
- Create your disk.
gcloud
To create a standalone boot persistent disk, use the
gcloud compute disks create
command:
gcloud compute disks create example-disk --image example-image
API
To create a new boot persistent disk using the API, use the following URI:
https://compute.googleapis.com/compute/v1/projects/example-project/zones/us-central1-f/disks?sourceImage=IMAGE
Where IMAGE
is the URL-encoded, fully-qualified URI of the source image
to apply to this persistent disk.
The request body must contain a name for this new persistent disk:
{
"name": "example-disk"
}
If you created a boot persistent disk that is larger than the image, you might need to repartition the boot persistent disk.
Create a boot persistent disk from a snapshot
After you create a snapshot of a boot persistent disk, you can apply data from that snapshot to new persistent disks. It is only possible to apply data from a snapshot when you first create a persistent disk. You cannot apply a snapshot to an existing persistent disk, or apply a snapshot to persistent disks that belong to a different project than that snapshot.
Console
- Go to the Create a new disk page.
- Under Source type, select Snapshot.
- Choose a snapshot from the list.
- Finish setting the properties for your disk and create it.
gcloud
To apply data from persistent disk snapshot, run the following command:
gcloud compute disks create example-disk --source-snapshot example-snapshot
API
To create a new boot persistent disk with a snapshot, make a POST
request
to the following URI:
POST https://compute.googleapis.com/compute/v1/projects/example-project/zones/us-central1-f/disks
The request body must contain a name for this new persistent disk and the URL to the snapshot to use:
{
"name": "example-disk",
"sourceSnapshot": "zones/us-central1-f/snapshots/example-snapshot"
}
What's next
- The process for resizing a boot persistent disk, and a non-boot persistent disk is the same. You can find that content in: Add or resize a persistent disk.