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
|Scenarios||Machine image||Persistent disk snapshot||Custom image||Instance template|
|Single disk backup||Yes||Yes||Yes||No|
|Multiple disk backup||Yes||No||No||No|
|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.
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:
VM instance configuration. Each VM configuration includes the following properties:
The volume mapping used to create persistent disks and local SSDs for the source instance.
Data stored on persistent disks at consistent points in time across disks.
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,
Cloud Storage dual-region,
asia1, or a
Cloud Storage region,
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
australia-southeast1 is outside of a multi-region. The closest
Regardless of where the machine image is stored, you can still access the machine image globally by setting the proper permissions.
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:
gcloud compute machine-images describecommand to find the storage size in bytes.
gcloud compute machine-images describe MACHINE_IMAGE_NAME
MACHINE_IMAGE_NAMEwith the name of the machine image.
Scroll to the end of the output, review the value stored in the
totalStorageBytesfield. This value is in bytes, convert this value to GigaBytes(GB) because storage cost is calculated per GB.
....... storageLocations: - us totalStorageBytes: '58688064'
Use the pricing table to find the cost per GB for your region. See Machine image pricing.