All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] Support for UEFI ESP in os-prober
@ 2012-09-29 15:04 Andrey Borzenkov
  2012-09-30 20:30 ` yannubuntu
  2012-10-01 11:25 ` Vladimir 'phcoder' Serbinenko
  0 siblings, 2 replies; 17+ messages in thread
From: Andrey Borzenkov @ 2012-09-29 15:04 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1344 bytes --]

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

[-- Attachment #2: os-prober-skip-MS-legacy-on-UEFI.patch --]
[-- Type: text/x-patch, Size: 538 bytes --]

Index: b/os-probes/mounted/x86/20microsoft
===================================================================
--- a/os-probes/mounted/x86/20microsoft
+++ 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" ;;

[-- Attachment #3: 30_os-prober.patch --]
[-- Type: text/x-patch, Size: 766 bytes --]

--- /etc/grub.d/30_os-prober.orig	2012-09-28 22:12:51.047085849 +0400
+++ /etc/grub.d/30_os-prober	2012-09-29 18:35:25.949036128 +0400
@@ -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=

[-- Attachment #4: 05efi --]
[-- Type: application/x-shellscript, Size: 959 bytes --]

[-- Attachment #5: 20microsoft --]
[-- Type: application/x-shellscript, Size: 614 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread
[parent not found: <mailman.26139.1370458399.22519.grub-devel@gnu.org>]

end of thread, other threads:[~2013-06-06 15:33 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-29 15:04 [RFC] Support for UEFI ESP in os-prober Andrey Borzenkov
2012-09-30 20:30 ` yannubuntu
2012-10-01 11:25 ` Vladimir 'phcoder' Serbinenko
2013-05-31 14:48   ` Andrey Borzenkov
2013-05-31 16:12     ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-05-31 17:03       ` Bruce Dubbs
2013-05-31 17:55         ` Chris Murphy
2013-06-05 15:56         ` Mads Kiilerich
2013-06-05 16:56           ` Andrey Borzenkov
2013-06-05 17:21           ` Bruce Dubbs
2013-06-05 17:58             ` Andrey Borzenkov
2013-06-05 18:43               ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-06-05 18:53                 ` Bruce Dubbs
2013-06-05 19:03                 ` Andrey Borzenkov
2013-06-05 19:29                   ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-06-05 17:51           ` Vladimir 'φ-coder/phcoder' Serbinenko
     [not found] <mailman.26139.1370458399.22519.grub-devel@gnu.org>
2013-06-06 15:33 ` Tom Davies

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.