* Add --memdisk parameter to grub-install
@ 2013-02-06 22:41 Paulo Flabiano Smorigo/Brazil/IBM
2013-02-25 22:06 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 1 reply; 2+ messages in thread
From: Paulo Flabiano Smorigo/Brazil/IBM @ 2013-02-06 22:41 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 818 bytes --]
Hi all,
This patch adds an option to store all modules inside the core. This
approach follows the suggestion from:
http://lists.gnu.org/archive/html/grub-devel/2012-10/msg00053.html
It works this way:
grub rescue> set
prefix=(mduuid/f897565f27383014091630e267aa4720)/grub
root=mduuid/f897565f27383014091630e267aa4720
grub rescue> set root=memdisk
grub rescue> set prefix=($root)/
grub rescue> ls /
powerpc-ieee1275/
grub rescue> insmod normal
grub rescue> normal
GNU GRUB version 2.00
Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists possible
device or file completions.
grub>
Tks!
--
Paulo Flabiano Smorigo
Software Engineer
Linux Technology Center - IBM Systems & Technology Group
[-- Attachment #2: grub_install_memdisk.patch --]
[-- Type: text/x-patch, Size: 4482 bytes --]
=== modified file 'ChangeLog'
--- ChangeLog 2013-02-06 16:37:29 +0000
+++ ChangeLog 2013-02-06 22:08:33 +0000
@@ -1,3 +1,7 @@
+2013-02-06 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
+
+ * util/grub-install.in: New option --memdisk.
+
2013-02-06 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/lsacpi.c: Fix types on 64-bit platform.
=== modified file 'util/grub-install.in'
--- util/grub-install.in 2013-01-27 15:17:21 +0000
+++ util/grub-install.in 2013-02-06 22:08:48 +0000
@@ -50,6 +50,8 @@
bootdir=
grubdir="`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`"
modules=
+memdisk=no
+memdisk_img=
install_device=
force_lba=
@@ -110,6 +112,7 @@
print_option_help "--removable" "$(gettext "the installation device is removable. This option is only available on EFI.")"
print_option_help "--bootloader-id=$(gettext "ID")" "$(gettext "the ID of bootloader. This option is only available on EFI.")"
print_option_help "--efi-directory=$(gettext "DIR")" "$(gettext "use DIR as the EFI System Partition root.")"
+ print_option_help "--memdisk" "$(gettext "include all modules in memdisk.")"
echo
gettext "INSTALL_DEVICE must be system device filename.";echo
echo
@@ -240,6 +243,9 @@
--no-nvram)
update_nvram=no ;;
+ --memdisk)
+ memdisk=yes ;;
+
# This is an undocumented feature...
--debug)
debug=yes ;;
@@ -558,6 +564,22 @@
exit 1
fi
+if test $memdisk = yes; then
+ memdisk_dir="`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+
+ mkdir -p "${memdisk_dir}"/"${grub_modinfo_target_cpu}-${grub_modinfo_platform}"
+
+ for file in "${source_dir}"/*.mod "${source_dir}"/*.lst; do
+ cp -f "$file" "${memdisk_dir}"/"${grub_modinfo_target_cpu}-${grub_modinfo_platform}" || exit 1
+ done
+
+ memdisk_img=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
+ (cd "${memdisk_dir}"; tar -cf - *) > "${memdisk_img}"
+ rm -rf "${memdisk_dir}"
+
+ modules="$modules memdisk tar"
+fi
+
# Write device to a variable so we don't have to traverse /dev every time.
grub_device="`"$grub_probe" --device-map="${device_map}" --target=device "${grubdir}"`" || exit 1
@@ -710,11 +732,15 @@
*) imgext=img ;;
esac
-if [ x"$config_opt_file" = x ]; then
- "$grub_mkimage" -d "${source_dir}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" --prefix="${prefix_drive}${relative_grubdir}" $modules || exit 1
-else
- "$grub_mkimage" -c "${config_opt_file}" -d "${source_dir}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" --prefix="${prefix_drive}${relative_grubdir}" $modules || exit 1
-fi
+additional_options=
+if [ x"$config_opt_file" != x ]; then
+ additional_options="-c \"${config_opt_file}\""
+fi
+if [ x"$memdisk_img" != x ]; then
+ additional_options="${additional_options} -m ${memdisk_img}"
+fi
+
+"$grub_mkimage" ${additional_options} -d "${source_dir}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" --prefix="${prefix_drive}${relative_grubdir}" $modules || exit 1
# Backward-compatibility kludges
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "mipsel-loongson" ]; then
@@ -723,13 +749,12 @@
cp "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" "${grubdir}/grub"
elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-efi" ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "x86_64-efi" ]; then
- if [ x"$config_opt_file" = x ]; then
- "$grub_mkimage" -d "${source_dir}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/grub.efi" --prefix="" $modules || exit 1
- else
- "$grub_mkimage" -c "${config_opt_file}" -d "${source_dir}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/grub.efi" --prefix="" $modules || exit 1
- fi
+ "$grub_mkimage" ${additional_options} -d "${source_dir}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/grub.efi" --prefix="" $modules || exit 1
fi
+if [ x"$memdisk_img" != x ]; then
+ rm -f "${memdisk_img}"
+fi
# Perform the grub_modinfo_platform-dependent install
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "sparc64-ieee1275" ] ; then
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Add --memdisk parameter to grub-install
2013-02-06 22:41 Add --memdisk parameter to grub-install Paulo Flabiano Smorigo/Brazil/IBM
@ 2013-02-25 22:06 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2013-02-25 22:06 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 1368 bytes --]
>It works this way:
>grub rescue> set
>prefix=(mduuid/f897565f27383014091630e267aa4720)/grub
>root=mduuid/f897565f27383014091630e267aa4720
>grub rescue> set root=memdisk
>grub rescue> set prefix=($root)/
>grub rescue> ls /
>powerpc-ieee1275/
>grub rescue> insmod normal
>grub rescue> normal
If you have to type this then obviously patch isn't finished work. You
need to point prefix to right point and have grub.cfg find and source
the definite grub.cfg.
You also need to include other files in memdisk like fonts and
translations. Having multi-prefix (prefix=a:b:c) and helpers to load
files from any of them is a possibility as long as it doesn't increase
core size.
Also you need to make a list of platforms which don't support this
approach. Currently:
Inherently: i386_pc
Due to choice of memory map: i386_coreboot, i386_multiboot,
i386_ieee1275, i386_qemu.
This should also be extended to grub-mknetdir.
It should also probably share more code with grub-mkstandalone.
On 06.02.2013 23:41, Paulo Flabiano Smorigo/Brazil/IBM wrote:
> -fi
> +additional_options=
> +if [ x"$config_opt_file" != x ]; then
> + additional_options="-c \"${config_opt_file}\""
> +fi
> +if [ x"$memdisk_img" != x ]; then
> + additional_options="${additional_options} -m ${memdisk_img}"
> +fi
> +
This breaks orribly in presence of whitespaces.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-02-25 22:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-06 22:41 Add --memdisk parameter to grub-install Paulo Flabiano Smorigo/Brazil/IBM
2013-02-25 22:06 ` Vladimir 'φ-coder/phcoder' Serbinenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).