Creating customized boot disks

When you create a virtual machine (VM) instance, you must also create a boot disk for the VM. You can use 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.

Before you begin

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

  1. In the Google Cloud Console, go to the Create a disk page.

    Go to the Create a disk page

  2. Under Source type, select Image. Choose an image from the list.
  3. Click Create.

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

Replace IMAGE with 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

  1. In the Google Cloud Console, go to the Create a disk page.

    Go to the Create a disk page

  2. Under Source type, select Snapshot.
  3. Choose a snapshot from the list.
  4. Finish setting the properties for your disk and click Create.

gcloud

To apply data from a persistent disk snapshot, run the following command:

gcloud compute disks create example-disk --source-snapshot example-snapshot

API

To create a 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

Bu sayfayı yararlı buldunuz mu? Lütfen görüşünüzü bildirin:

Şunun hakkında geri bildirim gönderin...

Compute Engine Documentation