Creating a Windows image

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. Running GCESysprep stops the instance, so if you can't stop your instance, you can skip the GCESysprep process and create the image anyway, but you will risk the integrity of the image.

  1. Log in to your Windows instance and open PowerShell or Command Prompt as an administrator.
  2. Use GCESysprep to prepare your system for duplication. This command shuts down the instance and closes the remote desktop connection.

    GCESysprep
    

    GCESysprep:

    1. Configures instance_setup.ps1 to run on the first boot of the VM instance.
    2. Sets the hostname to the name of the VM instance.
    3. Runs the user-provided specialize startup script, which you can use to customize the GCESysprep script. For more information, see Running Startup Scripts.
    4. Activates Windows using a Key Management Services (KMS) server.
    5. Sets up Remote Desktop Protocol (RDP) and Windows Remote Management (WinRM) to allow remote login.
  3. Create the image.

Specifying an image location

When creating a custom image, you can specify the image's Cloud Storage location, excluding dual-region locations. By specifying the image storage location, you can meet your regulatory and compliance requirements for data locality as well as your high availability needs by ensuring redundancy across regions.

The storage location feature is optional. If you do not select a location, Compute Engine will store your image in the multi-region closest to the image source. You can create custom images from source disks, images, snapshots, or images stored in Cloud Storage. You can use these images to create new VM instances.

All of your existing images prior to this feature launch remain where they are. The only change is that you can view the image location of all your images. If you have an existing image you want to move, you must recreate it in the desired location.

Creating a Windows image

You can create disk images from the following sources:

  • A persistent disk, even while that disk is attached to an instance
  • A snapshot of a persistent disk
  • Another image in your project
  • An image that is shared from another project
  • An imported image stored in Cloud Storage

Console

  1. In the Google Cloud Platform Console, go to the Create a new image page.

    Create a new image

  2. Specify the image Name.
  3. Choose a Source disk with a Windows operating system from which you want to create an image.
  4. Specify the Location to store the image. Choose an image location from the Based on source disk location (default) drop-down menu. For example, specify us to store the image in the us multi-region, or us-central1 to store it in the us-central1 region. If you do not make a selection, Compute Engine will store the image in the multi-region closest to your image's source location.
  5. Specify the properties for your image. For example, you can specify an image family name for your image to organize this image as part of an image family.
  6. Click Create.

gcloud

Use the gcloud compute with 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. The beta tag is required for the optional --storage-location flag.

gcloud beta compute images create example-image --source-disk [DISK_NAME] \
    --source-disk-zone [ZONE] \
    --storage-location [LOCATION] \
    [--force]
  • [DISK_NAME] is the name of the source disk to create the image from.
  • [ZONE] is the zone of the disk.
  • [LOCATION] is an optional flag that allows you to designate the region or multi-region where your image is going to be stored. For example, specify us to store the image in the us multi-region, or us-central1 to store it in the us-central1 region. If you do not make a selection, Compute Engine will store the image in the multi-region closest to your image's source location.
  • --force is 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. Use the beta version of this API method to specify the storageLocations parameter.

POST https://www.googleapis.com/compute/beta/projects/[PROJECT_ID]/global/images?[FORCE_OPTION]

{
  "name": "[IMAGE_NAME]",
  "sourceDisk": "zones/[ZONE]/disks/[DISK_NAME]",
  "storageLocations": "[LOCATION]",
}

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. Specify forceCreate=true at 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.
  • [LOCATION] is an optional parameter that allows you to select the multi-region or a region storage location of your image. For example, specify us to store the image in the us multi-region, or us-central1 to store it in the us-central1 region. If you do not make a selection, Compute Engine will store the image in the multi-region closest to your image's source location.

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.

What's next

Trang này có hữu ích không? Hãy cho chúng tôi biết đánh giá của bạn:

Gửi phản hồi về...

Compute Engine Documentation