10

Exactly what part of the disk is a UUID stored on? MBR? Somewhere within the partition? Is it a calculated value, or randomly generated and recorded?

jldugger
  • 14,122
  • 19
  • 73
  • 129

2 Answers2

13

The UUID is stored in the superblock (of which there are many copies in case one gets damaged). The value itself is generated using libuuid, which is part of the e2fsprogs suite. There are many libraries for generating UUIDs; RFC4122 is a good place to start as it describes the more commonly used technique and includes reference code.

Here's a couple of links that may help - they are specific to ext2, but other variants should also have a similar place where they store the uuid:

http://www.nongnu.org/ext2-doc/ext2.html#S-UUID

http://linux.die.net/man/3/libuuid

James F
  • 6,549
  • 1
  • 25
  • 23
0

There are many ways to get the UUID of a partition, but by far the simplest way is to look in the /dev/disk/by-uuid/ folder. By example,

[pobega@greedo]$ **ls -l /dev/disk/by-uuid/**
lrwxrwxrwx 1 root root 10 2009-08-26 17:13 02ce3c1b-8893-402a-9e12-c01ac752ac3b -> ../../sda2
lrwxrwxrwx 1 root root 10 2009-08-26 17:13 2dcd156b-7ec6-4bf5-b1a2-dd4f5fb5082a -> ../../sdb3
[...]

Each file is a symlink to the partition that it is the UUID of (I apologize if that sentence is tough to comprehend, but it's a tough concept to put into words).

Michael Pobega
  • 934
  • 5
  • 12
  • I'm not interested in the UUID, but how those UUID to device mappings are built, so that I can restore Ubuntu from a full disk backup and expect it to boot. – jldugger Aug 27 '09 at 04:10