Build grub.img for loading grub from within syslinux
authorUlrich Dangel <mru@grml.org>
Thu, 22 Dec 2011 14:50:03 +0000 (15:50 +0100)
committerUlrich Dangel <mru@grml.org>
Thu, 22 Dec 2011 22:08:05 +0000 (23:08 +0100)
This should fix the problem that loading grub from syslinux on usb devices
does not work.

etc/grml/fai/config/scripts/GRMLBASE/45-grub-images [moved from etc/grml/fai/config/scripts/GRMLBASE/45-efi with 60% similarity]
grml-live
templates/boot/grub/addons.cfg
templates/boot/isolinux/addon_10_grub2.cfg

similarity index 60%
rename from etc/grml/fai/config/scripts/GRMLBASE/45-efi
rename to etc/grml/fai/config/scripts/GRMLBASE/45-grub-images
index 673ac6b..75fc1b2 100755 (executable)
@@ -8,18 +8,6 @@
 
 set -e
 
 
 set -e
 
-if ! ifclass AMD64 ; then
-  echo "Not in AMD64 class but EFI feature is restricted to amd64 only, skipping."
-  exit 0
-fi
-
-set -u
-
-if ! [ -r "${target}"/usr/lib/grub/x86_64-efi/moddep.lst ] ; then
-  echo "/usr/lib/grub/x86_64-efi/moddep.lst could not be found, skipping."
-  echo "NOTE: grub-efi-amd64-bin not installed?"
-  exit 0
-fi
 
 BOOTX64="${target}/boot/bootx64.efi"
 EFI_IMG="${target}/boot/efi.img"
 
 BOOTX64="${target}/boot/bootx64.efi"
 EFI_IMG="${target}/boot/efi.img"
@@ -41,13 +29,41 @@ BOOTX64="${BOOTX64##${target}}"
 EFI_IMG="${EFI_IMG##${target}}"
 TMP_CONFIG="${TMP_CONFIG##${target}}"
 
 EFI_IMG="${EFI_IMG##${target}}"
 TMP_CONFIG="${TMP_CONFIG##${target}}"
 
-$ROOTCMD grub-mkimage -O x86_64-efi -o "$BOOTX64" --prefix=/boot/grub/ --config="$TMP_CONFIG" \
-  bitmap boot btrfs cat chain cmp configfile cpio echo efi_gop       \
-  efi_uga elf ext2 fat gfxmenu gfxterm gzio help iso9660 jpeg linux  \
-  loopback lvm minicmd multiboot normal part_gpt part_msdos play png \
-  probe raid regexp reiserfs search search_fs_file search_fs_uuid    \
-  search_label squash4 terminal test video videoinfo xfs
+ARCHS=(i386-pc)
 
 
+declare -A ADDITIONAL_MODULES
+ADDITIONAL_MODULES[i386-pc]="biosdisk"
+
+if ifclass AMD64 ; then
+  if [ -r "${target}"/usr/lib/grub/x86_64-efi/moddep.lst ] ; then
+    ARCHS+=(x86_64-efi)
+    ADDITIONAL_MODULES[x86_64-efi]="efi_gop efi_uga"
+  else
+    echo "/usr/lib/grub/x86_64-efi/moddep.lst could not be found, skipping."
+    echo "NOTE: grub-efi-amd64-bin not installed?"
+  fi
+fi
+
+BOOTX64="${BOOTX64##${target}}"
+EFI_IMG="${EFI_IMG##${target}}"
+TMP_CONFIG="${TMP_CONFIG##${target}}"
+
+for arch in ${ARCHS[@]} ; do
+$ROOTCMD grub-mkimage -O $arch -o /boot/$arch.img --prefix=/boot/grub/ --config="$TMP_CONFIG" \
+  bitmap boot btrfs cat chain cmp configfile cpio echo elf ext2    \
+  fat gfxmenu gfxterm gzio help iso9660 jpeg linux loopback lvm    \
+  memdisk minicmd multiboot normal part_gpt part_msdos play png    \
+  probe raid regexp reiserfs search search_fs_file search_fs_uuid  \
+  search_label squash4 terminal test video videoinfo xfs ${ADDITIONAL_MODULES[$arch]}
+done
+
+if [ -f "${target}/boot/i386-pc.img" ] ; then
+  mv "${target}/boot/i386-pc.img" "${target}/boot/grub/grub.img"
+fi
+
+if [ -f "${target}/boot/x86_64-efi.img" ] ; then
+  mv "${target}/boot/x86_64-efi.img" "${target}/${BOOTX64}"
+fi
 if ! [ -r "${target}/${BOOTX64}" ] ; then
   echo "Can not access grub efi image." >&2
   exit 1
 if ! [ -r "${target}/${BOOTX64}" ] ; then
   echo "Can not access grub efi image." >&2
   exit 1
index 2c4d4a2..e2719b1 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -902,6 +902,7 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
        cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.lst "${BUILD_OUTPUT}"/boot/grub/
        cp -a "${CHROOT_OUTPUT}"/usr/share/grub/ascii.pf2 "${BUILD_OUTPUT}"/boot/grub/
        cp -a "${CHROOT_OUTPUT}"/boot/grub/core.img "${BUILD_OUTPUT}"/boot/grub/
        cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.lst "${BUILD_OUTPUT}"/boot/grub/
        cp -a "${CHROOT_OUTPUT}"/usr/share/grub/ascii.pf2 "${BUILD_OUTPUT}"/boot/grub/
        cp -a "${CHROOT_OUTPUT}"/boot/grub/core.img "${BUILD_OUTPUT}"/boot/grub/
+       cp -a "${CHROOT_OUTPUT}"/boot/grub/grub.img "${BUILD_OUTPUT}"/boot/grub/
 
        if ! [ -d "${TEMPLATE_DIRECTORY}"/GRML ] ; then
           log    "Error: ${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting."
 
        if ! [ -d "${TEMPLATE_DIRECTORY}"/GRML ] ; then
           log    "Error: ${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting."
index b25b1e1..ed04291 100644 (file)
@@ -46,7 +46,7 @@ else
         module      /boot/addons/bsd4grml/boot.5 boot.5
         module      /boot/addons/bsd4grml/boot.6 boot.6
         module      /boot/addons/bsd4grml/boot.cfg boot.cfg
         module      /boot/addons/bsd4grml/boot.5 boot.5
         module      /boot/addons/bsd4grml/boot.6 boot.6
         module      /boot/addons/bsd4grml/boot.cfg boot.cfg
-        module      /boot/grub/core.img core.img
+        module      /boot/grub/grub.img grub.img
     }
 fi
 
     }
 fi
 
index ad0c1b1..cc81c64 100644 (file)
@@ -1,7 +1,7 @@
 label grub2
   menu label Run Bootloader Grub^2
   kernel /boot/addons/bsd4grml/ldbsd.com
 label grub2
   menu label Run Bootloader Grub^2
   kernel /boot/addons/bsd4grml/ldbsd.com
-  append echo Loading GRUB...`machine exec grub /boot/grub/core.img
+  append echo Loading GRUB...`machine exec grub /boot/grub/grub.img
 
   text help
                                         Start Bootloader Grub (version 2).
 
   text help
                                         Start Bootloader Grub (version 2).