Skip to contentSkip to conversation

search for partition using GPT GUID

PATCH KESHAV P.R. 3 participants 3 messages Mar 11, 2010

lore
Share & tools
lore
#0 lore raw

GPT GUID is one of the best FILESYSTEM-INDEPENDENT way of uniquely identifying a partition.

Most people who use GPT are thos who have need for many primary partitions. I use GPT in my internal 320 GB HDD (12 partitions) and 500 GB USB 2.0 external (11 partitions).

My guess of the workflow of grub2's search command :-

1) Read the partition table both the disks.
2) Find the starting/ending sectors of First Partition.
3) Detect its filesystem
4) Check for its UUID/GUID (length/uniqueness depends on the FS.
5) If the UUID matches, set it as the root part (set root=*)
6) If the UUID is different repeat steps 2,3,4 and 5 for 2nd partition (and so on).

The time taken for this operation depends on the number of partitions and the filesystem in each part. If one uses a 4 TB drive with 40 partitions of 100 GB (approx) each. GRUB2 has to read all the partitions, its filesystems in order till a UUID match is found. This will take a long time and will take more time depending on the not of disks connected.

But if GPT GUID is used, only the partition table needs to be accessed and each partition entry is checked for its "Partition Unique GUID" till a match is found. This is way faster since no filesystem is accessed and that accessing time is saved (especially for more no. of partitions). Maybe even the GPT Disk GUID can be used to reference a GPT disk (instead of confusion over whether it is (hd1) or (hd2) and so on.

Also I have no-FS partitions like BIOS-Boot incase of grub2, ie lets say I dd copy some bootloader to an unknown (my own random) GUID partition (like the way grub2 core.img is embedded in GPT-BIOS mode) in one of the external HDD, and I connect 2 external HDDs, how will I know which one is /dev/sdb and which one is /dev/sdc. SInce that part has no FS, the only way to uniquely reference that partition is using it "Unique GPT GUID". Also FS like FAT do not have UUIDs which can be regarded as unique. The main reason GPT table is good is because it provided FS-independent way to reference a part thus removing abiguity. Hope this test case is sufficient. Thank you.

PS : Please change the behavior of "help" command in grub2 shell as it is not possible to see all possible commands (it scrolls past screen and I see commands starting from s-alphabet only)

#1 lore raw
Quoted 2 lines · KESHAV P.R.

GPT GUID is one of the best FILESYSTEM-INDEPENDENT way of uniquely identifying a partition.

I am not sure if Linux supports gpt-uuids (I didn't find any hints of it via google!), but this sounds like it could be great news for Linux encrypted swap -- the current enc-swap recommendations destroy the partition contents on every boot, with a new random encryption-key and new mkswap inside it, so you have to refer to it like /dev/sda5. And then "/dev/sda5" partition gets destroyed on every boot, so the failure mode for wrong-partition is even worse than normal. But with a UUID stored outside the partition, it would be more possible to uniquely identify that partition. (Or a different encrypted-swap format, but no one seems interested in doing that :-( )

Quoted 3 lines

Maybe even the GPT Disk GUID can be used to reference a GPT disk (instead of confusion over whether it is (hd1) or (hd2) and so on.

oh, interesting, that could perhaps be nice for something

-Isaac

#2 lore raw

If this is to be supported, I highly recommend a GRUB2 commands that allows
the dumping of the current GPT partitions and their GUIDs so that if one needs to "look up" the GUID of a partition whose index is known they can do that without booting an OS (if one is even bootable!).

--S

Quoting Isaac Dupree, who wrote the following on Thu, 11 Mar 2010:

Quoted 20 lines · KESHAV P.R.
Quoted 2 lines

GPT GUID is one of the best FILESYSTEM-INDEPENDENT way of uniquely identifying a partition.

I am not sure if Linux supports gpt-uuids (I didn't find any hints of it via google!), but this sounds like it could be great news for Linux encrypted swap -- the current enc-swap recommendations destroy the partition contents on every boot, with a new random encryption-key and new mkswap inside it, so you have to refer to it like /dev/sda5. And then "/dev/sda5" partition gets destroyed on every boot, so the failure mode for wrong-partition is even worse than normal. But with a UUID stored outside the partition, it would be more possible to uniquely identify that partition. (Or a different encrypted-swap format, but no one seems interested in doing that :-( )

Quoted 3 lines

Maybe even the GPT Disk GUID can be used to reference a GPT disk (instead of confusion over whether it is (hd1) or (hd2) and so on.

oh, interesting, that could perhaps be nice for something

-Isaac

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel