Skip to contentSkip to conversation

Support for UEFI ESP in os-prober

RFC In review Andrey Borzenkov 6 participants 16 messages Sep 29, 2012 – Jun 5, 2013

lore
Share & tools
lore
#0 lore raw

RFC 1/1 Support for UEFI ESP in os-prober

Attached are suggested implementation for UEFI support. Because ESP can contain arbitrary number of boot entries, it is itself implemented as extensible framework.

1. /usr/lib/os-prober/mounted/05efi

Makes basic plausibility checks (FAT and /EFI exists) and calls scripts from /usr/lib/os-prober/mounted/efi/* to perform OS detection. Returns detected bootladers in the form ${device}@${path}:${long}:${short}:efi

2. patch for /etc/grub.d/30_os-prober

creates "chainloader ${path}" entry from the above

3. Patch for /usr/lib/os-prober/mounted/20microsoft

It seems that on UEFI systems Windows sometimes installs both legacy and UEFI bootloader. In this case os-prober adds menu entries for legacy Windows boot which do not work from within UEFI GRUB bootloader. Patch detects UEFI platform and skips running there.

4. /usr/lib/os-prober/mounted/efi/20microsoft

Suggested implementation for Microsoft bootloader. We have no way to create entries for individual OSes here (this would involve parsing BCD store at the very least), so entry is titled as "Windows Boot Manager", the same as is automatically added to UEFI boot menu.

This is successfully tested on VM with Windows 7/openSUSE 12.2 dual boot. As openSUSE 12.2 comes with GRUB2 as default bootloader, this issue seems to be hit by quite a number of users.

Comments?

-andrey

os-probes/mounted/x86/20microsoft +6 -0
Index: b/os-probes/mounted/x86/20microsoft
===================================================================
@@ -7,6 +7,12 @@ partition="$1"
 mpoint="$2"
 type="$3"
 
+# This script looks for legacy BIOS bootloaders only. Skip if running UEFI
+if [ -d /sys/firmware/efi ]; then
+	debug "Skipping legacy bootloaders on UEFI system"
+	exit 1
+fi
+
 # Weed out stuff that doesn't apply to us
 case "$type" in
 	ntfs|ntfs-3g) debug "$1 is a NTFS partition" ;;
etc/grub.d/30_os-prober renamed from etc/grub.d/30_os-prober.orig +16 -0
@@ -144,6 +144,22 @@ EOF
 }
 EOF
     ;;
+    efi)
+
+	EFIPATH=${DEVICE#*@}
+	DEVICE=${DEVICE%@*}
+	onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
+      cat << EOF
+menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
+EOF
+      save_default_entry | sed -e "s/^/\t/"
+      prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
+
+      cat <<EOF
+	chainloader ${EFIPATH}
+}
+EOF
+    ;;
     linux)
       LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
       prepare_boot_cache=
#1 lore raw

2012/9/29 Andrey Borzenkov <[email protected]>

Quoted 28 lines

Attached are suggested implementation for UEFI support. Because ESP can contain arbitrary number of boot entries, it is itself implemented as extensible framework.

1. /usr/lib/os-prober/mounted/05efi

Makes basic plausibility checks (FAT and /EFI exists) and calls scripts from /usr/lib/os-prober/mounted/efi/* to perform OS detection. Returns detected bootladers in the form ${device}@${path}:${long}:${short}:efi

2. patch for /etc/grub.d/30_os-prober

creates "chainloader ${path}" entry from the above

3. Patch for /usr/lib/os-prober/mounted/20microsoft

It seems that on UEFI systems Windows sometimes installs both legacy and UEFI bootloader. In this case os-prober adds menu entries for legacy Windows boot which do not work from within UEFI GRUB bootloader. Patch detects UEFI platform and skips running there.

4. /usr/lib/os-prober/mounted/efi/20microsoft

Suggested implementation for Microsoft bootloader. We have no way to create entries for individual OSes here (this would involve parsing BCD store at the very least), so entry is titled as "Windows Boot Manager", the same as is automatically added to UEFI boot menu.

Quoted 8 lines

This is successfully tested on VM with Windows 7/openSUSE 12.2 dual boot. As openSUSE 12.2 comes with GRUB2 as default bootloader, this issue seems to be hit by quite a number of users.

Comments?

-andrey

Thanks Andrey for working on this.
- I confirm that Windows sometimes installs both Legacy and UEFI bootloader.
Example: http://paste.ubuntu.com/1248333
- For information, here is a report you may be interested in:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1024383

Regards
Yann

#2 lore raw
In reply to Andrey Borzenkov

I haven‘t had time to view in details but os-prober isn‘t managed by us but by debian-boot team so you need to contact them. Also I‘d prefer more of detection to be done on runtime than it‘s done in current model

Quoted 42 lines · Andrey Borzenkov

Attached are suggested implementation for UEFI support. Because ESP can contain arbitrary number of boot entries, it is itself implemented as extensible framework.

1. /usr/lib/os-prober/mounted/05efi

Makes basic plausibility checks (FAT and /EFI exists) and calls scripts from /usr/lib/os-prober/mounted/efi/* to perform OS detection. Returns detected bootladers in the form ${device}@${path}:${long}:${short}:efi

2. patch for /etc/grub.d/30_os-prober

creates "chainloader ${path}" entry from the above

3. Patch for /usr/lib/os-prober/mounted/20microsoft

It seems that on UEFI systems Windows sometimes installs both legacy and UEFI bootloader. In this case os-prober adds menu entries for legacy Windows boot which do not work from within UEFI GRUB bootloader. Patch detects UEFI platform and skips running there.

4. /usr/lib/os-prober/mounted/efi/20microsoft

Suggested implementation for Microsoft bootloader. We have no way to create entries for individual OSes here (this would involve parsing BCD store at the very least), so entry is titled as "Windows Boot Manager", the same as is automatically added to UEFI boot menu.

This is successfully tested on VM with Windows 7/openSUSE 12.2 dual boot. As openSUSE 12.2 comes with GRUB2 as default bootloader, this issue seems to be hit by quite a number of users.

Comments?

-andrey

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

#3 lore raw

В Mon, 1 Oct 2012 13:25:50 +0200
"Vladimir 'phcoder' Serbinenko" <[email protected]> пишет:

Quoted 3 lines

I haven‘t had time to view in details but os-prober isn‘t managed by us but by debian-boot team so you need to contact them. Also I‘d prefer more of detection to be done on runtime than it‘s done in current model

In the meantime os-prober part is integrated in Debian as of 1.58. The patch adds missing part from grub2 side. How does it look like?

---
 ChangeLog                   |  5 +++++
 util/grub.d/30_os-prober.in | 16 ++++++++++++++++
 2 files changed, 21 insertions(+)
ChangeLog +5 -0
index e9ef17e..798369d 100644
@@ -1,3 +1,8 @@
+2013-05-31  Andrey Borzenkov <[email protected]>
+
+	* util/grub.d/30_os-prober.in: Add support for probing EFI
+	System Partition (as of os-prober 1.58).
+
 2013-05-30  Josh Triplett  <[email protected]>
 
 	* grub-core/normal/cmdline.c (grub_cmdline_get): Fix Ctrl-u
util/grub.d/30_os-prober.in +16 -0
index 04f32a1..5e3c5d8 100644
@@ -149,6 +149,22 @@ EOF
 }
 EOF
     ;;
+    efi)
+
+	EFIPATH=${DEVICE#*@}
+	DEVICE=${DEVICE%@*}
+	onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
+      cat << EOF
+menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
+EOF
+      save_default_entry | sed -e "s/^/\t/"
+      prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
+
+      cat <<EOF
+	chainloader ${EFIPATH}
+}
+EOF
+    ;;
     linux)
       if [ "x$BTRFS" = "xbtrfs" ]; then
          LINUXPROBED="`linux-boot-prober btrfs ${BTRFSuuid} ${BTRFSsubvol}  2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
Signature · 1 line
tg: (f434947..) u/os-prober-efi (depends on: master)
#4 lore raw
Quoted 10 lines · Andrey Borzenkov

В Mon, 1 Oct 2012 13:25:50 +0200
"Vladimir 'phcoder' Serbinenko" <[email protected]> пишет:

Quoted 3 lines

I haven‘t had time to view in details but os-prober isn‘t managed by us but by debian-boot team so you need to contact them. Also I‘d prefer more of detection to be done on runtime than it‘s done in current model

In the meantime os-prober part is integrated in Debian as of 1.58. The patch adds missing part from grub2 side. How does it look like?

Go ahead. I must say I'm generally disappointed with os-prober and have ideas to move away from it. I'll start another topic for it.

Quoted 46 lines
---
 ChangeLog                   |  5 +++++
 util/grub.d/30_os-prober.in | 16 ++++++++++++++++
 2 files changed, 21 insertions(+)
ChangeLog +5 -0
index e9ef17e..798369d 100644
@@ -1,3 +1,8 @@
+2013-05-31  Andrey Borzenkov <[email protected]>
+
+	* util/grub.d/30_os-prober.in: Add support for probing EFI
+	System Partition (as of os-prober 1.58).
+
 2013-05-30  Josh Triplett  <[email protected]>
 
 	* grub-core/normal/cmdline.c (grub_cmdline_get): Fix Ctrl-u
util/grub.d/30_os-prober.in +16 -0
index 04f32a1..5e3c5d8 100644
@@ -149,6 +149,22 @@ EOF
 }
 EOF
     ;;
+    efi)
+
+	EFIPATH=${DEVICE#*@}
+	DEVICE=${DEVICE%@*}
+	onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
+      cat << EOF
+menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
+EOF
+      save_default_entry | sed -e "s/^/\t/"
+      prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
+
+      cat <<EOF
+	chainloader ${EFIPATH}
+}
+EOF
+    ;;
     linux)
       if [ "x$BTRFS" = "xbtrfs" ]; then
          LINUXPROBED="`linux-boot-prober btrfs ${BTRFSuuid} ${BTRFSsubvol}  2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
#5 lore raw
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

I must say I'm generally disappointed with os-prober and have ideas to move away from it. I'll start another topic for it.

I agree. I would prefer adding an include command so grub.cfg could just do something like:

include /boot/grub/grub.d/*.cfg

and have an install procedure drop in one or more menu items instead of every os install or update rewriting the entire grub.cfg every time.

-- Bruce Dubbs
linuxfromscratch.org

#6 lore raw
Quoted 10 lines · Bruce Dubbs
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

I must say I'm generally disappointed with os-prober and have ideas to move away from it. I'll start another topic for it.

I agree. I would prefer adding an include command so grub.cfg could just do something like:

include /boot/grub/grub.d/*.cfg

and have an install procedure drop in one or more menu items instead of every os install or update rewriting the entire grub.cfg every time.

Or for GRUB to be a lot more dynamic by scanning the EFI System partition for bootloaders it recognizes, an effectively creates a grub.cfg on the fly based on ESP contents, and NVRAM contents. I think the present behavior is unreliable, and makes GRUB a very narrowly useful boot manager. So the question is, does GRUB want to grow into a more capable boot manager rather than just a collection of bootloaders for different OS's.

Chris Murphy

#7 lore raw
In reply to Bruce Dubbs
Quoted 10 lines · Bruce Dubbs
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

I must say I'm generally disappointed with os-prober and have ideas to move away from it. I'll start another topic for it.

I agree. I would prefer adding an include command so grub.cfg could just do something like:

include /boot/grub/grub.d/*.cfg

and have an install procedure drop in one or more menu items instead of every os install or update rewriting the entire grub.cfg every time.

http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ describes such a configuration structure, and http://pkgs.fedoraproject.org/cgit/grub2.git/plain/0362-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch implements it as a grub command.

/Mads

#8 lore raw

В Wed, 05 Jun 2013 17:56:40 +0200
Mads Kiilerich <[email protected]> пишет:

Quoted 9 lines · Bruce Dubbs
Quoted 8 lines
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

I must say I'm generally disappointed with os-prober and have ideas to move away from it. I'll start another topic for it.

I agree. I would prefer adding an include command so grub.cfg could just do something like:

Quoted 7 lines
Quoted 4 lines

include /boot/grub/grub.d/*.cfg

and have an install procedure drop in one or more menu items instead of every os install or update rewriting the entire grub.cfg every time.

http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ describes such a configuration structure,

It is rather (intentionally) limited in functionality. For a start, it explicitly excludes possibility to boot Windows, making transition from os-prober impossible.

Quoted 10 lines

and
http://pkgs.fedoraproject.org/cgit/grub2.git/plain/0362-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch
implements it as a grub command.

/Mads

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

#9 lore raw
In reply to Mads Kiilerich
Quoted 11 lines · Mads Kiilerich
Quoted 10 lines · Bruce Dubbs
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

I must say I'm generally disappointed with os-prober and have ideas to move away from it. I'll start another topic for it.

I agree. I would prefer adding an include command so grub.cfg could just do something like:

include /boot/grub/grub.d/*.cfg

Quoted 7 lines
Quoted 2 lines

and have an install procedure drop in one or more menu items instead of every os install or update rewriting the entire grub.cfg every time.

http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ describes such a configuration structure, and
http://pkgs.fedoraproject.org/cgit/grub2.git/plain/0362-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch
implements it as a grub command.

Although that's a good start, it seems a little too specific. What I had in mind would be the equivalent to the source command in bash. For example,

if condition; then
include (hd0,3)/grub/custom/themes/themeA.cfg
else
include (hd0,2)/boot/grub/themes/themeB.cfg
fi

# Get menuentries
include /boot/grub/grub.d/*.cfg

I have no preference to the keyword. Either include or source would work.

-- Bruce

#10 lore raw

В Wed, 05 Jun 2013 12:21:54 -0500
Bruce Dubbs <[email protected]> пишет:

Quoted 15 lines
Quoted 14 lines · Mads Kiilerich
Quoted 12 lines · Bruce Dubbs
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

I must say I'm generally disappointed with os-prober and have ideas to move away from it. I'll start another topic for it.

I agree. I would prefer adding an include command so grub.cfg could just do something like:

include /boot/grub/grub.d/*.cfg

and have an install procedure drop in one or more menu items instead of every os install or update rewriting the entire grub.cfg every time.

Quoted 7 lines
Quoted 4 lines

http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ describes such a configuration structure, and
http://pkgs.fedoraproject.org/cgit/grub2.git/plain/0362-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch
implements it as a grub command.

Although that's a good start, it seems a little too specific. What I had in mind would be the equivalent to the source command in bash.

grub already has "source" command.

Quoted 12 lines

For
example,

if condition; then
include (hd0,3)/grub/custom/themes/themeA.cfg
else
include (hd0,2)/boot/grub/themes/themeB.cfg
fi

# Get menuentries
include /boot/grub/grub.d/*.cfg

Implementing full-fledged globbing in grub is probably overkill; adding "source_dir" command looks more doable. Something like

source_dir --suffix .cfg /boot/grub/grub.d

Any takers? :)

#11 lore raw
Quoted 37 lines · Andrey Borzenkov

В Wed, 05 Jun 2013 12:21:54 -0500
Bruce Dubbs <[email protected]> пишет:

Quoted 15 lines
Quoted 14 lines · Mads Kiilerich
Quoted 12 lines · Bruce Dubbs
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

I must say I'm generally disappointed with os-prober and have ideas to move away from it. I'll start another topic for it.

I agree. I would prefer adding an include command so grub.cfg could just do something like:

include /boot/grub/grub.d/*.cfg

and have an install procedure drop in one or more menu items instead of every os install or update rewriting the entire grub.cfg every time.

Quoted 7 lines
Quoted 4 lines

http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ describes such a configuration structure, and
http://pkgs.fedoraproject.org/cgit/grub2.git/plain/0362-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch
implements it as a grub command.

Although that's a good start, it seems a little too specific. What I had in mind would be the equivalent to the source command in bash.

grub already has "source" command.

Quoted 9 lines

For
example,

if condition; then
include (hd0,3)/grub/custom/themes/themeA.cfg
else
include (hd0,2)/boot/grub/themes/themeB.cfg
fi

Quoted 7 lines
Quoted 3 lines

# Get menuentries
include /boot/grub/grub.d/*.cfg

Implementing full-fledged globbing in grub is probably overkill; adding "source_dir" command looks more doable. Something like

We already have globbing. Trouble with this approach is that ->dir method may be slow or (especially on network systems) absent. It should not be relied upon unless absolutely necessary.

Quoted 9 lines

source_dir --suffix .cfg /boot/grub/grub.d

Any takers? :)

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

#12 lore raw
Quoted 42 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 41 lines · Andrey Borzenkov

В Wed, 05 Jun 2013 12:21:54 -0500
Bruce Dubbs <[email protected]> пишет:

Quoted 15 lines
Quoted 14 lines · Mads Kiilerich
Quoted 12 lines · Bruce Dubbs
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

I must say I'm generally disappointed with os-prober and have ideas to move away from it. I'll start another topic for it.

I agree. I would prefer adding an include command so grub.cfg could just do something like:

include /boot/grub/grub.d/*.cfg

and have an install procedure drop in one or more menu items instead of every os install or update rewriting the entire grub.cfg every time.

Quoted 7 lines
Quoted 4 lines

http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ describes such a configuration structure, and
http://pkgs.fedoraproject.org/cgit/grub2.git/plain/0362-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch
implements it as a grub command.

Although that's a good start, it seems a little too specific. What I had in mind would be the equivalent to the source command in bash.

grub already has "source" command.

Quoted 12 lines

For
example,

if condition; then
include (hd0,3)/grub/custom/themes/themeA.cfg
else
include (hd0,2)/boot/grub/themes/themeB.cfg
fi

# Get menuentries
include /boot/grub/grub.d/*.cfg

Quoted 6 lines
Quoted 3 lines

Implementing full-fledged globbing in grub is probably overkill; adding "source_dir" command looks more doable. Something like

We already have globbing. Trouble with this approach is that ->dir method may be slow or (especially on network systems) absent. It should not be relied upon unless absolutely necessary.

This reminds me of the phrase "perfect is the enemy of good". What percentage of systems rely on network capabilities for booting?

Quoted 1 line
Quoted 1 line

source_dir --suffix .cfg /boot/grub/grub.d

#13 lore raw
In reply to Vladimir 'φ-coder/phcoder' Serbinenko

В Wed, 05 Jun 2013 20:43:58 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 38 lines · Andrey Borzenkov
Quoted 37 lines

В Wed, 05 Jun 2013 12:21:54 -0500
Bruce Dubbs <[email protected]> пишет:

Quoted 15 lines
Quoted 14 lines · Mads Kiilerich
Quoted 12 lines · Bruce Dubbs
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

I must say I'm generally disappointed with os-prober and have ideas to move away from it. I'll start another topic for it.

I agree. I would prefer adding an include command so grub.cfg could just do something like:

include /boot/grub/grub.d/*.cfg

and have an install procedure drop in one or more menu items instead of every os install or update rewriting the entire grub.cfg every time.

Quoted 7 lines
Quoted 4 lines

http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ describes such a configuration structure, and
http://pkgs.fedoraproject.org/cgit/grub2.git/plain/0362-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch
implements it as a grub command.

Although that's a good start, it seems a little too specific. What I had in mind would be the equivalent to the source command in bash.

grub already has "source" command.

Quoted 9 lines

For
example,

if condition; then
include (hd0,3)/grub/custom/themes/themeA.cfg
else
include (hd0,2)/boot/grub/themes/themeB.cfg
fi

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

# Get menuentries
include /boot/grub/grub.d/*.cfg

Implementing full-fledged globbing in grub is probably overkill; adding "source_dir" command looks more doable. Something like

We already have globbing.

Ehh .. you mean that

for i in /boot/grub/grub.d/*.cfg; do
source $i
done

already works?

Quoted 14 lines
                          Trouble with this approach is that ->dir

method may be slow or (especially on network systems) absent. It should not be relied upon unless absolutely necessary.

Quoted 9 lines

source_dir --suffix .cfg /boot/grub/grub.d

Any takers? :)

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

#14 lore raw
Quoted 50 lines · Andrey Borzenkov

В Wed, 05 Jun 2013 20:43:58 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 38 lines · Andrey Borzenkov
Quoted 37 lines

В Wed, 05 Jun 2013 12:21:54 -0500
Bruce Dubbs <[email protected]> пишет:

Quoted 15 lines
Quoted 14 lines · Mads Kiilerich
Quoted 12 lines · Bruce Dubbs
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

I must say I'm generally disappointed with os-prober and have ideas to move away from it. I'll start another topic for it.

I agree. I would prefer adding an include command so grub.cfg could just do something like:

include /boot/grub/grub.d/*.cfg

and have an install procedure drop in one or more menu items instead of every os install or update rewriting the entire grub.cfg every time.

Quoted 7 lines
Quoted 4 lines

http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ describes such a configuration structure, and
http://pkgs.fedoraproject.org/cgit/grub2.git/plain/0362-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch
implements it as a grub command.

Although that's a good start, it seems a little too specific. What I had in mind would be the equivalent to the source command in bash.

grub already has "source" command.

Quoted 9 lines

For
example,

if condition; then
include (hd0,3)/grub/custom/themes/themeA.cfg
else
include (hd0,2)/boot/grub/themes/themeB.cfg
fi

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

# Get menuentries
include /boot/grub/grub.d/*.cfg

Implementing full-fledged globbing in grub is probably overkill; adding "source_dir" command looks more doable. Something like

We already have globbing.

Quoted 8 lines

Ehh .. you mean that

for i in /boot/grub/grub.d/*.cfg; do
source $i
done

already works?

Yes, just make sure that regexp module is loaded.

Quoted 22 lines
Quoted 14 lines
                          Trouble with this approach is that ->dir

method may be slow or (especially on network systems) absent. It should not be relied upon unless absolutely necessary.

Quoted 9 lines

source_dir --suffix .cfg /boot/grub/grub.d

Any takers? :)

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

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

#15 lore raw
In reply to Mads Kiilerich
Quoted 9 lines · Mads Kiilerich
Quoted 8 lines · Bruce Dubbs
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

I must say I'm generally disappointed with os-prober and have ideas to move away from it. I'll start another topic for it.

I agree. I would prefer adding an include command so grub.cfg could just do something like:

Quoted 7 lines
Quoted 4 lines

include /boot/grub/grub.d/*.cfg

and have an install procedure drop in one or more menu items instead of every os install or update rewriting the entire grub.cfg every time.

http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ describes such a configuration structure, and

This standard apparently was done without any consideration of boot loader point of view and probably without any input from bootloader guys at all. I'm not ok with using it as is but can be used if ammended.

Quoted 3 lines

http://pkgs.fedoraproject.org/cgit/grub2.git/plain/0362-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch
implements it as a grub command.

Due to design limitations of design, it will break in some completely reasonable cases. It can't be supported as-is.

Quoted 6 lines

/Mads

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