Update licenses after an OS upgrade

This page explains how to update the license strings on your virtual machine (VM) instances after you perform an in-place upgrade of the operating system (OS). This process applies to the following operating systems:

  • Red Hat Enterprise Linux (RHEL)
  • RHEL for SAP
  • SUSE Linux Enterprise Server (SLES)
  • SLES for SAP
  • Windows Server

For details on license references and codes, see License changes and restrictions.

Before you begin

  • If you haven't already, set up authentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    gcloud

    1. Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:

      gcloud init

      If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

    2. Set a default region and zone.

Update the license on the disk

To update the license on a disk, use the Google Cloud CLI or the Compute Engine API. This process replaces the existing license URI with the new one corresponding to your upgraded OS version.

gcloud

To replace a disk's license with a new license reference, use the gcloud compute disks update command:

gcloud compute disks update DISK_NAME \
    --replace-license=PREVIOUS_LICENSE,NEW_LICENSE

Replace the following:

  • DISK_NAME: the name of the disk to update.
  • PREVIOUS_LICENSE: the license reference required for the previous OS version, for example, "windows-server-2022-dc" or "rhel-9".
  • NEW_LICENSE: the license reference required for the new OS version, for example, "windows-server-2025-dc" or "rhel-10".

REST

To replace a disk's license, add the new license to the request body and omit the previous license. Call the following disks.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/NEW_LICENSE"]}'

Replace the following:

  • PROJECT: the name of the project.
  • ZONE: the zone containing the disk.
  • DISK_NAME: the name of the disk.
  • NEW_LICENSE: the new license reference, for example, "windows-server-2025-dc" or "rhel-10".

Validate the license change

To validate that your license has been changed on the boot disk, use the following procedure:

  1. Get information about the boot disk by running the gcloud compute disks describe command:

    gcloud compute disks describe DISK_NAME \
        --zone=ZONE \
        --format="value(licenses)"
    

    Replace the following:

    • DISK_NAME: the name of the boot disk to validate the license of
    • ZONE: the zone containing the boot disk to validate the license of
  2. Verify that the output is similar to the following:

    https://www.googleapis.com/compute/v1/projects/windows-cloud/global/licenses/windows-server-2025-dc