On Mon, Sep 20, 2010 at 12:33:00PM -0400, Daniel Kahn Gillmor wrote:
> a standard powerpc mac mini is unable to boot with grub after running
>
> grub-install /dev/hda
>
> (the machine's only disk uses an apple partitioning scheme, with an HFS
> volume as (hd,apple2) mounted at /boot/grub)
[...]
> it looks like grub-install isn't passing a --prefix option to
> grub-mkimage.
>
> Re-running /usr/sbin/grub-install /dev/hda with the attached patch
> applied makes it so that this ugly workaround is no longer necessary.
Thanks for your report.
> --- /usr/sbin/grub-install 2010-08-23 08:23:50.000000000 -0400
> +++ /usr/sbin/grub-install.new 2010-09-20 11:47:30.000000000 -0400
> @@ -222,7 +222,7 @@
> modules="$modules $fs_module $partmap_module $devabstraction_module"
>
> # Now perform the installation.
> -"$grub_mkimage" -O ${target_cpu}-ieee1275 --directory=${pkglibdir}
> --output=${grubdir}/grub $modules || exit 1
> +"$grub_mkimage" -O ${target_cpu}-ieee1275 --directory=${pkglibdir}
> --output=${grubdir}/grub --prefix=${prefix_drive}${relative_grubdir} $modules
> || exit 1
>
> if test $update_nvram = yes; then
> set $ofpathname dummy
I don't see how this can be sufficient, since neither prefix_drive nor
relative_grubdir is set in the current version of the script.
Does the attached patch work? It's a partial resync with the main
version of grub-install, anticipating the next snapshot/release where
all the different grub-installs are merged into a single version.
Thanks,
--
Colin Watson [[email protected]]
Description: Backport ieee1275 grub-install improvements
We need to encode a prefix in the generated image, otherwise it will need
manual help to find the boot directory.
Author: Daniel Kahn Gillmor <[email protected]>
Author: Colin Watson <[email protected]>
Bug-Debian: http://bugs.debian.org/597538
Forwarded: not-needed
Last-Update: 2010-09-21
Index: b/util/ieee1275/grub-install.in
===================================================================
--- a/util/ieee1275/grub-install.in
+++ b/util/ieee1275/grub-install.in
@@ -156,6 +156,8 @@
grubdir=${bootdir}/`echo grub | sed ${transform}`
device_map=${grubdir}/device.map
+grub_probe="${grub_probe} --device-map=${device_map}"
+
set $grub_mkimage dummy
if test -f "$1"; then
:
@@ -196,12 +198,15 @@
cp -f $file ${grubdir} || exit 1
done
+# Write device to a variable so we don't have to traverse /dev every time.
+grub_device=`$grub_probe --target=device ${grubdir}` || exit 1
+
if ! test -f ${grubdir}/grubenv; then
$grub_editenv ${grubdir}/grubenv create
fi
# Create the core image. First, auto-detect the filesystem module.
-fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}`
+fs_module=`$grub_probe --target=fs --device ${grub_device}`
if test "x$fs_module" = x -a "x$modules" = x; then
echo "Auto-detection of a filesystem module failed." 1>&2
echo "Please specify the module with the option \`--modules' explicitly." 1>&2
@@ -212,17 +217,66 @@
# this command is allowed to fail (--target=fs already grants us that the
# filesystem will be accessible).
partmap_module=
-for x in `$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null`; do
+for x in `$grub_probe --target=partmap --device ${grub_device} 2> /dev/null`; do
partmap_module="$partmap_module part_$x";
done
# Device abstraction module, if any (lvm, raid).
-devabstraction_module=`$grub_probe --target=abstraction --device-map=${device_map} ${grubdir}`
+devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}`
modules="$modules $fs_module $partmap_module $devabstraction_module"
+relative_grubdir=`make_system_path_relative_to_its_root ${grubdir}` || exit 1
+if [ "x${relative_grubdir}" = "x" ] ; then
+ relative_grubdir=/
+fi
+
+prefix_drive=
+config_opt=
+
+rm -f ${grubdir}/load.cfg
+
+if [ "x${devabstraction_module}" = "x" ] ; then
+ if [ x"${install_device}" != x ]; then
+ if echo "${install_device}" | grep -qx "(.*)" ; then
+ install_drive="${install_device}"
+ else
+ install_drive="`$grub_probe --target=drive --device ${install_device}`" || exit 1
+ fi
+ install_drive="`echo ${install_drive} | sed -e s/,[a-z0-9,]*//g`"
+ fi
+ grub_drive="`$grub_probe --target=drive --device ${grub_device}`" || exit 1
+
+ # Strip partition number
+ grub_drive="`echo ${grub_drive} | sed -e s/,[a-z0-9,]*//g`"
+ if [ "$disk_module" = ata ] ; then
+ # generic method (used on coreboot and ata mod)
+ uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`"
+ if [ "x${uuid}" = "x" ] ; then
+ echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
+ exit 1
+ fi
+ echo "search.fs_uuid ${uuid} root " >> ${grubdir}/load.cfg
+ echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg
+ config_opt="-c ${grubdir}/load.cfg "
+ modules="$modules search_fs_uuid"
+ elif [ "x${grub_drive}" != "x${install_drive}" ] ; then
+ uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`"
+ if [ "x${uuid}" = "x" ] ; then
+ echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
+ exit 1
+ fi
+ echo "search.fs_uuid ${uuid} root " >> ${grubdir}/load.cfg
+ echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg
+ config_opt="-c ${grubdir}/load.cfg "
+ modules="$modules search_fs_uuid"
+ fi
+else
+ prefix_drive=`$grub_probe --target=drive --device ${grub_device}` || exit 1
+fi
+
# Now perform the installation.
-"$grub_mkimage" -O ${target_cpu}-ieee1275 --directory=${pkglibdir} --output=${grubdir}/grub $modules || exit 1
+"$grub_mkimage" ${config_opt} -O ${target_cpu}-ieee1275 --directory=${pkglibdir} --output=${grubdir}/grub --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
if test $update_nvram = yes; then
set $ofpathname dummy