Skip to contentSkip to conversation

add drivemap support to 30_os-prober.in and use UUIDs

PATCH In review Felix Zielcke 3 participants 6 messages Jun 7, 2009 – Jun 11, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add drivemap support to 30_os-prober.in and use UUIDs

Attached patch uses `prepare_grub_to_access_device' to set the root in the generated entrys.
And it adds drivemap to the chainload ones, if root isn't (hd0).

The Debian grub-installer adds map only with Dos and Windows, should I do the same or is it okay to do it for all?

-# update-grub helper script.
+# grub-mkconfig helper script.
Does this needs to be mentioned in ChangeLog?

Signature · 1 line
Felix Zielcke

2009-06-07 Felix Zielcke <[email protected]>

* util/grub.d/30_os-prober.in: Source ${libdir}/grub/grub-mkconfig_lib. Use prepare_grub_to_access_device to set the root device.

util/grub.d/30_os-prober.in +23 -7
index 7d4d17e..9a6dff4 100644
@@ -1,7 +1,7 @@
 #! /bin/sh -e
 
-# update-grub helper script.
-# Copyright (C) 2006,2007,2008  Free Software Foundation, Inc.
+# grub-mkconfig helper script.
+# Copyright (C) 2006,2007,2008,2009  Free Software Foundation, Inc.
 #
 # GRUB is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,6 +16,12 @@
 # You should have received a copy of the GNU General Public License
 # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+
+. ${libdir}/grub/grub-mkconfig_lib
+
 if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then
   # missing os-prober and/or linux-boot-prober
   exit 0
@@ -45,7 +51,15 @@ for OS in ${OSPROBED} ; do
 
       cat << EOF
 menuentry "${LONGNAME} (on ${DEVICE})" {
-	set root=${CHAINROOT}
+EOF
+      prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
+
+      if [ `echo ${CHAINROOT} | sed -e 's/,[0-9]*[a-z]*//g'` != "(hd0)" ] ; then
+	  cat << EOF
+	  drivemap -s (hd0) \$root
+EOF
+      fi
+      cat << EOF
 	chainloader +1
 }
 EOF
@@ -61,15 +75,15 @@ EOF
         LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
         LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"
 
-        LINUXROOT="`grub-probe --target=drive --device ${LBOOT} 2> /dev/null`"
-
         if [ -z "${LLABEL}" ] ; then
           LLABEL="${LONGNAME}"
         fi
 
         cat << EOF
 menuentry "${LLABEL} (on ${DEVICE})" {
-	set root=${LINUXROOT}
+EOF
+	prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
+	cat <<  EOF
 	linux ${LKERNEL} ${LPARAMS}
 EOF
         if [ -n "${LINITRD}" ] ; then
@@ -88,7 +102,9 @@ EOF
       OSXDISK=disk"`echo ${OSXROOT} | awk -F , '{ print $1 ; }' | sed 's/(hd//;'`"s"`echo ${OSXROOT} | awk -F , '{ print $2 ; }' | sed 's/)//;'`"
         cat << EOF
 menuentry "${LONGNAME} (on ${DEVICE})" {
-	set root=${OSXROOT}
+EOF
+	prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
+	cat << EOF
         insmod vbe
         do_resume=0
         if [ /var/vm/sleepimage -nt10 / ]; then
#1 lore raw
Quoted 6 lines · Felix Zielcke

Attached patch uses `prepare_grub_to_access_device' to set the root in the generated entrys.
And it adds drivemap to the chainload ones, if root isn't (hd0).

The Debian grub-installer adds map only with Dos and Windows, should I do the same or is it okay to do it for all?

Perhaps it would be better to avoid it when it's not needed. But it may be tricky to determine what bootloader we are using.

Let's do it always and eliminate the cases where it's harmful or definitely useless.

Quoted 3 lines
util/grub.d/30_os-prober.in +1 -1
-# update-grub helper script.
+# grub-mkconfig helper script.

Does this needs to be mentioned in ChangeLog?

The standard says:

'When you change just comments or doc strings, it is enough to write an entry for the file, without mentioning the functions. Just "Doc fixes" is enough for the change log.'

