pktCoder
pktCoder

Reputation: 1115

Is there a UUID type of value in Linux that can uniquely identify an instance of a VM?

I have an app that runs in Linux. Each one will try to get a UUID from OS and report to a centralized server. I want to make sure all instance are running with globally unique UUID.

If the linux is on bare metal, it can just read the UUID (say, from dmidecode command). But if it's on VM, the UUID (from dmidecode) can potentially be equal since the VM can be copied or moved.

Any ideas?

By the way, for Linux running on physical hardware (not on VM), if user changes memory, NIC etc, will UUID change?

Thanks in advance.

Upvotes: 3

Views: 16908

Answers (4)

SebMa
SebMa

Reputation: 4709

The VMware UUID can also be found this way :

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

Upvotes: 0

Михаил Кру
Михаил Кру

Reputation: 21

Linux

root@vmtest:~#dmidecode | grep -i uuid | awk '{print $2}' | tr '[:upper:]' '[:lower:]'

564d7abb-2403-eb3b-2fde-81cd440fc49b

In Esxi

cat vmtest.vmx
...
uuid.bios = "56 4d 7a bb 24 03 eb 3b-2f de 81 cd 44 0f c4 9b"
...

SNMP Esxi

iso.3.6.1.4.1.6876.2.1.1.10.<vmID> = = STRING: "564d7abb-2403-eb3b-2fde-81cd440fc49b"

Upvotes: 2

Evan Powell
Evan Powell

Reputation: 960

If the linux is on bare metal, it can just read the UUID (say, from dmidecode command). But if it's on VM, the UUID (from dmidecode) can potentially be equal since the VM can be copied or moved.

This is not actually the case for VMware products. The BIOS UUID (the one returned by dmidecode) is used as the inventory UUID property of ESX hosts and vCenter, and duplication of the UUID is not allowed on the same system. This means only one machine can have that UUID per vCenter, or per host if there is no vCenter. I've used this UUID as an identifier in the past with success.

To run your program more than once, they'd have to install it in a VM on a separate host, or in an entirely different vCenter. That's an awful lot of resources required just to run more than one of your program, and I think it's well beyond the diminishing returns of license enforcement.

Workstation uses the same data layout as ESX/vCenter, so I expect that it has the same restriction.

Upvotes: 2

John Zwinck
John Zwinck

Reputation: 249143

If your UUID does not need to be tied to a specific OS installation, just generate one for your specific application using uuid_generate and friends. From what you've written so far, it sounds like this could be a fine solution for your use case.

Upvotes: 2

Related Questions