Create a customized boot disk


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, don't use regional Persistent Disks for boot disks. In a failover situation, they don't force-attach to a VM.

Before you begin

  • When creating VMs from images or disks by using the Google Cloud CLI or REST, 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.
  • If you haven't already, set up authentication. Authentication is the process by which your identity is verified for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine as follows.

    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

    1. Install the Google Cloud CLI, then initialize it by running the following command:

      gcloud init
    2. Set a default region and zone.

    REST

    To 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, then initialize it by running the following command:

      gcloud init

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

REST

To create a new boot Persistent Disk using REST, 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

REST

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.