How to upgrade Ubuntu LTS to Ubuntu Pro on Google Cloud

Overview

Duration: 2:00
Google Cloud offers users an option to in-place upgrade Ubuntu LTS VMs to Ubuntu Pro in simply three steps:

  1. Installing updates and dependencies
  2. Appending the Ubuntu Pro license
  3. Validating the license

What you’ll need

  • Ubuntu LTS machines from 16.04 onwards
  • Having “pro client” tool in your machine

What you’ll learn
How to use gcloud command to in-place upgrade Ubuntu LTS to Ubuntu Pro.

Installing updates and dependencies

  • Run the following commands on each VM, replacing VM_NAME with the name of the VM to upgrade:
    1. Update the package index by using the following command:

gcloud compute ssh VM_NAME --command “sudo apt update”

  1. Install the newest version of the packages by using the following command:

gcloud compute ssh VM_NAME --command “sudo apt upgrade”

  1. Install Ubuntu Pro by using the following command:

gcloud compute ssh VM_NAME --command “sudo apt install ubuntu-advantage-tools”

Appending the Ubuntu Pro license

Append the Ubuntu Pro license by using the following procedure:

  1. Stop the VM by using the gcloud compute instances stop command:

gcloud compute instances stop VM_NAME \ --zone=ZONE

Replace the following:

  • VM_NAME: the name of the VM to stop
  • ZONE: the zone containing the VM to stop
  1. Get the list of disks associated with the VM by using the gcloud compute instances describe command:

gcloud compute instances describe VM_NAME \ --zone=ZONE \ --format=“yaml(disks)”

Replace the following:

  • VM_NAME: the name of the VM to get the list of associated disks from
  • ZONE: the zone containing the VM to get the list of associated disks from
  1. Verify that the output is similar to:
disks:
- autoDelete: true
  boot: true
  deviceName: ubuntu
  diskSizeGb: '10'
  guestOsFeatures:
  - type: VIRTIO_SCSI_MULTIQUEUE
  - type: SEV_CAPABLE
  - type: UEFI_COMPATIBLE
  - type: GVNIC
  index: 0
  interface: SCSI
  kind: compute#attachedDisk
  licenses:
  - https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1604-xenial
  mode: READ_WRITE
  shieldedInstanceInitialState:
    dbxs:
    - content: ...
      fileType: BIN
  source: https://www.googleapis.com/compute/v1/projects/PROJECT_NAME/zones/ZONE/disks/VM_NAME
  type: PERSISTENT

Note that no userLicenses have been appended.
4. Get the name of the boot disk by running the gcloud compute disks list command:

gcloud compute disks list

  1. Update the boot disk with the Ubuntu Pro license URI by using the gcloud beta compute disks update command:

gcloud beta compute disks update BOOT_DISK_NAME \ --zone=ZONE \ --update-user-licenses=“LICENSE_URI”

Replace the following:

  • BOOT_DISK_NAME: the name of the boot disk to append the license to.
  • ZONE: the zone containing the boot disk to append the license to.
  • LICENSE_URI: the license URI for the version of Ubuntu Pro you are upgrading to. The following table shows the license URI for the supported versions of Ubuntu Pro:
Ubuntu Pro version License URI
Ubuntu Pro 16.04 LTS https://www.googleapis.com/compute/v1/projects/ubuntu-os-pro-cloud/global/licenses/ubuntu-pro-1604-lts
Ubuntu Pro 18.04 LTS https://www.googleapis.com/compute/v1/projects/ubuntu-os-pro-cloud/global/licenses/ubuntu-pro-1804-lts
Ubuntu Pro 20.04 LTS https://www.googleapis.com/compute/v1/projects/ubuntu-os-pro-cloud/global/licenses/ubuntu-pro-2004-lts

Validate the license

Validate the Ubuntu Pro license by using the following procedure:

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

gcloud beta compute disks describe BOOT_DISK_NAME \ --zone=ZONE

Replace the following:

  • BOOT_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
  1. Verify output similar to:
creationTimestamp: '2021-10-20T17:20:26.616-07:00'
guestOsFeatures:
- type: VIRTIO_SCSI_MULTIQUEUE
- type: SEV_CAPABLE
- type: UEFI_COMPATIBLE
- type: GVNIC
id: '7008232787326864549'
kind: compute#disk
labelFingerprint: 42WmSpB8rSM=
lastAttachTimestamp: '2021-10-20T17:20:26.617-07:00'
licenseCodes:
- '1000201'
- '8045211386737108299'
licenses:
- https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1604-xenial
name: ubuntu
physicalBlockSizeBytes: '4096'
selfLink: https://www.googleapis.com/compute/v1/projects/PROJECT_NAME/zones/ZONE/disks/DISK_NAME
sizeGb: '10'
sourceImage: https://www.googleapis.com/compute/v1/projects/IMAGE_PROJECT/global/images/IMAGE
sourceImageId: '1233998915439563944'
status: READY
type: https://www.googleapis.com/compute/v1/projects/PROJECT_NAME/zones/ZONE/diskTypes/DISK_TYPE
userLicenses:
- https://www.googleapis.com/compute/v1/projects/ubuntu-os-pro-cloud/global/licenses/ubuntu-pro-1604-lts
users:
- https://www.googleapis.com/compute/v1/projects/PROJECT_NAME/zones/ZONE/instances/VM_NAME
zone: https://www.googleapis.com/compute/v1/projects/PROJECT_NAME/zones/ZONE
  1. Validate that the Ubuntu Pro license is appended to the boot disk by checking the output of the previous step for the userLicenses field for the appropriate license string.If the userLicenses field doesn’t contain the intended license string, you might need to clear and update the user licenses. For more information, see the gcloud beta compute disks update command.
  2. Start the VM by using the gcloud compute instances start command:

gcloud compute instances start VM_NAME \ --zone=ZONE \ [–csek-key-file ENCRYPTION_KEY]

Replace the following:

  • VM_NAME: the name of the VM to start
  • ZONE: the zone containing the VM to start
  • ENCRYPTION_KEY: an optional flag that specifies the path to the Customer-Supplied Encryption Key (CSEK) file if the boot disk is encrypted
  1. After the VM boots, run the gcloud compute ssh command to verify that the Ubuntu ESM is entitled and enabled:

gcloud compute ssh VM_NAME --command “sudo ua status --wait” \ --zone=ZONE

Replace the following:

  • VM_NAME: the name of the VM to verify
  • ZONE: the zone containing the VM to verify
  1. Check that the Ubuntu ESM is entitled and enabled by verifying that the output is similar to:
SERVICE       ENTITLED  STATUS    DESCRIPTION
cis           yes       disabled  Center for Internet Security Audit Tools
esm-apps      yes       enabled   UA Apps: Extended Security Maintenance (ESM)
esm-infra     yes       enabled   UA Infra: Extended Security Maintenance (ESM)
fips          yes       n/a       NIST-certified core packages
fips-updates  yes       n/a       NIST-certified core packages with priority security updates
livepatch     yes       n/a       Canonical Livepatch service
1 Like

Ubuntu Pro 22.04 License: https://www.googleapis.com/compute/v1/projects/ubuntu-os-pro-cloud/global/licenses/ubuntu-pro-2204-lts