All the web content and its acronym explains it as Uniquely identifier.

But when i try to create another device, lets say swap in my case and assign the UUID, i am able to assign many UUIDs to single slice of disk.

I can create multiple swap device with different UUIDs, using command mkswap with -U option to it.

Then, how is it unique..?

  • Because multiple swap devices can be created with same UUID. – amitam Sep 24 '15 at 10:32
  • 1
    @AmitM but then you assigned the UUID, the system didn't. You're not a valid source of UUIDs. – muru Sep 24 '15 at 10:40
  • Yes, But OS should take care that device should have single UUID, thats how it will be uniquely identified. Agree? – amitam Sep 24 '15 at 10:51
  • I think to devices Like /dev/sd[a|b|c|] – amitam Sep 24 '15 at 10:54
  • Indeed, UUIDs are assigned to filesystems. LVM volumes might have UUIDs, which are named PARTUUID in blkid output, IIRC. "OS should take care that device should have single UUID, thats how it will be uniquely identified. Agree?" Disagree. Why should it, when you, the user, are deliberately assigning the same UUID? – muru Sep 24 '15 at 11:22

No, a UUID can't be guaranteed to be unique. A UUID is just a 128-bit random number. When my computer generates a UUID, there's no practical way it can prevent your computer or any other device in the universe from generating that same UUID at some time in the future.

It may not be likely that any two UUIDs will be the same, but they can be.

In this case, the code assigning UUIDs to devices may check a new UUID against any existing UUIDs already assigned to devices and throw away duplicates, guaranteeing uniqueness that way.

Regarding uniqueness. When a new disk is installed to a system, the usual practice is for a technician to define the partitions thereon. Labels are not unique and are not used. In the definition process, a software algorithm creates a UUID.

As the system already has a list of existing mounted UUIDs, the process of defining the partition automatically creates a unique UUID value. The new UUID value filtered against the existing list of mounted UUID's so as to avoid duplication. With partition creation,on the host system that UUID coupled with the partition number form a unique combination.

Yes really. Duplication could occur if the disk is prepared on system A for use on an existing system B.

  • On my setup, i can create multiple swap devices, where Veritas VxVM product is installed and used. Here, i have OS device path with one UUID AND veritas vxvm device with another UUID and both are swap devices. Doesn't this mean, we have a single physical part of disk and many logical partitions are pointing to the same part/slice of disk but having different UUIDs. – amitam Sep 24 '15 at 10:34
  • 1
    This link seems appropriate: wiki.archlinux.org/index.php/… Note that it says filesystems have UUIDs, not the device itself. – Andrew Henle Sep 24 '15 at 11:08

i am able to assign many UUIDs to single slice of disk.

Not really. You can only assign a single UUID to an object. But you can have objects that cover the same space and each have their own UUID, for example a filesystem and the UEFI partition or the LVM logical volume that it's on.

I can create multiple swap device with different UUIDs

That would be normal: multiple swap volumes, each with its own distinct UUID.

It appears though that you actually meant to ask about the opposite situation: having the same UUID on different volumes. This is not supposed to happen. It won't happen if you use normal tools. For example, when you create a filesystem or a swap volume, by default, it gets a random UUID; since this random value has 122 bits of entropy, the world can have about a quintillion (one billion billion) volumes, each with its own UUID, before the probability of collisions becomes significant.

If you tell the tools which UUID to use, then it becomes your responsibility to ensure that the UUID is unique. UUIDs are unique when used correctly; therefore, if you force non-unique UUIDs, you're using them incorrectly.

  • I think, uniqueness of UUID is at system level, not at universe. By that i mean, UUID assigned by system would be unique among all the UUIDs present on the system, not that its unique in the world. I just want to mention this, to your comments. – amitam Sep 25 '15 at 5:54
  • @AmitM Your thinking is wrong. UUID, if generated correctly, are unique in the world. – Gilles Sep 25 '15 at 7:58

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.