You can create customized Windows Server images from your existing Windows Server instances. Use these custom images to create instances with the same boot disk images as your existing instances.
These custom images are useful for saving configuration settings for the operating system on your existing instances and reusing the same configuration to create other instances.
If you need to create an instance from a public image or a custom image, read Creating a New Windows Instance.
To make scheduled backups of your persistent disk data, use persistent disk snapshots instead of custom images.
If you need to import Windows Server or SQL Server systems, use the VM Migration Service.
Creating a Windows Server image
Before you create the image, run GCESysprep on the instance to prepare it
for the image creation process. This process stops the instance. If you cannot
stop your instance, you can skip the GCESysprep process and create the image
while risking the integrity of the image.
- Log in to your Windows instance and open PowerShell or Command Prompt as an administrator.
Use
GCESysprepto prepare your system for duplication. This command shuts down the instance and closes the remote desktop connection.GCESysprep
After you prepare your instance, create the image.
Console
- Go to the Create a new image page in the GCP Console.
- Specify a name for the image.
- Choose a source disk with a Windows operating system from which you want to create an image.
- If the source disk is connected to a running instance, click Keep instance running to create the image anyway. This option might compromise the integrity of your image. Stop the instance before you create the image if possible.
- Click Create.
gcloud
Use the gcloud compute with the
images create, and provide
the source persistent disk from which you want to create an image.
Optionally, include the --force flag to create the image even if it is
attached to a running instance.
gcloud compute images create example-image --source-disk [DISK_NAME] \
--source-disk-zone [ZONE] [--force]
[DISK_NAME]is the name of the source disk to create the image from.[ZONE]is the zone of the disk.--forceis an optional flag that creates the image even if the disk is attached to an instance that is still running. This option might compromise the integrity of your image. Stop the instance before you create the image if possible.
When you run this command, gcloud compute creates a new image based on
the persistent disk you provided and adds it to your collection. You can
confirm that your image was successfully created by running:
gcloud compute images list
API
Make a POST request to the images().insert
method, with a sourceDisk URL in the request body.
POST https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/global/images?[FORCE_OPTION]
{
"name": "[IMAGE_NAME]",
"sourceDisk": "zones/[ZONE]/disks/[DISK_NAME]"
}
where:
[PROJECT_ID]is the project ID for this request.[FORCE_OPTION]is an option to create the image even if the source disk is attached to a running instance. SpecifyforceCreate=trueat the end of your POST line to set this option. This option might compromise the integrity of your image. Stop the instance before you create the image if possible.[IMAGE_NAME]is the name to give this image.[ZONE]is the zone of the source disk to create an image from.[DISK_NAME]is the name of the source disk.
For more information about adding images, see the images reference.
Updating Windows agents and scripts
Compute Engine occasionally releases new Windows images with the latest agents and scripts. These items assist Windows instances with startup and shutdown processes, account management, and address management.
Since Windows image version v20160112, the Windows agent updates itself with
upstream releases. You can disable these agent updates by setting the
disable-agent-updates instance metadata key to true. If you have instances
that are based on older image releases, you can
manually update the Windows agent of those instances.


