3

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.

Kara
  • 6,115
  • 16
  • 50
  • 57
pktCoder
  • 1,105
  • 2
  • 15
  • 32

4 Answers4

2

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"
  • note that `dmidecode` [requires root privilege](https://stackoverflow.com/a/338161/900078). – pynexj Sep 15 '21 at 02:17
2

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.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • Thanks John for the idea. Sorry I didn't specify the need clearly. Here is expected use of the UUID. -- when someone else gets one of my application and try it on his PC What's needed here is a UUID that's generated by the system. More specifically, the application will – pktCoder Jan 07 '12 at 22:07
  • Sorry, the formatting is killing me. "Enter" will cause the message to be submitted. Here is it again. Thanks John for the idea. Sorry I didn't specify the need clearly. Here is expected use of the UUID. 1) when a user gets my application and try it on his PC, this application will pull the UUID and asks him to register 2) when user register the UUID and get a hash, he will run the application with the hash and then the application will run. The goal of UUID here is to prevent user from doing only one registration and run the application on multiple PCs (linux). – pktCoder Jan 07 '12 at 22:16
2

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.

Evan Powell
  • 960
  • 5
  • 4
  • Thanks a lot Evan for the info. Wish I could get a notification email. The purpose of of using UUID is to prevent the case when a user get one license of a program (in a VM) and copy the VM in a different hardware to run it. Are you saying Vmware middleware will generate a UUID based on the actual hardware and will always generate different UUIDs? Thanks again. – pktCoder Jan 19 '12 at 02:17
  • VMware generates UUIDs in a specific range, but it's not hardware dependent. In fact, the UUID can be changed by the user in the .vmx file, or via the API. No identical UUIDs are allowed within a single VMware product - in the case of vCenter, this likely spans their whole virtual infrastructure. vCenter will do the unique-UUID enforcement for you in this case, and you won't have to worry about it. If they don't use vCenter, they can copy the VM on different host hardware and it would work. This just seems like a long way to go to circumvent a license that is likely cheaper than a server. – Evan Powell Jan 31 '12 at 17:55
0

The VMware UUID can also be found this way :

$ sudo cat /sys/class/dmi/id/product_serial /sys/class/dmi/id/product_uuid
SebMa
  • 4,037
  • 29
  • 39