spectacularbob
spectacularbob

Reputation: 3218

Can duplicate UUID's (GUID's) be generated across multiple devices with the same image?

I am using multiple Raspberry Pis running raspian(Debian) for a project I am working on. I want each Raspberry Pi to have a unique ID so that I can tell them apart on a network.

I have thought that the g++ library <uuid/uuid.h> could be the best way to accomplish this, where the Pi will generate and store a UUID via a daemon program the first time it boots up.

However, I plan to create a stock installation image and load it onto the new raspberry Pi each time I add one to the network. As far as I understand it, UUID generation is partially based off of the system time and because I would be using the same image for all of them, they would probably all have the same system time. (It's possible that they could be booted before they could acquire any sort of internet time.)

How drastically does this affect the uniqueness of the UUID generation?

Upvotes: 1

Views: 2207

Answers (1)

Daniel Rudy
Daniel Rudy

Reputation: 1439

In general, there are several different ways to generate a guid/uuid. According to the UUID Wikipedia article, there are 5 different ways to generate them.

  1. Network MAC address and time.
  2. Same as #1, but also includes the users numeric user id or group id.
  3. This one uses a MD5 hash of some name, URL, or object. However, since hashing the same thing will give the same hash, a time element is added to make the guid/uuid unique.
  4. My personal favorite. The guid/uuid is generated at random using either a Pseudo Random Number Generator (PNRG), or a true random source like the decay of a radioactive isotope, white noise, noise amplified from a PN junction, etc.
  5. Same at #3, but uses the SHA-1 hash function instead.

In addition to these, some CPUs have an instruction that tells the CPU to provide its serial number. Many OEM machines have an area in the BIOS which contains the serial number of the machine. So any of these can be used as a source to generate a guid/uuid. Since you are running Linux, you can write your own routine to generate these.

If you plan on using something unique to the machine (such as the Network MAC Address), I would combine it with the current time and hash it a few times as this can cause a privacy hole. It was this privacy hole that allowed authorities to track down the author of the Melissa virus.

Additionally, there is RFC4122 which details this as well.

Upvotes: 1

Related Questions