From: Paulo de Rezende Pinatti <ppinatti@linux.vnet.ibm.com>
To: grub-devel@gnu.org
Subject: [PATCH] Enable install of grub2 in PReP partition
Date: Fri, 11 Nov 2011 12:02:08 -0200 [thread overview]
Message-ID: <4EBD2AE0.7020200@linux.vnet.ibm.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 322 bytes --]
Hi,
This patch will enable the install and run of Grub 2 in the PReP
partition for PowerPC machines. This procedure will only be used if a
install_device argument is used with grub-install, otherwise it will be
installed by the old way.
Best Regards
--
Paulo de Rezende Pinatti
Staff Software Engineer, LTC Brazil
[-- Attachment #2: grub-install-prep.patch --]
[-- Type: text/plain, Size: 3500 bytes --]
=== modified file 'util/grub-install.in'
--- util/grub-install.in 2011-11-05 11:15:07 +0000
+++ util/grub-install.in 2011-11-11 00:06:00 +0000
@@ -273,8 +273,7 @@
exit 1
fi
-if ! ([ "${target_cpu}-${platform}" = "i386-pc" ] \
- || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]); then
+if ! ([ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${platform}" = "ieee1275" ]); then
install_device=
fi
@@ -643,6 +642,28 @@
# Point boot-device at the new grub install
boot_device="$ofpath:$partno,"`"$grub_mkrelpath" "${grubdir}/core.${imgext}" | sed 's,/,\\\\,g'`
+
+ # If a install device is defined, copy the core.elf to PReP partition.
+ if [ "${target_cpu}" = "powerpc" ] && [ -n "${install_device}" ]; then
+ if [ "$(${grub_probe} -m ${device_map} -d ${install_device} -t msdos_parttype)" != "41" ]; then
+ echo "The chosen partition is not a PReP partition."
+ exit 1
+ fi
+
+ if [ "$(file -s ${install_device} -b | awk '{ print $1 }')" = ELF ] || [ $(cmp /dev/zero ${install_device} &>/dev/null) ]; then
+ # Change boot device to the harddisk root
+ boot_device="$ofpath"
+ dd if=${grubdir}/core.${imgext} of=${install_device} 2>/dev/null || {
+ echo "Failed to copy Grub to the PReP partition."
+ exit 1
+ }
+ else
+ echo "The PReP partition is not empty. If you are sure you want to use it, run dd to clear it:"
+ echo " dd if=/dev/zero of=${install_device}"
+ exit 1
+ fi
+ fi
+
"$nvsetenv" boot-device "$boot_device" || {
echo "$nvsetenv failed."
echo "You will have to set boot-device manually. At the Open Firmware prompt, type:"
=== modified file 'util/grub-probe.c'
--- util/grub-probe.c 2011-11-08 11:38:30 +0000
+++ util/grub-probe.c 2011-11-11 00:02:52 +0000
@@ -55,7 +55,8 @@
PRINT_DEVICE,
PRINT_PARTMAP,
PRINT_ABSTRACTION,
- PRINT_CRYPTODISK_UUID
+ PRINT_CRYPTODISK_UUID,
+ PRINT_MSDOS_PARTTYPE
};
int print = PRINT_FS;
@@ -231,6 +232,20 @@
goto end;
}
+ if (print == PRINT_MSDOS_PARTTYPE)
+ {
+ if (dev->disk->partition == NULL)
+ {
+ grub_util_info ("no partition map found for %s", dev->disk->name);
+ }
+
+ if (strcmp(dev->disk->partition->partmap->name, "msdos") == 0)
+ printf ("%02x", dev->disk->partition->msdostype);
+
+ printf ("\n");
+ goto end;
+ }
+
fs = grub_fs_probe (dev);
if (! fs)
grub_util_error ("%s", grub_errmsg);
@@ -296,7 +311,7 @@
\n\
-d, --device given argument is a system device, not a path\n\
-m, --device-map=FILE use FILE as the device map [default=%s]\n\
- -t, --target=(fs|fs_uuid|fs_label|drive|device|partmap|abstraction|cryptodisk_uuid)\n\
+ -t, --target=(fs|fs_uuid|fs_label|drive|device|partmap|abstraction|cryptodisk_uuid|msdos_parttype)\n\
print filesystem module, GRUB drive, system device, partition map module, abstraction module or CRYPTO UUID [default=fs]\n\
-h, --help display this message and exit\n\
-V, --version print version information and exit\n\
@@ -357,6 +372,8 @@
print = PRINT_ABSTRACTION;
else if (!strcmp (optarg, "cryptodisk_uuid"))
print = PRINT_CRYPTODISK_UUID;
+ else if (!strcmp (optarg, "msdos_parttype"))
+ print = PRINT_MSDOS_PARTTYPE;
else
usage (1);
break;
next reply other threads:[~2011-11-11 14:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-11 14:02 Paulo de Rezende Pinatti [this message]
2011-11-11 15:11 ` [PATCH] Enable install of grub2 in PReP partition Vladimir 'φ-coder/phcoder' Serbinenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EBD2AE0.7020200@linux.vnet.ibm.com \
--to=ppinatti@linux.vnet.ibm.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.