search for partition using GPT GUID
PATCH 1/1 search for partition using GPT GUID
Hello everybody.
I have just implemented support for GPT GUID search and I am really interested in providing this patch for integration.Who is in chief here, we can discuss details =)
Patch is included. The syntax is now the following
# Entry 1 - Chainload another bootloader
menuentry "Chainload LILO"
{
search --no-floppy --gpt-guid --set a97fa026-fa15-8244-b272-5bff98b1c522
chainloader /boot/elilo.efi
}As I said before, search over GPT GUIDs is much safer then in FS UUID (see topic below)
Regards,
Georgy
=== modified file 'ChangeLog'
ChangeLog +5 -0
@@ -1,3 +1,8 @@ +2010-02-12 Georgy Buranov <[email protected]> + + * disk/efi/efidisk.c (grub_efidisk_get_device_name): Fix bug obtaining device name of the whole disk + * fs/iso9660.c (grub_iso9660_iterate_dir): Remove file versions from ISO9660&Joliet file names + 2010-02-10 Vladimir Serbinenko <[email protected]> Pass SIMPLE framebuffer size in bytes and not 64K blocks.
=== modified file 'commands/search.c'
search.c +59 -0
83 lines not on this page · raw message
=== modified file 'commands/search_wrap.c'
search_wrap.c +7 -2
@@ -34,6 +34,8 @@ 0, 0}, {"fs-uuid" ,'u' ,0 ,N_ ("Search devices by a filesystem UUID." ), 0, 0}, + {"gpt-guid", 'g', 0, N_("Search devices by GPT GUID."), + 0, 0}, {"set", 's', GRUB_ARG_OPTION_OPTIONAL, N_("Set a variable to the first device found."), "VAR", ARG_TYPE_STRING}, {"no-floppy", 'n', 0, N_("Do not probe any floppy drive."), 0, 0},
@@ -45,6 +47,7 @@SEARCH_FILE ,SEARCH_LABEL ,SEARCH_FS_UUID , +SEARCH_GPT_GUID ,SEARCH_SET , SEARCH_NO_FLOPPY, };
@@ -67,6 +70,8 @@grub_search_fs_uuid (args[0 ], var, state[SEARCH_NO_FLOPPY ].set); else if (state[SEARCH_FILE].set) grub_search_fs_file (args[0], var, state[SEARCH_NO_FLOPPY].set); + else if (state[SEARCH_GPT_GUID].set) + grub_search_gpt_guid (args[0], var, state[SEARCH_NO_FLOPPY].set); else return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
@@ -80,9 +85,9 @@ cmd = grub_register_extcmd ("search", grub_cmd_search, GRUB_COMMAND_FLAG_BOTH, - N_("search [-f|-l|-u|-s|-n] NAME"), + N_("search [-f|-l|-u|-g|-s|-n] NAME"), N_("Search devices by file, filesystem label" - " or filesystem UUID." + " ,filesystem UUID or GPT GUID." " If --set is specified, the first device found is" " set to a variable. If no variable name is" " specified, \"root\" is used."),
=== modified file 'conf/any-emu.rmk'
any-emu.rmk +1 -0
@@ -10,6 +10,7 @@ commands/handler.c commands/ls.c commands/test.c \ commands/search_wrap.c commands/search_file.c \ commands/search_label.c commands/search_uuid.c \ + commands/search_guid.c \ commands/blocklist.c commands/hexdump.c \ lib/hexdump.c commands/halt.c commands/reboot.c \ lib/envblk.c commands/loadenv.c \
=== modified file 'conf/common.rmk'
common.rmk +6 -1
@@ -519,7 +519,7 @@ search_mod_CFLAGS = $(COMMON_CFLAGS) search_mod_LDFLAGS = $(COMMON_LDFLAGS) -pkglib_MODULES += search_fs_file.mod search_fs_uuid.mod search_label.mod +pkglib_MODULES += search_fs_file.mod search_fs_uuid.mod search_label.mod search_gpt_guid.mod # For search.mod. search_fs_file_mod_SOURCES = commands/search_file.c
@@ -536,6 +536,11 @@ search_fs_uuid_mod_CFLAGS = $(COMMON_CFLAGS) search_fs_uuid_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For search.mod. +search_gpt_guid_mod_SOURCES = commands/search_guid.c +search_gpt_guid_mod_CFLAGS = $(COMMON_CFLAGS) +search_gpt_guid_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For test.mod. test_mod_SOURCES = commands/test.c test_mod_CFLAGS = $(COMMON_CFLAGS)
=== modified file 'disk/efi/efidisk.c'
efi/efidisk.c +1 -1
@@ -825,7 +825,7 @@if (! disk)return 1 ; -if (disk->id ==GRUB_DISK_DEVICE_EFIDISK_ID ) +if (disk->dev->id ==GRUB_DISK_DEVICE_EFIDISK_ID ) {struct grub_efidisk_data *d;
=== modified file 'fs/iso9660.c'
iso9660.c +8 -3
@@ -615,9 +615,6 @@if (!filename) { name[dirent.namelen] ='\0' ; - filename =grub_strrchr (name,';' ); -if (filename) - *filename ='\0' ;if (dirent.namelen ==1 && name[0 ] ==0 ) filename ="." ;
@@ -640,6 +637,14 @@ filename_alloc =1 ; } + +if (!dir->data->rockridge) + { +// On simple ISO 9660 disks and on joliet, we need to remove file version, if any +char * lastSymbol =grub_strrchr (filename,';' ); +if (lastSymbol) + *lastSymbol ='\0' ; + }if (hook (filename, type, node)) {
=== modified file 'include/grub/gpt_partition.h'
grub/gpt_partition.h +7 -0
@@ -20,6 +20,9 @@#define GRUB_GPT_PARTITION_HEADER 1#include <grub/types.h> +#include <grub/err.h> +#include <grub/disk.h> +#include <grub/partition.h> struct grub_gpt_part_type {
@@ -67,5 +70,9 @@grub_uint64_t attrib;char name[72 ]; } __attribute__ ((packed)); +typedef struct grub_gpt_partentry *grub_gpt_partentry_t ; + +grub_err_t +gpt_partition_map_gpt_iterate (grub_disk_t disk,void (*hook) (grub_gpt_partentry_t entry));#endif /* ! GRUB_GPT_PARTITION_HEADER */
=== modified file 'include/grub/search.h'
grub/search.h +1 -0
@@ -22,5 +22,6 @@void grub_search_fs_file (const char *key,const char *var,int no_floppy);void grub_search_fs_uuid (const char *key,const char *var,int no_floppy);void grub_search_label (const char *key,const char *var,int no_floppy); +void grub_search_gpt_guid (const char *key,const char *var,int no_floppy);#endif
=== modified file 'partmap/gpt.c'
gpt.c +43 -8
69 lines not on this page · raw message
=== modified file 'po/POTFILES'
POTFILES +1 -0
@@ -40,6 +40,7 @@ commands/search_file.c commands/search_label.c commands/search_uuid.c +commands/search_guid.c commands/sleep.c commands/test.c commands/true.c
What about this patch? It is possible to integrate it, at least in the experimental branch?
--
This message was sent on behalf of [email protected] at openSubscriber.com
http://www.opensubscriber.com/message/[email protected]/13421616.html
Quoted 3 lines · [email protected] wrote:
What about this patch? It is possible to integrate it, at least in the experimental branch?
I asked you for at least a usecase when it makes a difference but till now I've read only about theoretical advantages.
Quoted 11 lines
--
This message was sent on behalf of [email protected] at openSubscriber.com
http://www.opensubscriber.com/message/[email protected]/13421616.html_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
2010/2/20 Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]>:
Quoted 6 lines
Quoted 3 lines · [email protected] wrote:
What about this patch? It is possible to integrate it, at least in the experimental branch?
I asked you for at least a usecase when it makes a difference but till now I've read only about theoretical advantages.
It has been explained that using the NTFS UUID is about equivalent of using the volume label. If it is sufficient why are we using UUIDs at all? We can use the much more readable labels everywhere and get rid of those long and impractical UUIDs completely.
Thanks
Michal
Quoted 4 lines · Michal Suchanek
It has been explained that using the NTFS UUID is about equivalent of using the volume label. If it is sufficient why are we using UUIDs at all? We can use the much more readable labels everywhere and get rid of those long and impractical UUIDs completely.
Volume labels (in the general case; I don't know specifically about NTFS) are set by system administrators by hand. GRUB cannot assume that any filesystem has a volume label, or that they don't clash. (For example, Red Hat's installer used to have the unwise policy of setting labels to match the mount point; thus two Red Hat installations on the same machine would produce label collisions.)
The appropriate policy for use of labels is to permit them to be used when requested by the system administrator, but not to use them by default.
I posted an analysis of all the generic available methods for filesystem identification to debian-boot a while back:
http://lists.debian.org/debian-boot/2008/12/msg00338.html
Signature · 1 line
Colin Watson [[email protected]]
Quoted 2 lines
I asked you for at least a usecase when it makes a difference but till now I've read only about theoretical advantages.
Ok, my usecase is the following:
We are installing grub to EFI system partition and on the next load it must load itself (rmadisk&kernel) from Windows partiton (where our main product is installed). It need however to find the NTFS partition with our product, the only ways is GPT GUID.
Out of Linux world FS UUID is nothing, our main product works on Windows, and the only way to identify the partition correctly - GUID. UEFI spec also use GPT GUIDs in it's "device path", same as Windows.
grub2 is not for Linux load only.
--
This message was sent on behalf of [email protected] at openSubscriber.com
http://www.opensubscriber.com/message/[email protected]/13458994.html
Quoted 4 lines · [email protected] wrote:
Quoted 3 lines
I asked you for at least a usecase when it makes a difference but till now I've read only about theoretical advantages.
Quoted 8 lines
Ok, my usecase is the following:
We are installing grub to EFI system partition and on the next load it must load itself (rmadisk&kernel) from Windows partiton (where our main product is installed). It need however to find the NTFS partition with our product, the only ways is GPT GUID.Out of Linux world FS UUID is nothing, our main product works on Windows, and the only way to identify the partition correctly - GUID. UEFI spec also use GPT GUIDs in it's "device path", same as Windows.
grub2 is not for Linux load only.
I thought about this and decided that it's ok to have this functionality as long as it's implemented cleanly. In particular:
- It shouldn't be named "GPT GUID" but something like PARTITION GUID. If partition is GPT then GPT UUIDs are used, if it's msdos then nt-like UUIDs should be used and so on. You don't have to implement non-GPT but arcitecture must be clean
- It must not give any size increase of basic modules
- grub-probe must support it (trivial)
- Not used by default
Quoted 11 lines
--
This message was sent on behalf of [email protected] at openSubscriber.com
http://www.opensubscriber.com/message/[email protected]/13458994.html_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko