Creating Customized Root Disks

This page shows you how to create a root disk for your instance from a public image, a custom image, or a snapshot from a root disk.

Google Compute Engine automatically creates a root 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.

However, in some situations you might need to create a standalone root persistent disk and attach it to an instance later, or resize a root persistent disk to improve performance and add more room for additional application or operating system files.

Before you begin

Creating a standalone root persistent disk from an image

You can create a standalone root persistent disk outside of instance creation and attach it to an instance afterwards.

Console

  1. Go to the Create a new disk page.

    Go to the Create a new disk page

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

gcloud

To create a standalone root persistent disk, use the gcloud compute disks create command:

gcloud compute disks create example-disk --image example-image

API

To create a new root persistent disk using the API, use the following URI:

https://www.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 root persistent disk that is larger than the image, you might need to repartition the root persistent disk.

Create a root persistent disk from a snapshot

After you create a snapshot of a root 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. Go to the Create a new disk page.

    Go to the Create a new disk page

  2. Under Source type, select Snapshot.
  3. Choose a snapshot from the list.
  4. 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 root persistent disk with a snapshot, make a POST request to the following URI:

POST https://www.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"
}

Resizing a root persistent disk

If your instances require additional storage space, you can attach a persistent disk or connect another instance storage option. However, in some situations your root persistent disk might require additional space for the operating system data.

You can resize root persistent disks even if they are attached to running instances. For example, if you have a default 10GB root persistent disk and you require 40GB of additional space or better performance for that disk, you can resize the disk to 50GB.

Console

Resize the persistent disk in the Google Cloud Platform Console:

  1. Go to the VM instances page.

    Go to the VM instances page

  2. Click the name of the root disk that you want to resize.
  3. At the top of the disk details page, click Edit.
  4. In the Size field, enter the new size for your disk.
  5. At the bottom of the disk details page, click Save to apply your changes to the disk.
  6. After you resize the disk, you must repartition the root persistent disk so that the operating system can access the additional space. Some operating systems support automatic root disk resizing, so you can simply restart the instance.

gcloud

With the gcloud tool, use the disks resize command and specify the --size flag with the desired disk size in GB.

gcloud compute disks resize example-instance --size 50

After you resize the disk, you must repartition the root persistent disk so that the operating system can access the additional space. Some operating systems support automatic root disk resizing, so you can simply restart the instance.

API

In the API, construct a POST request to the compute.disks.resize method. In the request body, specify the sizeGb parameter and set it to the desired disk size in GB.

POST https://www.googleapis.com/compute/v1/projects/myproject/zones/us-east1-d/disks/example-instance/resize

{
 "sizeGb": "50"
}

After you resize the disk, you must repartition the root persistent disk so that the operating system can access the additional space. Some operating systems support automatic root disk resizing, so you can simply restart the instance.

Repartition a root persistent disk

If you create or resize a root persistent disk or create a disk from an image or a snapshot, your virtual machine instance can automatically resize the partition to recognize the additional space after you restart the instance.

In some cases, depending on the operating system, this behavior might not be supported yet. Check to see if your instance's operating system supports automatic resizing.

Checking if your operating system supports automatic resizing

Most recent versions of Public Images support automatic partition resizing on persistent disks after a system reboot. The SLES 11 public images are the only public images that do not support this feature.

For your custom images and operating systems that are supported by external vendors and communities, you must follow partition resizing instructions provided by the respective operating system vendor.

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Compute Engine Documentation