2

Can anybody explain me how UUID (Universally unique identifier) of a partition is generated in Linux based distributions ?

5

Both UUID of GPT partitions, and UUID of filesystems, are generated randomly when the partition/filesystem is created. You can check that they're version 4 UUIDs.

| improve this answer | |
3

An uuid is just formatted (hyphens at specific places) random bytes so there's nothing magical about it.

By glancing at the source, which you can get with apt-get source libuuid1 if you're on a Ubuntu based distro, the uuid generation either uses truly random bytes (known to be rather slow -- you can get those by reading from the /dev/random special file) or time-based bytes (virtually instantaneous but not cryptographically secure).

| improve this answer | |
2

UUID of a partition which generated in Linux distribution is version 4. The version 4 UUID is meant for generating UUIDs from truly-random or pseudo-random numbers. It is described in RFC 4122 .

| improve this answer | |
2

At present in my Ubuntu 15.04 UUID version 4 is used for partitions.
Version 4 UUIDs use a scheme relying only on random numbers.

xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx

here 4 denotes the version number
x is any hexadecimal digit
y is one of 8, 9, A, or B

Random UUID probability of duplicates

Out of a total of 128 bits, two bits indicate an RFC 4122 ("Leach-Salz") UUID and four bits the version (0100 indicating "randomly generated"), so randomly generated UUIDs have 122 random bits. The chance of two such UUIDs having the same value can be calculated using probability theory (birthday paradox). Using the approximation

enter image description here

these are the probabilities of an accidental clash after calculating n UUIDs, with x = 2^122:

To put these numbers into perspective, the annual risk of a given person being hit by a meteorite is estimated to be one chance in 17 billion, which means the probability is about 0.00000000006 (6 × 10−11), equivalent to the odds of creating a few tens of trillions of UUIDs in a year and having one duplicate. In other words, only after generating 1 billion UUIDs every second for the next 100 years, the probability of creating just one duplicate would be about 50%.

source: wikipedia

| improve this answer | |
  • Hmmm.....I see a different format of UUID for marked LVM2 members: /dev/sda2: UUID="7ceOVx-e0v2-8Y4H-i5En-Vkum-rz54-B24bmU" TYPE="LVM2_member" on one system and /dev/sda2: UUID="Cq99qZ-go7M-O569-e1Kc-yzso-xCWQ-R9bP4G" TYPE="LVM2_member" on another which deviates from the standard described in this answer. – mdpc Sep 1 '16 at 21:49
  • @mdpc how does it deviates? – Edward Torvalds Sep 2 '16 at 13:09
  • the '4' and the 'y' – mdpc Sep 2 '16 at 16:58
  • @mdpc looks like your distribution is not using version 4, but that is ok – Edward Torvalds Sep 3 '16 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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