On systems which support multiple boot platforms such as BIOS or EFI,
it makes no sense to show menu entries which are not supported by
the current boot platform. Menu entries generated from os-prober
'chain' boot type use boot sector chainloading which is supported
by PC BIOS platform only.
Show 'chain' menu entries only if boot platform is PC BIOS.
Show 'efi' menu entries only if boot platform is EFI.
This is aimed to allow os-prober to report both EFI and PC BIOS
boot loaders regardless of the current boot mode on x86 systems
which support both EFI and legacy BIOS boot.
Signed-off-by: Pascal Hambourg <pascal@plouf.fr.eu.org>
---
Note: I did not change indentation to keep the patch minimal.
v2:
- show 'chain' menu entries if platform=pc instead of platform!=efi
- add explanatory comments in generated config
util/grub.d/30_os-prober.in | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
index 043e5dfea..e9e217208 100644
--- a/util/grub.d/30_os-prober.in
+++ b/util/grub.d/30_os-prober.in
@@ -155,6 +155,8 @@ for OS in ${OSPROBED} ; do
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
cat << EOF
+# this menu entry is supported only by PC BIOS platform
+if [ "\$grub_platform" = "pc" ]; then
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os
\$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
EOF
save_default_entry | grub_add_tab
@@ -179,6 +181,7 @@ EOF
cat <<EOF
chainloader +1
}
+fi
EOF
;;
efi)
@@ -187,6 +190,8 @@ EOF
DEVICE=${DEVICE%@*}
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
cat << EOF
+# this menu entry is supported only by EFI platform
+if [ "\$grub_platform" = "efi" ]; then
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os
\$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
EOF
save_default_entry | sed -e "s/^/\t/"
@@ -195,6 +200,7 @@ EOF
cat <<EOF
chainloader ${EFIPATH}
}
+fi
EOF
;;
linux)