Manage licenses

Linux Windows

This document explains how to manage licenses associated with a Compute Engineinstance. This includes how to append, remove, replace, and view the history oflicense updates. For more information about licenses on Compute EngineseeAbout licenses.

Restrictions for changing licenses

Only certain OS licenses are eligible to be appended, removed, or replaced. License changes are supported for Red Hat Enterprise Linux (RHEL), RHEL for SAP, SUSE Linux Enterprise Server (SLES), SLES for SAP, Ubuntu, and Ubuntu Pro. License changes are not supported for Windows or SQL Server licenses.

The allowed license changes are determined by the license owner and are subject to change. To validate the allowed license changes for your VM, seeReview license changes and restrictions.

For changing your RHEL or SLES licenses between pay-as-you-go (PAYG) and bring-your-own-subscription (BYOS), seeSwitch between PAYG and BYOS.

For Ubuntu LTS, to upgrade your license to Ubuntu Pro to enable ExtendedSecurity Maintenance (ESM), seeUpgrade from Ubuntu to Ubuntu Pro.

To update your on-demand RHEL license to include extended support,seeAppend the RHEL Extended lifecycle Support (ELS) Add-On to your license.

Before you begin

Prepare to update a disk's license

Caution: Google recommends using reservations to ensure machine availabilitywhile the VM is shut down.

To update the disk's license while the disk is attached to a running instance,first either stop the instance or detach the disk.

  • Stop the instance. Temporarily shuts down the instance before updating the disk's license.
  • Detach the disk. This detaches the disk from the instance before updating the disk's license.

View the licenses associated with a VM

Permissions required for this task

To perform this task, you must have the followingpermissions:

  • compute.instances.get

To view the licenses associated with a VM, use the Google Cloud console,gcloud CLI, or the Compute Engine API.

Console

  1. In the Google Cloud console, go to theVM instances page.

    Go to VM instances

  2. Click the name of the VM to check the license of. TheInstancedetails page opens.

  3. At the bottom of theInstance details page, clickEquivalent Code.

  4. View thelicenses field for the boot disk.

gcloud

  1. Run the followinggcloud compute instances describe command:

    gcloud compute instances describeVM_NAME

    ReplaceVM_NAME with the name of your VM.

  2. View thedisks section of the output. Thelicenses field shows thelicenses associated with the boot disk.

REST

Call theinstances.get v1 method:

GET https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/instancesVM_NAME

Replace the following:

  • PROJECT: the name of the project
  • ZONE: the zone containing the VM
  • VM_NAME: the name of the VM

The Compute Engine API returns the licenses associated with the bootdisk in thedisks section of thelicenses field.

Append a license during an image import

To append a license during the image import process, use the followinggcloud compute images import command.

gcloud compute images importIMAGE_NAME \  --source-file=SOURCE_FILE  --os=OS

Replace the following:

  • IMAGE_NAME: the name of the image to create.
  • SOURCE_FILE: a local file or Cloud Storage URI ofthe virtual disk to import.
  • OS: the OS of the disk image to import. The licensefor the OS is inferred from the value of this flag; there isn't an explicitflag to provide license information when importing. For a list of thesupported values, see--os flag.

For more information about importing images, seeImporting virtual disks.

Append licenses when creating an image

To append licenses when creating an image, use the followinggcloud compute images create command.

gcloud compute images createIMAGE_NAME \  --source-image=SOURCE_IMAGE \  --licenses=LICENSES

Replace the following:

  • IMAGE_NAME: the name of the image to create.
  • SOURCE_IMAGE: the name of the image to create the newimage from.
  • LICENSES: a comma-separated list oflicense strings. For example,"license1","license2".

For more information about creating images, seeCreating, deleting, and deprecating custom images, andCreating a Windows image.

Append licenses to a disk

To append licenses associated with a VM, use the gcloud CLI or the Compute Engine API.

gcloud

To append licenses to a disk using a license reference or code, use thefollowinggcloud compute disks update command.

