Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to be able uniquely identify my virtual machines from inside the virtual machine. The problem is that in my setup I cannot use the MAC address for that. Is it possible to configure another hardware parameter (e.g. CPU name, BIOS flags, Motherboard ID,...) to have a unique value for my VM which I can then access from inside the VM? I would be most interested in solutions which work for Xen, KVM or VMWare ESX or at best for all of them.

share|improve this question
possibly related question: Can a virtual PC find out the identity of its host? – warren Jul 14 '11 at 15:35

You could generate a UUID from the host when the VM is created, and pass it in via the kernel command-line. When you transfer the machine from one hardware node to the next, the UUID would travel with it. However, when you create a new machine, a new UUID would be generated for it.

As mentioned in the other answer, this won't work if you duplicate the VM (including its configuration), but in that event it wouldn't be hard to run uuidgen from the command line and replace the UUID in the configuration file that is used to create the domain.

As a matter of practice, it's probably best not to duplicate VMs in that manner anyway; you should create a new VM and have a script run that configures the VM in whatever manner best fits your environment.

share|improve this answer
(Additionally, another way you could pass it would be to create a file .vm_uuid or similar in the guest system's filesystem root, such that a program could simply read the UUID from that file instead of looking in /proc/cmdline and parsing it out from the kernel command line.) – Michael Trausch Jul 25 '11 at 20:10

Have the VM generate and store a UUID/GUID:

   This specification defines a Uniform Resource Name namespace for
   UUIDs (Universally Unique IDentifier), also known as GUIDs (Globally
   Unique IDentifier).  A UUID is 128 bits long, and can guarantee
   uniqueness across space and time.  UUIDs were originally used in the
   Apollo Network Computing System and later in the Open Software
   Foundation's (OSF) Distributed Computing Environment (DCE), and then
   in Microsoft Windows platforms.

Microsoft provide a utility called uuidgen

Python has it built in from 2.5:

So that covers you for Windows and Linux.

share|improve this answer
What happens when that VM is copied to another host? How do you ensure that the UUID is unique? – Jed Daniels Jul 14 '11 at 21:00
The GUID/UUID doesn't change. The relevant snippet from the RFC "can guarantee uniqueness across space and time" – davey Jul 15 '11 at 5:51
Right. So once you make a copy, the UUID is no longer unique, since you now have two or more machines with the same UUID. You'd have to generate a NEW uuid, after having some mechanism to recognize that you just copied your first VM (note that I said copied, not moved; if you move, you want the same UUID). – Jed Daniels Jul 15 '11 at 19:21
Script the process; copy, boot, regenerate UIID, register UUID in CMDB. If people are making uncontrolled copies of VM's in an environment then that environment has other problems than a UUID is going to solve. – davey Jul 16 '11 at 7:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.