Get the UUID of a VM

This document describes how to get the universally unique identifier (UUID) of a virtual machine (VM) instance from within the guest operating system.

Each Compute Engine VM has a system UUID with the following properties:

  • The UUID is unique among Compute Engine VMs.

  • Compute Engine generates the UUID from the VM's project number, zone, and name.

  • The UUID is stable for the lifetime of the VM. If you delete and re-create a VM in the same project, in the same zone, and with the same name, then the VM receives the same UUID, although string formatting such as letter case and byte order can vary across operating systems and CPU architectures.

  • UUIDs are available for VMs created on or after October 30, 2014. If you have a VM created before that date, then re-create the VM so that Compute Engine can assign it a UUID.

Use operating system tools to get the UUID of a VM

To get the UUID of a VM, run the command that corresponds to the VM's operating system:

Linux

Connect to the Linux VM and read the System Management BIOS (SMBIOS) system UUID from the /sys/class/dmi/id/product_uuid file:

sudo cat /sys/class/dmi/id/product_uuid

Alternatively, if the dmidecode utility is installed on the VM, then run the following command:

sudo dmidecode -s system-uuid

The output is similar to the following:

3748eb17-a207-5bc3-aa4f-3113a1b9409d

Windows (PowerShell)

From PowerShell on the Windows VM, run the following Get-CimInstance cmdlet to query the Win32_ComputerSystemProduct Common Information Model (CIM) class:

(Get-CimInstance -ClassName Win32_ComputerSystemProduct).UUID

The output is similar to the following:

81CBB42C-73A0-9660-6C7D-2FE94627F3A3

Windows (Command Prompt)

From Command Prompt on the Windows VM, run the following command to invoke the PowerShell Get-CimInstance cmdlet:

powershell -NoProfile -Command "(Get-CimInstance -ClassName Win32_ComputerSystemProduct).UUID"

The output is similar to the following:

81CBB42C-73A0-9660-6C7D-2FE94627F3A3