gcloud compute disks updateDISK_NAME \--append-licenses=LICENSES

Replace the following:

  • DISK_NAME: the name of the disk to append.
  • LICENSES: a comma-separated list oflicense references, for example,"projects/rhel-cloud/global/licenses/rhel-9-server","projects/rhel-cloud/global/licenses/rhel-8-server".

REST

To append licenses to a disk using a license reference or code, call thefollowingdisks.update v1 method:

PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/disks/DISK_NAME?paths=licenses --data '{"name":"DISK_NAME", "licenses":["https://www.googleapis.com/compute/v1/LICENSES"]}'

Replace the following:

  • PROJECT: the name of the project
  • ZONE: the zone containing the VM
  • DISK_NAME: the name of the disk
  • LICENSES: a comma-separated list oflicense references, for example,"projects/rhel-cloud/global/licenses/rhel-9-server","projects/rhel-cloud/global/licenses/rhel-8-server".

Replace licenses on a disk

To replace licenses associated with a VM, use the gcloud CLI or the Compute Engine API.

gcloud

To replace a license on a disk using a license reference or code, use thefollowinggcloud compute disks update command.

gcloud compute disks updateDISK_NAME \--replace-license=PREVIOUS_LICENSE,NEW_LICENSE

Replace the following:

  • DISK_NAME: the name of the disk to append.
  • PREVIOUS_LICENSE: the previouslicense reference being replaced, for example,"projects/rhel-cloud/global/licenses/rhel-9-server","projects/rhel-cloud/global/licenses/rhel-8-server".
  • NEW_LICENSE: the newlicense reference, for example,"projects/rhel-cloud/global/licenses/rhel-9-server","projects/rhel-cloud/global/licenses/rhel-8-server".

REST

To replace a license on a disk using a license reference or code, call thedisks.update v1 method andreplace the previous license with the new license in the request body asfollows:

PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/disks/DISK_NAME?paths=licenses --data '{"name":"DISK_NAME", "licenses":["https://www.googleapis.com/compute/v1/NEW_LICENSE"]}'

Replace the following:

  • PROJECT: the name of the project
  • ZONE: the zone containing the VM
  • DISK_NAME: the name of the disk
  • NEW_LICENSE: the newlicense reference, for example,"projects/rhel-cloud/global/licenses/rhel-9-server","projects/rhel-cloud/global/licenses/rhel-8-server".

Remove licenses from a disk

To remove individual licenses associated with a VM, use the gcloud CLI and Compute Engine API.

gcloud

To remove licenses from a disk using a license reference or code, use thegcloud compute disks update command.

gcloud compute disks updateDISK_NAME \--remove-licenses=LICENSES

Replace the following:

  • DISK_NAME: the name of the disk to remove.
  • LICENSES: a comma-separated list oflicense references, for example,"projects/rhel-cloud/global/licenses/rhel-9-server","projects/rhel-cloud/global/licenses/rhel-8-server".

REST

To remove a license, provide an empty license field in the call request along with the path selector by calling the followingdisks.update v1 method:

PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/disks/DISK_NAME?paths=licenses --data '{"name":"DISK_NAME", "licenses":[]}'

Replace the following:

  • PROJECT: the name of the project
  • ZONE: the zone containing the VM
  • DISK_NAME: the name of the disk
  • LICENSES: leave blank.

View the history of license updates

View the history of license updates for VMs in a project by using the followingprocedure:

  1. In the Google Cloud console, go to theLogs Explorer page.

    Go to Logs Explorer

  2. In the toolbar, verify thatShow query is enabled.

  3. Copy the following expression into the query editor:

    resource.type="gce_disk"logName="projects/PROJECT_NAME/logs/cloudaudit.googleapis.com%2Factivity"severity>=NOTICEprotoPayload.request.@type="type.googleapis.com/compute.disks.update"protoPayload.request.licenses:*
  4. ReplacePROJECT_NAME with the name of the project.

  5. ClickRun query.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-18 UTC.