Create a customized boot disk


When you create a Compute Engine instance, you must also create a boot disk for the instance. 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 TiB to account for the limitations of MBR partitioning.

Compute Engine automatically creates a boot disk when you create an instance. If you require additional data storage space for your instances, add one or more secondary instance storage disks to the instance.

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 Persistent Disk or Google Cloud Hyperdisk boot disk.

As a best practice, don't use regional disks for boot disks. In a failover situation, they don't force-attach to a compute instance.

Before you begin

  • When you create virtual machines (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, then 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 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

    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

    For more information, see Authenticate for using REST in the Google Cloud authentication documentation.

Create a boot disk from an image

You can create a standalone boot 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 disk, use the gcloud compute disks create command:

gcloud compute disks create DISK_NAME --image IMAGE_NAME

REST

To create a new boot disk, make a POST request to the disks.insert method:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_NAME/zones/ZONE/disks?sourceImage=IMAGE

Replace IMAGE with the URL-encoded, fully qualified URI of the source image to apply to this boot disk.

The request body must contain a name for this new disk:

{
    "name": "DISK_NAME"
}

If you created a boot disk that is larger than the image, you might want to repartition the boot disk.

Create a boot disk from a snapshot

After you create a snapshot of a boot disk, you can use the snapshot to create new boot disks.

You can only apply data from a snapshot when you first create a disk. You can't apply a snapshot to an existing disk, or apply a snapshot to disks that belong to a different project than the 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 disk snapshot, run the following command:

gcloud compute disks create DISK_NAME --source-snapshot SNAPSHOT_NAME

REST

To create a boot disk from a snapshot, make a POST request to the disks.insert method:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_NAME/zones/ZONE/disks

The request body must contain a name for this new disk and the URL for the snapshot to use when creating the disk:

{
    "name": "DISK_NAME",
    "sourceSnapshot": "zones/ZONE/snapshots/SNAPSHOT_NAME"
}

What's next