1

How the tag ID_PART_ENTRY_UUID is computed? Can I get ID_PART_TABLE_UUID from ID_PART_ENTRY_UUID?

I have a disk with GPT partition table and some partitions.

I need to identify which partitions are related to my disk. All partitions in the disk are referenced to partition table in this disk. I can found this partition table id with udevadm:

$ sudo udevadm info /dev/loop18p1 | grep ID_PART_TABLE_UUID
E: ID_PART_TABLE_UUID=75e3b937-1ff1-4166-a51f-524b98278e6e

However, unfortunately udevadm (as well as parted and so on) is not suitable for me and I have to use blkid

I can found a partition table id from disk:

$ sudo blkid -po udev /dev/loop18 | grep ID_PART_TABLE_UUID
ID_PART_TABLE_UUID=75e3b937-1ff1-4166-a51f-524b98278e6e

But ID_PART_TABLE_UUID is absent in partition:

$ sudo blkid -po udev /dev/loop18p1
ID_PART_ENTRY_SCHEME=gpt
ID_PART_ENTRY_NAME=primary
ID_PART_ENTRY_UUID=bcf5e461-90db-4625-a471-6c1d61126773
ID_PART_ENTRY_TYPE=0fc63daf-8483-4772-8e79-3d69d8477de4
ID_PART_ENTRY_NUMBER=1
ID_PART_ENTRY_OFFSET=34
ID_PART_ENTRY_SIZE=195279
ID_PART_ENTRY_DISK=7:18

There is only ID_PART_ENTRY_UUID. In MBR partition table, ID_PART_ENTRY_UUID is just a ID_PART_TABLE_UUID plus serial number of partition, so I can handle it easily. But in GPT table ID_PART_ENTRY_UUID is a tricky hash. I suppose this hash is related to ID_PART_TABLE_UUID and I can use it to recognize a partitions of disk.

So, how this hash ID_PART_ENTRY_UUID is computed? Can I get ID_PART_TABLE_UUID from ID_PART_ENTRY_UUID?

I suppose it's possible because udevadm can do it.

Upd: Actually I use binding to liblkid instead of CLI blkid but I suppose it doesn't matter.

NikBond
  • 113
  • 4

1 Answers1

1

For GPT ID_PART_TABLE_UUID and ID_PART_ENTRY_UUID are not related, these are just unique UUIDs (or in fact GUIDs converted to UUIDs in libblkid) from GPT header (for ID_PART_TABLE_UUID) and GPT partition entry (for ID_PART_ENTRY_UUID).

UDev has the information simply because it has a basic parent-child relationship knowledge and for partitions some basic information from the parent (disk) are added to the partition data (see 60-persistent-storage.rules UDev rule).

Vojtech Trefny
  • 16,922
  • 6
  • 24
  • 48