Create a customized boot disk

Stay organized with collections Save and categorize content based on your preferences.

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.

Use the procedures described in this document to create boot disks that you can use later to create VMs. To improve the performance of a boot disk or to add space for additional applications or operating system files, you can resize the boot 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

  • If you want to use the command-line examples in this guide, do the following:
    1. Install or update to the latest version of the Google Cloud CLI.
    2. Set a default region and zone.
  • If you want to use the API examples in this guide, set up API access.
  • When creating VMs from images or disks by using the Google Cloud CLI or the Compute Engine API, there's a limit of 20 VM instances per second. If you need to create a higher number of VMs per second, request a higher quota limit for the Images resource.

Create a 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 Disk 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 Disk 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

  • The process for resizing a boot persistent disk and a non-boot persistent disk is the same. For more information, see Resize a persistent disk.