Add PARTUUID detection support
v10 cover Add PARTUUID detection support
Summary of Changes:
- Defined print_gpt_puid()
- Updated grub-probe.c to use print_gpt_guid()
- Renamed struct grub_gpt_part_type to struct grub_gpt_part_guid.
- Updated struct typedef to use grub_gpt_part_guid
- Replaced grub_gpt_part_type_t type with grub_gpt_part_guid_t in variable declarations.
- Changed grub_gpt_partentry.guid from a 16 byte array to grub_gpt_part_guid.
- Added PRINT_PARTUUID enum element to enum defined in util/grub-probe.c.
- Added "partuuid" string to targets array defined in util/grub-probe.c.
- Defined probe_partuuid() function.
- Added GRUB_DISABLE_LINUX_PARTUUID item to docs/grub/texi
- Defined GRUB_DEVICE_PARTUUID variable util/grub-mkconfig.in
- Updated exports to export GRUB_DEVICE_PARTUUID and GRUB_DISABLE_LINUX_PARATUUID variables.
- Updated rootfs detection logic in util/grub.d/10_linux.in to favor partition UUIDs when GRUB_DISABLE_LINUX_PARTUUID is not set to 'true' and no initramfs is found (this also includes cases where GRUB_DISABLE_LINUX_PARTUUID is unset) or when an initramfs is found and GRUB_DISABLE_LINUX_UUID is set to 'true'.
- Updated rootfs detection logic in util/grub.d/20_linux_xen.in to favor partition UUIDs when GRUB_DISABLE_LINUX_PARTUUID is not set to 'true' and no initramfs is found (this also includes cases where GRUB_DISABLE_LINUX_PARTUUID is unset) or when an initramfs is found and GRUB_DISABLE_LINUX_UUID is set to 'true'.
Changes from Patch v9:
- Merged optional patch with updage grub script template files patch
- Updated util/grub.d/20_linux_xen.in to use new partuuid logic
- Updated documentation on GRUB_DISABLE_LINUX_PARTUUID
Changes from Patch v8:
- Renamed GRUB_ENABLE_LINUX_PARTUUID to GRUB_DISABLE_LINUX_PARTUUID
- Updated the 10_linux logic so GRUB_ENABLE_LINUX_PARTUUID and GRUB_ENABLE_LINUX_UUID would behave more independently.
- Documented interactions of GRUB_DISABLE_LINUX_UUID, GRUB_DISABLE_LINUX_PARTUUID, and initramfs detection in commit message.
- Added optional patch that sets GRUB_DISABLE_LINUX_PARTUUID to true by default.
- Fixed merge conflicts between this patchset and upstream's master branch.
Changes from Patch v7:
- Changed checks in probe_partuuid() to use the variable 'p' instead of disk->partition
- Moved 'disk->partition = p;' assignment to inside the 'p & p->parent == NULL' statement
- Moved 'disk->partition = p->parent;' assignment to before partmap name checks.
- Fixed formatting issues.
- Copied Daniel Kiper's reviewed-by line to unaltered patches.
Changes from Patch v6:
- Corrected spelling and grammatical errors in description text for GRUB_ENABLE_LINUX_PARTUUID
- Moved disk->partition save & restore logic to beginning and end of probe_partuuid()
- Fixed formatting errors in probe_partuuid
Changes from Patch v5:
- Added sign-off by lines
- Fixed formatting errors found by Daniel Kiper
Changes from Patch v4:
- Updated grub.texi to reflect new behavior for GRUB_ENABLE_LINUX_PARTUUID
- Updated 10_linux.in logic to favor the PARTUUID when GRUB_ENABLE_LINUX_PARTUUID is enabled and GRUB_DISABLE_LINUX_UUID is disabled.
Changes from Patch v3:
- Removed flex-2.6.3 compatibility patch
- Removed Steve Kenton's patch
Changes from Patch v2:
- Added flex-2.6.3 compatibility patch
- Fixed a GPT partition read error
- Added Steve Kenton's patch
- Changed struct grub_part_gpt_type name to struct grub_part_gpt_part_guid
- Changed grub_part_gpt_type_t typedef name to grub_part_gpt_guid_t
- Added sprint_gpt_guid to Steve Kenton's patch
- Updated v1 and Steve Kenton's patch to use similar methods when reading partition GUIDs.
Changes from Patch v1:
- Added GRUB_ENABLE_LINUX_PARTUUID variable description to grub.texi
- Removed added gpt_part_guid copy logic from
grub_gpt_partition_map_iterate()
- Removed added NT disk signature copy logic from grub_partition_msdos_iterate()
- Removed modifications to partition number increment logic
- Removed added guid union definition.
- Added GRUB_ENABLE_LINUX_PARTUUID to grub-mkconfig.in export list
- Moved PRINT_GPT_PARTTYPE printing logic to print_gpt_guid() function in grub-probe.c
- Updated PRINT_GPT_PARTTYPE case to call print_gpt_guid() function in grub-probe.c.
- Created probe_partuuid() function in grub-probe.c
- Updated print == PRINT_PARTUUID check logic in probe() to call probe_partuuid().
- Updated UUID logic in 10_linux.in to enable root=PARTUUID feature only if GRUB_DISABLE_LINUX_UUID is not set to true, and GRUB_DEVICE_PARTUUID is not empty, GRUB_ENABLE_LINUX_PARTUUID is set to true.
Hello,
This is a request to add PARTUUID detection support grub-probe for MBR and GPT partition schemes. The Linux kernel supports mounting the root filesystem by Linux device name or by the Partition [GU]UID. GRUB's mkconfig, however, currently only supports specifying the rootfs in the kernel command-line by Linux device name unless an initramfs is also present. When an initramfs is present GRUB's mkconfig will set the kernel's root parameter value to either the Linux device name or to the filesystem [GU]UID.
Therefore, the only way to protect a Linux system from failing to boot when its Linux storage device names change is to either manually edit grub.cfg or /etc/default/grub and append root=PARTUUID=xxx to the command-line or create an initramfs that understands how to mount devices by filesystem [G]UID and let grub-mkconfig pass the filesystem [GU]UID to the initramfs.
The goal of this patch set is to enable root=PARTUUID=xxx support in grub-mkconfig, so that users don't have to manually edit /etc/default/grub or grub.cfg, or create an initramfs for the sole purpose of having a robust bootloader configuration for Linux.
Thanks,
Nicholas Vinson
Nicholas Vinson (4):
Centralize guid prints
Update grub_gpt_partentry
Add PARTUUID detection support to grub-probe
Update grub script template files
docs/grub.texi | 11 ++++++ grub-core/disk/ldm.c | 2 +- grub-core/partmap/gpt.c | 4 +- include/grub/gpt_partition.h | 8 ++-- util/grub-install.c | 2 +- util/grub-mkconfig.in | 3 ++ util/grub-probe.c | 76 +++++++++++++++++++++++++++++------- util/grub.d/10_linux.in | 22 +++++++++-- util/grub.d/20_linux_xen.in | 22 +++++++++-- 9 files changed, 121 insertions(+), 29 deletions(-)
Signature · 1 line
2.17.0
PATCH v10 1/4 Centralize guid prints
Define print_gpt_guid(), so there is a central function for printing GUID strings. This change is a precursor for later patches which rely on this logic.
--- util/grub-probe.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
util/grub-probe.c +15 -15
@@ -129,6 +129,20 @@ get_targets_string (void)return str; } +static int +print_gpt_guid (grub_gpt_part_guid_t guid) +{ + guid.data1 =grub_le_to_cpu32 (guid.data1); + guid.data2 =grub_le_to_cpu16 (guid.data2); + guid.data3 =grub_le_to_cpu16 (guid.data3); + +return grub_printf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" , + guid.data1, guid.data2, guid.data3, guid.data4[0 ], + guid.data4[1 ], guid.data4[2 ], guid.data4[3 ], + guid.data4[4 ], guid.data4[5 ], guid.data4[6 ], + guid.data4[7 ]); +} +static void do_print (const char *x,void *data) {
@@ -641,21 +655,7 @@ probe (const char *path, char **device_names, char delim)if (grub_disk_read (dev->disk, p->offset, p->index,sizeof (gptdata), &gptdata) ==0 ) - { -grub_gpt_part_type_t gpttype; - gpttype.data1 =grub_le_to_cpu32 (gptdata.type.data1); - gpttype.data2 =grub_le_to_cpu16 (gptdata.type.data2); - gpttype.data3 =grub_le_to_cpu16 (gptdata.type.data3); -grub_memcpy (gpttype.data4, gptdata.type.data4,8 ); - -grub_printf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" , - gpttype.data1, gpttype.data2, - gpttype.data3, gpttype.data4[0 ], - gpttype.data4[1 ], gpttype.data4[2 ], - gpttype.data4[3 ], gpttype.data4[4 ], - gpttype.data4[5 ], gpttype.data4[6 ], - gpttype.data4[7 ]); - } +print_gpt_guid (gptdata.type); dev->disk->partition = p; }putchar (delim);
Signature · 1 line
2.17.0
PATCH v10 2/4 Update grub_gpt_partentry
In reply to Nicholas VinsonRename grub_gpt_part_type to grub_gpt_part_guid and update grub_gpt_partentry to use this type for both the partition type GUID string and the partition GUID string entries. This change ensures that the two GUID fields are handled more consistently and helps to simplify the changes needed to add Linux partition GUID support.
--- grub-core/disk/ldm.c | 2 +- grub-core/partmap/gpt.c | 4 ++-- include/grub/gpt_partition.h | 8 ++++---- util/grub-install.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)
grub-core/disk/ldm.c +1 -1
@@ -135,7 +135,7 @@ msdos_has_ldm_partition (grub_disk_t dsk)return has_ldm; } -static const grub_gpt_part_type_t ldm_type =GRUB_GPT_PARTITION_TYPE_LDM ; +static const grub_gpt_part_guid_t ldm_type =GRUB_GPT_PARTITION_TYPE_LDM ;/* Helper for gpt_ldm_sector. */ static int
grub-core/partmap/gpt.c +2 -2
@@ -33,10 +33,10 @@ static grub_uint8_t grub_gpt_magic[8] = 0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54 }; -static const grub_gpt_part_type_t grub_gpt_partition_type_empty =GRUB_GPT_PARTITION_TYPE_EMPTY ; +static const grub_gpt_part_guid_t grub_gpt_partition_type_empty =GRUB_GPT_PARTITION_TYPE_EMPTY ;#ifdef GRUB_UTIL -static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot =GRUB_GPT_PARTITION_TYPE_BIOS_BOOT ; +static const grub_gpt_part_guid_t grub_gpt_partition_type_bios_boot =GRUB_GPT_PARTITION_TYPE_BIOS_BOOT ;#endif /* 512 << 7 = 65536 byte sectors. */
include/grub/gpt_partition.h +4 -4
@@ -22,14 +22,14 @@#include <grub/types.h> #include <grub/partition.h> -struct grub_gpt_part_type +struct grub_gpt_part_guid {grub_uint32_t data1;grub_uint16_t data2;grub_uint16_t data3;grub_uint8_t data4[8 ]; }GRUB_PACKED ; -typedef struct grub_gpt_part_type grub_gpt_part_type_t ; +typedef struct grub_gpt_part_guid grub_gpt_part_guid_t ;#define GRUB_GPT_PARTITION_TYPE_EMPTY \ { 0x0, 0x0, 0x0, \
@@ -70,8 +70,8 @@ struct grub_gpt_headerstruct grub_gpt_partentry { -grub_gpt_part_type_t type; -grub_uint8_t guid[16 ]; +grub_gpt_part_guid_t type; +grub_gpt_part_guid_t guid;grub_uint64_t start;grub_uint64_t end;grub_uint64_t attrib;
util/grub-install.c +1 -1
@@ -714,7 +714,7 @@ is_prep_partition (grub_device_t dev)if (grub_disk_read (dev->disk, p->offset, p->index,sizeof (gptdata), &gptdata) ==0 ) { -const grub_gpt_part_type_t template = { +const grub_gpt_part_guid_t template = {grub_cpu_to_le32_compile_time (0x9e1a2d38 ),grub_cpu_to_le16_compile_time (0xc612 ),grub_cpu_to_le16_compile_time (0x4316 ),
Signature · 1 line
2.17.0
PATCH v10 3/4 Add PARTUUID detection support to grub-probe
In reply to Nicholas VinsonAdd PARTUUID detection support grub-probe for MBR and GPT partition schemes.
--- util/grub-probe.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
util/grub-probe.c +46 -0
@@ -28,6 +28,7 @@#include <grub/partition.h> #include <grub/msdos_partition.h> #include <grub/gpt_partition.h> +#include <grub/i386/pc/boot.h> #include <grub/emu/hostdisk.h> #include <grub/emu/getroot.h> #include <grub/term.h>
@@ -62,6 +63,7 @@ enum {PRINT_DRIVE ,PRINT_DEVICE ,PRINT_PARTMAP , +PRINT_PARTUUID ,PRINT_ABSTRACTION ,PRINT_CRYPTODISK_UUID , PRINT_HINT_STR,
@@ -85,6 +87,7 @@ static const char *targets[] = [PRINT_DRIVE] = "drive", [PRINT_DEVICE] = "device", [PRINT_PARTMAP] = "partmap", + [PRINT_PARTUUID] = "partuuid", [PRINT_ABSTRACTION] = "abstraction", [PRINT_CRYPTODISK_UUID] = "cryptodisk_uuid", [PRINT_HINT_STR] = "hints_string",
@@ -181,6 +184,43 @@ probe_partmap (grub_disk_t disk, char delim) } } +static void +probe_partuuid (grub_disk_t disk,char delim) +{ +grub_partition_t p = disk->partition; + +/* +* Nested partitions not supported for now. +* Non-nested partitions must have disk->partition->parent == NULL +*/ +if (p && p->parent ==NULL ) + { + disk->partition = p->parent; +if (strcmp (p->partmap->name,"msdos" ) ==0 ) + { +/* +* The partition GUID for MSDOS is the partition number (starting +* with 1) prepended with the NT disk signature. +*/ +grub_uint32_t nt_disk_sig; + +if (grub_disk_read (disk,0 ,GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC , +sizeof (nt_disk_sig), &nt_disk_sig) ==0 ) +grub_printf ("%08x-%02x" , +grub_le_to_cpu32 (nt_disk_sig),1 + p->number); + } +else if (strcmp (p->partmap->name,"gpt" ) ==0 ) + { +struct grub_gpt_partentry gptdata; + +if (grub_disk_read (disk, p->offset, p->index, +sizeof (gptdata), &gptdata) ==0 ) +print_gpt_guid (gptdata.guid); + } + disk->partition = p; + } +} +static void probe_cryptodisk_uuid (grub_disk_t disk,char delim) {
@@ -635,6 +675,12 @@ probe (const char *path, char **device_names, char delim)/* Check if dev->disk itself is contained in a partmap. */ probe_partmap (dev->disk, delim); + else if (print == PRINT_PARTUUID) + { +probe_partuuid (dev->disk, delim); +putchar (delim); + } + else if (print == PRINT_MSDOS_PARTTYPE) { if (dev->disk->partition
Signature · 1 line
2.17.0
PATCH v10 4/4 Update grub script template files
In reply to Nicholas VinsonUpdate grub-mkconfig.in and 10_linux.in to support grub-probe's new partuuid target. Update grub.texi documentation. The following table shows how GRUB_DISABLE_LINUX_UUID, GRUB_DISABLE_LINUX_PARTUUID, and initramfs detection interact:
Initramfs GRUB_DISABLE_LINUX_PARTUUID GRUB_DISABLE_LINUX_UUID Linux Root detected Set Set ID Method
false false false part UUID false false true part UUID false true false dev name false true true dev name true false false fs UUID true false true part UUID true true false fs UUID true true true dev name
Note: GRUB_DISABLE_LINUX_PARTUUID and GRUB_DISABLE_LINUX_UUID equate to
'false' when unset or set to any value other than 'true'. GRUB_DISABLE_LINUX_PARTUUID defaults to 'true'.
--- docs/grub.texi | 67 ++++++++++++++++++++++++++++++++++--- util/grub-mkconfig.in | 3 ++ util/grub.d/10_linux.in | 22 ++++++++++-- util/grub.d/20_linux_xen.in | 22 ++++++++++-- 4 files changed, 104 insertions(+), 10 deletions(-)
docs/grub.texi +63 -4
@@ -1214,10 +1214,11 @@ GRUB is configured using @file{grub.cfg}, usually located under need to write the whole thing by hand. @menu -* Simple configuration:: Recommended for most users -* Shell-like scripting:: For power users and developers -* Multi-boot manual config:: For non-standard multi-OS scenarios -* Embedded configuration:: Embedding a configuration file into GRUB +* Simple configuration:: Recommended for most users +* Root Identifcation Heuristics:: Summary on how the root file system is identified. +* Shell-like scripting:: For power users and developers +* Multi-boot manual config:: For non-standard multi-OS scenarios +* Embedded configuration:: Embedding a configuration file into GRUB @end menu
@@ -1425,6 +1426,17 @@ the Linux kernel, using a @samp{root=UUID=...} kernel parameter. This is usually more reliable, but in some cases it may not be appropriate. To disable the use of UUIDs, set this option to @samp{true}. +@item GRUB_DISABLE_LINUX_PARTUUID +If @command{grub-mkconfig} cannot identify the root filesystem via its +universally-unique indentifier (UUID), @command{grub-mkconfig} can use the UUID +of the partition containing the filesystem to identify the root filesystem to +the Linux kernel via a @samp{root=PARTUUID=...} kernel parameter. This is not +as reliable as using the filesystem UUID, but is more reliable than using the +Linux device names. When @samp{GRUB_DISABLE_LINUX_PARTUUID} is set to +@samp{false}, the Linux kernel version must be 2.6.37 (3.10 for systems using +the MSDOS partition scheme) or newer. This option defaults to @samp{true}. To +enable the use of partition UUIDs, set this option to @samp{false}. + @item GRUB_DISABLE_RECOVERY If this option is set to @samp{true}, disable the generation of recovery mode menu entries.
@@ -1556,6 +1568,53 @@ edit the scripts in @file{/etc/grub.d} directly. menu entries; simply type the menu entries you want to add at the end of that file, making sure to leave at least the first two lines intact. +@node Root Identifcation Heuristics +@section Root Identifcation Heuristics +If the target operating system uses the Linux kernel, @command{grub-mkconfig} +attempts to identify the root file system via a heuristic algoirthm. This +algorithm selects the identification method of the root file system by +considering three factors. The first is if an initrd for the target operating +system is also present. The second is @samp{GRUB_DISABLE_LINUX_UUID} and if set +to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file +system by its UUID. The third is @samp{GRUB_DISABLE_LINUX_PARTUUID} and if set +to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file +system via the UUID of its enclosing partition. If the variables are assigned +any other value, that value is considered equivalent to @samp{false}. The +variables are also considered to be set to @samp{false} if they are not set. + +When booting, the Linux kernel will delegate the task of mounting the root +filesystem to the initrd. Most initrd images determine the root file system by +checking the Linux kernel's command-line for the @samp{root} key and use its +value as the identification method of the root file system. To improve the +reliability of booting, most initrd images also allow the root file system to be +identified by its UUID. Because of this behavior, the @command{grub-mkconfig} +command will set @samp{root} to @samp{root=UUID=...} to provide the initrd with +the filesystem UUID of the root file system. + +If no initrd is detected or @samp{GRUB_DISABLE_LINUX_UUID} is set then +@command{grub-command} will identify the root filesystem by setting the kernel +command-line variable @samp{root} to @samp{root=PARTUUID=...} unless +@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true}. If +@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true}, +@command{grub-command} will identify by its LInux device name. + +The following table summarizes the behavior of the @command{grub-mkconfig} +command. + +@multitable {detected} {GRUB_DISABLE_LINUX_PARTUUID} {GRUB_DISABLE_LINUX_UUID} {Linux Root} +@headitem Initrd detected @tab GRUB_DISABLE_LINUX_PARTUUID Set To @tab GRUB_DISABLE_LINUX_UUID Set To @tab Linux Root ID Method +@item false @tab false @tab false @tab part UUID +@item false @tab false @tab true @tab part UUID +@item false @tab true @tab false @tab dev name +@item false @tab true @tab true @tab dev name +@item true @tab false @tab false @tab fs UUID +@item true @tab false @tab true @tab part UUID +@item true @tab true @tab false @tab fs UUID +@item true @tab true @tab true @tab dev name +@end multitable + +Remember, @samp{GRUB_DISABLE_LINUX_PARTUUID} and @samp{GRUB_DISABLE_LINUX_UUID} +are also considered to be set to @samp{false} when they are unset. @node Shell-like scripting @section Writing full configuration files directly
util/grub-mkconfig.in +3 -0
@@ -134,6 +134,7 @@ fi # Device containing our userland. Typically used for root= parameter. GRUB_DEVICE="`${grub_probe} --target=device /`" GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true +GRUB_DEVICE_PARTUUID="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2> /dev/null`" || true # Device containing our /boot partition. Usually the same as GRUB_DEVICE. GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
@@ -188,6 +189,7 @@ if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub # override them. export GRUB_DEVICE \ GRUB_DEVICE_UUID \ + GRUB_DEVICE_PARTUUID \ GRUB_DEVICE_BOOT \ GRUB_DEVICE_BOOT_UUID \ GRUB_FS \
@@ -223,6 +225,7 @@ export GRUB_DEFAULT \ GRUB_TERMINAL_OUTPUT \ GRUB_SERIAL_COMMAND \ GRUB_DISABLE_LINUX_UUID \ + GRUB_DISABLE_LINUX_PARTUUID \ GRUB_DISABLE_RECOVERY \ GRUB_VIDEO_BACKEND \ GRUB_GFXMODE \
util/grub.d/10_linux.in +19 -3
@@ -43,12 +43,22 @@ case ${GRUB_DEVICE} in ;; esac +# Default to disabling partition uuid support to maintian compatibility with +# older kernels. +GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true} + # btrfs may reside on multiple devices. We cannot pass them as value of root= parameter # and mounting btrfs requires user space scanning, so force UUID in this case. -if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ - || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ +if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ) \ + || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ + && [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \ + || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ + && ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \ || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then LINUX_ROOT_DEVICE=${GRUB_DEVICE} +elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \ + || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then + LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} fi
@@ -242,7 +252,13 @@ while [ "x$list" != "x" ] ; do if test -z "${initramfs}" && test -z "${initrd_real}" ; then # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs. Since there's # no initrd or builtin initramfs, it can't work here. - linux_root_device_thisversion=${GRUB_DEVICE} + if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \ + || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then + + linux_root_device_thisversion=${GRUB_DEVICE} + else + linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID} + fi fi if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
util/grub.d/20_linux_xen.in +19 -3
@@ -43,12 +43,22 @@ case ${GRUB_DEVICE} in ;; esac +# Default to disabling partition uuid support to maintian compatibility with +# older kernels. +GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true} + # btrfs may reside on multiple devices. We cannot pass them as value of root= parameter # and mounting btrfs requires user space scanning, so force UUID in this case. -if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ - || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ +if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \ + || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ + && [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \ + || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ + && ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \ || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then LINUX_ROOT_DEVICE=${GRUB_DEVICE} +elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \ + || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then + LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} fi
@@ -246,7 +256,13 @@ while [ "x${xen_list}" != "x" ] ; do gettext_printf "Found initrd image: %s\n" "${dirname}/${initrd}" >&2 else # "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here. - linux_root_device_thisversion=${GRUB_DEVICE} + if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \ + || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then + + linux_root_device_thisversion=${GRUB_DEVICE} + else + linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID} + fi fi if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
Signature · 1 line
2.17.0
Re: [GRUB PARTUUID PATCH V10 4/4] Update grub script template files
Quoted 84 lines · Nicholas Vinson
Update grub-mkconfig.in and 10_linux.in to support grub-probe's new partuuid target. Update grub.texi documentation. The following table shows how
GRUB_DISABLE_LINUX_UUID,GRUB_DISABLE_LINUX_PARTUUID, and initramfs detection interact:Initramfs GRUB_DISABLE_LINUX_PARTUUID GRUB_DISABLE_LINUX_UUID Linux Root detected Set Set ID Methodfalse false false part UUID false false true part UUID false true false dev name false true true dev name true false false fs UUID true false true part UUID true true false fs UUID true true true dev nameNote:
GRUB_DISABLE_LINUX_PARTUUIDandGRUB_DISABLE_LINUX_UUIDequate to
'false' when unset or set to any value other than 'true'.GRUB_DISABLE_LINUX_PARTUUIDdefaults to 'true'.Signed-off-by Nicholas Vinson <[email protected]>--- docs/grub.texi | 67 ++++++++++++++++++++++++++++++++++--- util/grub-mkconfig.in | 3 ++ util/grub.d/10_linux.in | 22 ++++++++++-- util/grub.d/20_linux_xen.in | 22 ++++++++++-- 4 files changed, 104 insertions(+), 10 deletions(-)docs/grub.texi +30
-4@@ -1214,10 +1214,11 @@ GRUB is configured using @file{grub.cfg}, usually located under need to write the whole thing by hand. @menu -* Simple configuration:: Recommended for most users -* Shell-like scripting:: For power users and developers -* Multi-boot manual config:: For non-standard multi-OS scenarios -* Embedded configuration:: Embedding a configuration file into GRUB +* Simple configuration:: Recommended for most users +* Root Identifcation Heuristics:: Summary on how the root file system is identified. +* Shell-like scripting:: For power users and developers +* Multi-boot manual config:: For non-standard multi-OS scenarios +* Embedded configuration:: Embedding a configuration file into GRUB @end menu@@ -1425,6 +1426,17 @@ the Linux kernel, using a @samp{root=UUID=...} kernel parameter. This is usually more reliable, but in some cases it may not be appropriate. To disable the use of UUIDs, set this option to @samp{true}. +@item GRUB_DISABLE_LINUX_PARTUUID +If @command{grub-mkconfig} cannot identify the root filesystem via its +universally-unique indentifier (UUID), @command{grub-mkconfig} can use the UUID +of the partition containing the filesystem to identify the root filesystem to +the Linux kernel via a @samp{root=PARTUUID=...} kernel parameter. This is not +as reliable as using the filesystem UUID, but is more reliable than using the +Linux device names. When @samp{GRUB_DISABLE_LINUX_PARTUUID} is set to +@samp{false}, the Linux kernel version must be 2.6.37 (3.10 for systems using +the MSDOS partition scheme) or newer. This option defaults to @samp{true}. To +enable the use of partition UUIDs, set this option to @samp{false}. + @item GRUB_DISABLE_RECOVERY If this option is set to @samp{true}, disable the generation of recovery mode menu entries.@@ -1556,6 +1568,53 @@ edit the scripts in @file{/etc/grub.d} directly. menu entries; simply type the menu entries you want to add at the end of that file, making sure to leave at least the first two lines intact. +@node Root Identifcation Heuristics +@section Root Identifcation Heuristics +If the target operating system uses the Linux kernel, @command{grub-mkconfig} +attempts to identify the root file system via a heuristic algoirthm. This +algorithm selects the identification method of the root file system by +considering three factors. The first is if an initrd for the target operating +system is also present. The second is @samp{GRUB_DISABLE_LINUX_UUID} and if set +to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file +system by its UUID. The third is @samp{GRUB_DISABLE_LINUX_PARTUUID} and if set +to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file +system via the UUID of its enclosing partition. If the variables are assigned +any other value, that value is considered equivalent to @samp{false}. The +variables are also considered to be set to @samp{false} if they are not set. +
docs/grub.texi edit the scripts in @file{/etc/grub.d} directly. · line 1594
Quoted 10 lines
docs/grub.texi +10
-0+When booting, the Linux kernel will delegate the task of mounting the root +filesystem to the initrd. Most initrd images determine the root file system by +checking the Linux kernel's command-line for the @samp{root} key and use its +value as the identification method of the root file system. To improve the +reliability of booting, most initrd images also allow the root file system to be +identified by its UUID. Because of this behavior, the @command{grub-mkconfig} +command will set @samp{root} to @samp{root=UUID=...} to provide the initrd with +the filesystem UUID of the root file system. + +If no initrd is detected or @samp{GRUB_DISABLE_LINUX_UUID} is set then
s/set/set to @samp{true}/?
docs/grub.texi edit the scripts in @file{/etc/grub.d} directly. · line 1599
Quoted 5 lines
docs/grub.texi +5
-0+@command{grub-command} will identify the root filesystem by setting the kernel +command-line variable @samp{root} to @samp{root=PARTUUID=...} unless +@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true}. If +@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true}, +@command{grub-command} will identify by its LInux device name.
s/LInux/Linux/g
docs/grub.texi edit the scripts in @file{/etc/grub.d} directly. · line 1607
Quoted 8 lines
docs/grub.texi +8
-0+ +The following table summarizes the behavior of the @command{grub-mkconfig} +command. + +@multitable {detected} {GRUB_DISABLE_LINUX_PARTUUID} {GRUB_DISABLE_LINUX_UUID} {Linux Root} +@headitem Initrd detected @tab GRUB_DISABLE_LINUX_PARTUUID Set To @tab GRUB_DISABLE_LINUX_UUID Set To @tab Linux Root ID Method +@item false @tab false @tab false @tab part UUID +@item false @tab false @tab true @tab part UUID
I hope that you have tested these two settings and they work. If yes then I am happy with all the patches. If there are no objections I will commit all of them in a week or so. I will fix both nitpicks listed above just before commit.
Daniel
Re: [GRUB PARTUUID PATCH V10 4/4] Update grub script template files
Quoted 89 lines · Daniel Kiper
Quoted 88 lines · Nicholas Vinson
Update grub-mkconfig.in and 10_linux.in to support grub-probe's new partuuid target. Update grub.texi documentation. The following table shows how
GRUB_DISABLE_LINUX_UUID,GRUB_DISABLE_LINUX_PARTUUID, and initramfs detection interact:Initramfs GRUB_DISABLE_LINUX_PARTUUID GRUB_DISABLE_LINUX_UUID Linux Root detected Set Set ID Methodfalse false false part UUID false false true part UUID false true false dev name false true true dev name true false false fs UUID true false true part UUID true true false fs UUID true true true dev nameNote:
GRUB_DISABLE_LINUX_PARTUUIDandGRUB_DISABLE_LINUX_UUIDequate to
'false' when unset or set to any value other than 'true'.GRUB_DISABLE_LINUX_PARTUUIDdefaults to 'true'.Signed-off-by Nicholas Vinson <[email protected]>--- docs/grub.texi | 67 ++++++++++++++++++++++++++++++++++--- util/grub-mkconfig.in | 3 ++ util/grub.d/10_linux.in | 22 ++++++++++-- util/grub.d/20_linux_xen.in | 22 ++++++++++-- 4 files changed, 104 insertions(+), 10 deletions(-)docs/grub.texi +34
-4@@ -1214,10 +1214,11 @@ GRUB is configured using @file{grub.cfg}, usually located under need to write the whole thing by hand. @menu -* Simple configuration:: Recommended for most users -* Shell-like scripting:: For power users and developers -* Multi-boot manual config:: For non-standard multi-OS scenarios -* Embedded configuration:: Embedding a configuration file into GRUB +* Simple configuration:: Recommended for most users +* Root Identifcation Heuristics:: Summary on how the root file system is identified. +* Shell-like scripting:: For power users and developers +* Multi-boot manual config:: For non-standard multi-OS scenarios +* Embedded configuration:: Embedding a configuration file into GRUB @end menu@@ -1425,6 +1426,17 @@ the Linux kernel, using a @samp{root=UUID=...} kernel parameter. This is usually more reliable, but in some cases it may not be appropriate. To disable the use of UUIDs, set this option to @samp{true}. +@item GRUB_DISABLE_LINUX_PARTUUID +If @command{grub-mkconfig} cannot identify the root filesystem via its +universally-unique indentifier (UUID), @command{grub-mkconfig} can use the UUID +of the partition containing the filesystem to identify the root filesystem to +the Linux kernel via a @samp{root=PARTUUID=...} kernel parameter. This is not +as reliable as using the filesystem UUID, but is more reliable than using the +Linux device names. When @samp{GRUB_DISABLE_LINUX_PARTUUID} is set to +@samp{false}, the Linux kernel version must be 2.6.37 (3.10 for systems using +the MSDOS partition scheme) or newer. This option defaults to @samp{true}. To +enable the use of partition UUIDs, set this option to @samp{false}. + @item GRUB_DISABLE_RECOVERY If this option is set to @samp{true}, disable the generation of recovery mode menu entries.@@ -1556,6 +1568,53 @@ edit the scripts in @file{/etc/grub.d} directly. menu entries; simply type the menu entries you want to add at the end of that file, making sure to leave at least the first two lines intact. +@node Root Identifcation Heuristics +@section Root Identifcation Heuristics +If the target operating system uses the Linux kernel, @command{grub-mkconfig} +attempts to identify the root file system via a heuristic algoirthm. This +algorithm selects the identification method of the root file system by +considering three factors. The first is if an initrd for the target operating +system is also present. The second is @samp{GRUB_DISABLE_LINUX_UUID} and if set +to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file +system by its UUID. The third is @samp{GRUB_DISABLE_LINUX_PARTUUID} and if set +to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file +system via the UUID of its enclosing partition. If the variables are assigned +any other value, that value is considered equivalent to @samp{false}. The +variables are also considered to be set to @samp{false} if they are not set. + +When booting, the Linux kernel will delegate the task of mounting the root +filesystem to the initrd. Most initrd images determine the root file system by +checking the Linux kernel's command-line for the @samp{root} key and use its +value as the identification method of the root file system. To improve the
Quoted 8 lines
docs/grub.texi edit the scripts in @file{/etc/grub.d} directly. · line 1594
Quoted 6 lines
docs/grub.texi +6
-0+reliability of booting, most initrd images also allow the root file system to be +identified by its UUID. Because of this behavior, the @command{grub-mkconfig} +command will set @samp{root} to @samp{root=UUID=...} to provide the initrd with +the filesystem UUID of the root file system. + +If no initrd is detected or @samp{GRUB_DISABLE_LINUX_UUID} is set thens/set/set to @samp{true}/?
Yes. Thanks.
Quoted 8 lines
docs/grub.texi edit the scripts in @file{/etc/grub.d} directly. · line 1599
Quoted 6 lines
docs/grub.texi +5
-0+@command{grub-command} will identify the root filesystem by setting the kernel +command-line variable @samp{root} to @samp{root=PARTUUID=...} unless +@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true}. If +@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true}, +@command{grub-command} will identify by its LInux device name.s/LInux/Linux/g
ack.
Quoted 14 lines
docs/grub.texi edit the scripts in @file{/etc/grub.d} directly. · line 1607
Quoted 9 lines
docs/grub.texi +8
-0+ +The following table summarizes the behavior of the @command{grub-mkconfig} +command. + +@multitable {detected} {GRUB_DISABLE_LINUX_PARTUUID} {GRUB_DISABLE_LINUX_UUID} {Linux Root} +@headitem Initrd detected @tab GRUB_DISABLE_LINUX_PARTUUID Set To @tab GRUB_DISABLE_LINUX_UUID Set To @tab Linux Root ID Method +@item false @tab false @tab false @tab part UUID +@item false @tab false @tab true @tab part UUIDI hope that you have tested these two settings and they work. If yes then I am happy with all the patches. If there are no objections I will commit all of them in a week or so. I will fix both nitpicks listed above just before commit.
I did. I've added a test script and its output at the bottom of this email.
Thanks,
Nicholas Vinson
Quoted 3 lines
Daniel
==========test.sh
==========
#/bin/sh
[[ -f Makefile ]] && make distclean &>/dev/null
echo "Configuring GRUB..."
./configure --prefix=$PWD/image CFLAGS="-Wno-error" --with-platform=efi
&>/dev/null \
|| { echo "configure failed"; exit 1; }echo "Building GRUB..."
make -j9 &>/dev/null || { echo "make failed"; exit 1; }
echo "Installing GRUB..."
make install &>/dev/null; echo $? || { echo "make install failed"; exit 1; }
GRUB_MKCONFIG="$PWD/image/sbin/grub-mkconfig" echo "Disabling submenu and recovery entries..." export GRUB_DISABLE_SUBMENU=y GRUB_DISABLE_RECOVERY=true
rm -f /boot/initramfs*
rm -f /boot/*xen*
echo ""
echo "****************************************"
echo "* *" echo "* 10_linux script test *" echo "* *"
echo "****************************************"
echo ""
echo "No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=false"
export GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=false echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+linux\|[12]0_linux')"
echo ""
echo "No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=true"
export GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=true echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+linux\|[12]0_linux')"
echo ""
echo "No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=false"
export GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=false echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+linux\|[12]0_linux')"
echo ""
echo "No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=true"
export GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=true echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+linux\|[12]0_linux')"
touch /boot/initramfs-4.16.2-gentoo.img
echo ""
echo "INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=false"
export GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=false echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+linux\|[12]0_linux')"
echo ""
echo "INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=true"
export GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=true echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+linux\|[12]0_linux')"
echo ""
echo "INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=false"
export GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=false echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+linux\|[12]0_linux')"
echo ""
echo "INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=true"
export GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=true echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+linux\|[12]0_linux')"
rm -f /boot/initramfs*
cp /boot/config-4.16.2-gentoo{,.orig}
echo "CONFIG_XEN_DOM0=y" >> /boot/config-4.16.2-gentoo touch /boot/xen
echo ""
echo "****************************************"
echo "* *" echo "* 20_linux script test *" echo "* *"
echo "****************************************"
echo ""
echo ""
echo "No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=false"
export GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=false echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+module\|[12]0_linux')"
echo ""
echo "No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=true"
export GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=true echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+module\|[12]0_linux')"
echo ""
echo "No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=false"
export GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=false echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+module\|[12]0_linux')"
echo ""
echo "No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=true"
export GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=true echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+module\|[12]0_linux')"
touch /boot/initramfs-4.16.2-gentoo.img
echo ""
echo "INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=false"
export GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=false echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+module\|[12]0_linux')"
echo ""
echo "INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=true"
export GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=true echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+module\|[12]0_linux')"
echo ""
echo "INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=false"
export GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=false echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+module\|[12]0_linux')"
echo ""
echo "INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=true"
export GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=true echo "$($GRUB_MKCONFIG 2>/dev/null | grep '[[:space:]]\+module\|[12]0_linux')"
rm -f /boot/initramfs*
rm /boot/xen
mv /boot/config-4.16.2-gentoo{.orig,}
==========
test.log
==========
Configuring GRUB...
Building GRUB...
Installing GRUB...
0
Disabling submenu and recovery entries...
****************************************
* * * 10_linux script test * * *
****************************************
No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=false ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ###
linux /vmlinuz-4.16.2-gentoo
root=PARTUUID=ff807b48-63c7-41ff-a0b4-0de6b83278b9 ro ### END /data/nvinson/grub/image/etc/grub.d/10_linux ### ### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ### ### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=true ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ###
linux /vmlinuz-4.16.2-gentoo
root=PARTUUID=ff807b48-63c7-41ff-a0b4-0de6b83278b9 ro ### END /data/nvinson/grub/image/etc/grub.d/10_linux ### ### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ### ### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=false ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ###
linux /vmlinuz-4.16.2-gentoo root=/dev/sdg2 ro
### END /data/nvinson/grub/image/etc/grub.d/10_linux ### ### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ### ### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=true ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ###
linux /vmlinuz-4.16.2-gentoo root=/dev/sdg2 ro
### END /data/nvinson/grub/image/etc/grub.d/10_linux ### ### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ### ### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=false ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ###
linux /vmlinuz-4.16.2-gentoo
root=UUID=962d87b1-d7b4-465a-9ea7-01c6a20439a5 ro ### END /data/nvinson/grub/image/etc/grub.d/10_linux ### ### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ### ### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=true ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ###
linux /vmlinuz-4.16.2-gentoo
root=PARTUUID=ff807b48-63c7-41ff-a0b4-0de6b83278b9 ro ### END /data/nvinson/grub/image/etc/grub.d/10_linux ### ### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ### ### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=false ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ###
linux /vmlinuz-4.16.2-gentoo
root=UUID=962d87b1-d7b4-465a-9ea7-01c6a20439a5 ro ### END /data/nvinson/grub/image/etc/grub.d/10_linux ### ### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ### ### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=true ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ###
linux /vmlinuz-4.16.2-gentoo root=/dev/sdg2 ro
### END /data/nvinson/grub/image/etc/grub.d/10_linux ### ### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ### ### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
****************************************
* * * 20_linux script test * * *
****************************************
No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=false ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ###
### END /data/nvinson/grub/image/etc/grub.d/10_linux ###
### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
module /vmlinuz-4.16.2-gentoo placeholder
root=PARTUUID=ff807b48-63c7-41ff-a0b4-0de6b83278b9 ro
### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=true ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ###
### END /data/nvinson/grub/image/etc/grub.d/10_linux ###
### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
module /vmlinuz-4.16.2-gentoo placeholder
root=PARTUUID=ff807b48-63c7-41ff-a0b4-0de6b83278b9 ro
### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=false ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ###
### END /data/nvinson/grub/image/etc/grub.d/10_linux ###
### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
module /vmlinuz-4.16.2-gentoo placeholder root=/dev/sdg2 ro
### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
No INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=true ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ###
### END /data/nvinson/grub/image/etc/grub.d/10_linux ###
### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
module /vmlinuz-4.16.2-gentoo placeholder root=/dev/sdg2 ro
### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=false ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ### ### END /data/nvinson/grub/image/etc/grub.d/10_linux ###
### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
module /vmlinuz-4.16.2-gentoo placeholder
root=UUID=962d87b1-d7b4-465a-9ea7-01c6a20439a5 ro
module --nounzip /initramfs-4.16.2-gentoo.img
### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=false GRUB_DISABLE_LINUX_UUID=true ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ### ### END /data/nvinson/grub/image/etc/grub.d/10_linux ###
### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
module /vmlinuz-4.16.2-gentoo placeholder
root=PARTUUID=ff807b48-63c7-41ff-a0b4-0de6b83278b9 ro
module --nounzip /initramfs-4.16.2-gentoo.img
### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=false ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ### ### END /data/nvinson/grub/image/etc/grub.d/10_linux ###
### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
module /vmlinuz-4.16.2-gentoo placeholder
root=UUID=962d87b1-d7b4-465a-9ea7-01c6a20439a5 ro
module --nounzip /initramfs-4.16.2-gentoo.img
### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
INITRAMFS GRUB_DISABLE_LINUX_PARTUUID=true GRUB_DISABLE_LINUX_UUID=true ### BEGIN /data/nvinson/grub/image/etc/grub.d/10_linux ### ### END /data/nvinson/grub/image/etc/grub.d/10_linux ###
### BEGIN /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
module /vmlinuz-4.16.2-gentoo placeholder root=/dev/sdg2 ro module --nounzip /initramfs-4.16.2-gentoo.img
### END /data/nvinson/grub/image/etc/grub.d/20_linux_xen ###
Re: [GRUB PARTUUID PATCH V10 4/4] Update grub script template files
Quoted 127 lines · Nick Vinson
Quoted 89 lines · Daniel Kiper
Quoted 88 lines · Nicholas Vinson
Update grub-mkconfig.in and 10_linux.in to support grub-probe's new partuuid target. Update grub.texi documentation. The following table shows how
GRUB_DISABLE_LINUX_UUID,GRUB_DISABLE_LINUX_PARTUUID, and initramfs detection interact:Initramfs GRUB_DISABLE_LINUX_PARTUUID GRUB_DISABLE_LINUX_UUID Linux Root detected Set Set ID Methodfalse false false part UUID false false true part UUID false true false dev name false true true dev name true false false fs UUID true false true part UUID true true false fs UUID true true true dev nameNote:
GRUB_DISABLE_LINUX_PARTUUIDandGRUB_DISABLE_LINUX_UUIDequate to
'false' when unset or set to any value other than 'true'.GRUB_DISABLE_LINUX_PARTUUIDdefaults to 'true'.Signed-off-by Nicholas Vinson <[email protected]>--- docs/grub.texi | 67 ++++++++++++++++++++++++++++++++++--- util/grub-mkconfig.in | 3 ++ util/grub.d/10_linux.in | 22 ++++++++++-- util/grub.d/20_linux_xen.in | 22 ++++++++++-- 4 files changed, 104 insertions(+), 10 deletions(-)docs/grub.texi +34
-4@@ -1214,10 +1214,11 @@ GRUB is configured using @file{grub.cfg}, usually located under need to write the whole thing by hand. @menu -* Simple configuration:: Recommended for most users -* Shell-like scripting:: For power users and developers -* Multi-boot manual config:: For non-standard multi-OS scenarios -* Embedded configuration:: Embedding a configuration file into GRUB +* Simple configuration:: Recommended for most users +* Root Identifcation Heuristics:: Summary on how the root file system is identified. +* Shell-like scripting:: For power users and developers +* Multi-boot manual config:: For non-standard multi-OS scenarios +* Embedded configuration:: Embedding a configuration file into GRUB @end menu@@ -1425,6 +1426,17 @@ the Linux kernel, using a @samp{root=UUID=...} kernel parameter. This is usually more reliable, but in some cases it may not be appropriate. To disable the use of UUIDs, set this option to @samp{true}. +@item GRUB_DISABLE_LINUX_PARTUUID +If @command{grub-mkconfig} cannot identify the root filesystem via its +universally-unique indentifier (UUID), @command{grub-mkconfig} can use the UUID +of the partition containing the filesystem to identify the root filesystem to +the Linux kernel via a @samp{root=PARTUUID=...} kernel parameter. This is not +as reliable as using the filesystem UUID, but is more reliable than using the +Linux device names. When @samp{GRUB_DISABLE_LINUX_PARTUUID} is set to +@samp{false}, the Linux kernel version must be 2.6.37 (3.10 for systems using +the MSDOS partition scheme) or newer. This option defaults to @samp{true}. To +enable the use of partition UUIDs, set this option to @samp{false}. + @item GRUB_DISABLE_RECOVERY If this option is set to @samp{true}, disable the generation of recovery mode menu entries.@@ -1556,6 +1568,53 @@ edit the scripts in @file{/etc/grub.d} directly. menu entries; simply type the menu entries you want to add at the end of that file, making sure to leave at least the first two lines intact. +@node Root Identifcation Heuristics +@section Root Identifcation Heuristics +If the target operating system uses the Linux kernel, @command{grub-mkconfig} +attempts to identify the root file system via a heuristic algoirthm. This +algorithm selects the identification method of the root file system by +considering three factors. The first is if an initrd for the target operating +system is also present. The second is @samp{GRUB_DISABLE_LINUX_UUID} and if set +to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file +system by its UUID. The third is @samp{GRUB_DISABLE_LINUX_PARTUUID} and if set +to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file +system via the UUID of its enclosing partition. If the variables are assigned +any other value, that value is considered equivalent to @samp{false}. The +variables are also considered to be set to @samp{false} if they are not set. + +When booting, the Linux kernel will delegate the task of mounting the root +filesystem to the initrd. Most initrd images determine the root file system by +checking the Linux kernel's command-line for the @samp{root} key and use its +value as the identification method of the root file system. To improve theQuoted 8 lines
docs/grub.texi edit the scripts in @file{/etc/grub.d} directly. · line 1594
Quoted 6 lines
docs/grub.texi +6
-0+reliability of booting, most initrd images also allow the root file system to be +identified by its UUID. Because of this behavior, the @command{grub-mkconfig} +command will set @samp{root} to @samp{root=UUID=...} to provide the initrd with +the filesystem UUID of the root file system. + +If no initrd is detected or @samp{GRUB_DISABLE_LINUX_UUID} is set thens/set/set to @samp{true}/?
Yes. Thanks.
Quoted 8 lines
docs/grub.texi edit the scripts in @file{/etc/grub.d} directly. · line 1599
Quoted 6 lines
docs/grub.texi +5
-0+@command{grub-command} will identify the root filesystem by setting the kernel +command-line variable @samp{root} to @samp{root=PARTUUID=...} unless +@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true}. If +@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true}, +@command{grub-command} will identify by its LInux device name.s/LInux/Linux/g
ack.
Quoted 14 lines
docs/grub.texi edit the scripts in @file{/etc/grub.d} directly. · line 1607
Quoted 9 lines
docs/grub.texi +8
-0+ +The following table summarizes the behavior of the @command{grub-mkconfig} +command. + +@multitable {detected} {GRUB_DISABLE_LINUX_PARTUUID} {GRUB_DISABLE_LINUX_UUID} {Linux Root} +@headitem Initrd detected @tab GRUB_DISABLE_LINUX_PARTUUID Set To @tab GRUB_DISABLE_LINUX_UUID Set To @tab Linux Root ID Method +@item false @tab false @tab false @tab part UUID +@item false @tab false @tab true @tab part UUIDI hope that you have tested these two settings and they work. If yes then I am happy with all the patches. If there are no objections I will commit all of them in a week or so. I will fix both nitpicks listed above just before commit.
Quoted 1 line
I did. I've added a test script and its output at the bottom of this email.
LGTM, thank you for doing the work.
Daniel