Machine images

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

This page describes what a machine image is, when to use it, and how it compares to other resources that store data such as snapshots or custom images. For information about creating a machine image, see Creating machine images.

A machine image is a Compute Engine resource that stores all the configuration, metadata, permissions, and data from multiple disks of a virtual machine (VM) instance. You can use a machine image in many system maintenance, backup and recovery, and instance cloning scenarios.

When to use a machine image

The following table compares the use of machine images, persistent disk snapshots, instance templates, and custom images.

Scenarios Machine image Persistent disk snapshot Custom image Instance template
Single disk backup Yes Yes Yes No
Multiple disk backup Yes No No No
Differential backup Yes Yes No No
Instance cloning Yes No Yes Yes
Base image for replication No No Yes No

From the preceding table, you can see that machine images are the most ideal resources for the following use cases:

Multiple Disk backups

Machine images support backups at the VM instance level. Disks are backed up as differential snapshots.

When a machine image is used to copy disks, Compute Engine guarantees that the data across disks is captured in a crash-consistent manner at a given time. Compute Engine uses globally consistent timestamps to ensure this guarantee. This consistency is critical if your VM instance is running and you want to ensure that the backup point across disks is maintained. When the backup point across disks is maintained, you can return to the same point in time across disks when you restore a machine image.

Multiple disk backup

Machine images are suitable for creating backups of all disks that are attached to a VM instance. A machine image can be used to backup multiple disks at a time. A persistent disk snapshot can only backup a single disk at a time.

Differential disk backup

Machine images store differential snapshots of your previously created machine images or snapshots. When you generate a machine image from a VM instance, the first machine image contains a full copy of all disk data. Subsequent machine images are stored as differential copies for better performance and space efficiency. This mechanism is similar to that used by persistent disk snapshots.

Instance cloning

Machine images can be used to clone instances. You can use machine image to make copies of an instance that contains most of the VM configurations of the source instance. These copies can then be used for troubleshooting, scaling VM instances, debugging, or system maintenance.

Information stored in a machine image

A machine image collects the following information from the source instance:

The following information from the source instance is not collected by a machine image:

  • Data in memory.
  • Data in local SSD. However, a machine image captures the device mapping of local SSDs.
  • Attributes that are specific to the source instance, such as the name or IP address.

Machine image storage location

To meet compliance needs, you might need to control where your data is stored. You can control where your machine image is stored geographically by specifying a storageLocation during the creation of your machine image. Machine images can be stored in a Cloud Storage multi-region, such as asia, a Cloud Storage dual-region, such as asia1, or a Cloud Storage region, such as asia-south1.

By default, when creating a machine image from an instance, the machine image is stored in either the Cloud Storage multi-region bucket that contains the source instance, or the geographically closest Cloud Storage multi-region bucket to the source instance.

For example, if your source instance is stored in us-central1 your machine image is stored in the us multi-region by default. However, a default location like australia-southeast1 is outside of a multi-region. The closest multi-region is asia.

Regardless of where the machine image is stored, you can still access the machine image globally by setting the proper permissions.

Pricing

The cost of using a machine image depends on the size of the machine image, and the location where it is stored.

To determine the cost of your machine image, complete the following steps:

  1. Use the gcloud compute machine-images describe command to find the storage size in bytes.

    gcloud compute machine-images describe MACHINE_IMAGE_NAME
    

    Replace MACHINE_IMAGE_NAME with the name of the machine image.

  2. Scroll to the end of the output, review the value stored in the totalStorageBytes field. This value is in bytes, convert this value to GigaBytes(GB) because storage cost is calculated per GB.

    .......
    storageLocations:
    - us
    totalStorageBytes: '58688064'
  3. Use the pricing table to find the cost per GB for your region. See Machine image pricing.

What's next