Signature · 2 lines
Regards,
Pavel Roskin
#2 lore raw
Quoted 5 lines · Pavel Roskin
Quoted 4 lines · Felix Zielcke

Attached patch uses `prepare_grub_to_access_device' to set the root in the generated entrys.
And it adds drivemap to the chainload ones, if root isn't (hd0).

Quoted 8 lines
Quoted 2 lines

The Debian grub-installer adds map only with Dos and Windows, should I do the same or is it okay to do it for all?

Perhaps it would be better to avoid it when it's not needed.  But it may be tricky to determine what bootloader we are using.

Let's do it always and eliminate the cases where it's harmful or definitely useless.

Drivemapping isn't good per se. It's more like unfortunate need. However it should always be safe to drivemap because AFAIK no OS relies on particular drive ordering except 0x80 being booting drive. However this entry will fail unless my drivemap fix is incorporated

Quoted 21 lines
Quoted 4 lines
util/grub.d/30_os-prober.in +1 -1
-# update-grub helper script.
+# grub-mkconfig helper script.

Does this needs to be mentioned in ChangeLog?

The standard says:

'When you change just comments or doc strings, it is enough to write an entry for the file, without mentioning the functions.  Just "Doc fixes" is enough for the change log.'

--
Regards,
Pavel Roskin

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

Signature · 2 lines
Regards
Vladimir 'phcoder' Serbinenko
#3 lore raw

Am Montag, den 08.06.2009, 12:54 +0200 schrieb Vladimir 'phcoder' Serbinenko:

Quoted 12 lines · Pavel Roskin
Quoted 11 lines · Felix Zielcke
Quoted 6 lines

Attached patch uses `prepare_grub_to_access_device' to set the root in the generated entrys.
And it adds drivemap to the chainload ones, if root isn't (hd0).

The Debian grub-installer adds map only with Dos and Windows, should I do the same or is it okay to do it for all?

Perhaps it would be better to avoid it when it's not needed. But it may be tricky to determine what bootloader we are using.

Quoted 6 lines
Quoted 2 lines

Let's do it always and eliminate the cases where it's harmful or definitely useless.

Drivemapping isn't good per se. It's more like unfortunate need. However it should always be safe to drivemap because AFAIK no OS relies on particular drive ordering except 0x80 being booting drive. However this entry will fail unless my drivemap fix is incorporated

os-prober currently prints `chain' on FreeDOS, QNX4, Windows, MS-DOS, Solaris, Minix and Dell Utility Partition
Solaris probable won't need it but for Minix and QNX4 (I don't even know what this is) I don't know.
FreeDOS probable needs it too or not?
So better just use it always and if someone says it can't boot because of drivemap we can change it for that OS.

Signature · 1 line
Felix Zielcke
#4 lore raw
Quoted 5 lines · Felix Zielcke

os-prober currently prints `chain' on FreeDOS, QNX4, Windows, MS-DOS, Solaris, Minix and Dell Utility Partition
Solaris probable won't need it but for Minix and QNX4 (I don't even know what this is) I don't know.
FreeDOS probable needs it too or not?

FreeDOS 1.0 still needs drivemap. Dell Utility Partition is MS DOS based, so I think it needs drivemap too.

Quoted 2 lines

So better just use it always and if someone says it can't boot because of drivemap we can change it for that OS.

That's exactly my suggestion.

Even we check that a certain version of, say, QNX is fine without drivemap, some older version may need it, and somebody may have that version.

Signature · 2 lines
Regards,
Pavel Roskin
#5 lore raw
In reply to Felix Zielcke

Am Sonntag, den 07.06.2009, 17:37 +0200 schrieb Felix Zielcke:

Quoted 10 lines

Attached patch uses `prepare_grub_to_access_device' to set the root in the generated entrys.
And it adds drivemap to the chainload ones, if root isn't (hd0).

The Debian grub-installer adds map only with Dos and Windows, should I do the same or is it okay to do it for all?

util/grub.d/30_os-prober.in +1 -1
-# update-grub helper script.
+# grub-mkconfig helper script.

Does this needs to be mentioned in ChangeLog?

Commited.

Signature · 1 line
Felix Zielcke