2 # Filename: ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/45-efi
3 # Purpose: create grub image for use in ISO for EFI boot
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2 or any later version.
7 ################################################################################
11 if ! ifclass AMD64 ; then
12 echo "Not in AMD64 class but EFI feature is restricted to amd64 only, skipping."
18 if ! [ -r "${target}"/usr/lib/grub/x86_64-efi/moddep.lst ] ; then
19 echo "/usr/lib/grub/x86_64-efi/moddep.lst could not be found, skipping."
20 echo "NOTE: grub-efi-amd64-bin not installed?"
24 GRUB_EFI_IMAGE="${target}/tmp/grub_efi_image"
25 TMP_CONFIG="${target}/tmp/grub_config_efi"
26 EFI_IMAGE="${target}/tmp/efi_image"
28 rm -f "$GRUB_EFI_IMAGE" "$TMP_CONFIG" "$EFI_IMAGE"
30 cat > "$TMP_CONFIG" <<EOF
31 search --set -f /conf/bootid.txt root
32 if [ -e /boot/grub/grub.cfg ]; then
33 set prefix=\$root/boot/grub
34 configfile /boot/grub/grub.cfg
36 echo "E: Could not find root device!"
40 GRUB_EFI_IMAGE="${GRUB_EFI_IMAGE##${target}}"
41 TMP_CONFIG="${TMP_CONFIG##${target}}"
42 EFI_IMAGE="${EFI_IMAGE##${target}}"
44 $ROOTCMD grub-mkimage -O x86_64-efi -o "$GRUB_EFI_IMAGE" --prefix=/boot/grub/ --config="$TMP_CONFIG" \
45 bitmap boot btrfs cat chain cmp configfile cpio echo efi_gop \
46 efi_uga elf ext2 fat gfxmenu gfxterm gzio help iso9660 jpeg linux \
47 loopback lvm minicmd multiboot normal part_gpt part_msdos png \
48 probe raid reiserfs search search_fs_file search_fs_uuid \
49 search_label terminal test video videoinfo xfs
51 if ! [ -r "${target}/${GRUB_EFI_IMAGE}" ] ; then
52 echo "Can not access grub efi image." >&2
56 SIZE=$(du -sk "${target}/${GRUB_EFI_IMAGE}" | awk -F" " '{print $1'})
57 SIZE=$(((($SIZE / 32 )+2)*32))
59 dd if=/dev/zero of="${target}/${EFI_IMAGE}" bs=1k count="$SIZE" 2>/dev/null
60 $ROOTCMD mkfs.vfat -n GRML "$EFI_IMAGE" >/dev/null
61 $ROOTCMD mmd -i "$EFI_IMAGE" ::EFI
62 $ROOTCMD mmd -i "$EFI_IMAGE" ::EFI/BOOT
63 $ROOTCMD mcopy -i "$EFI_IMAGE" "$GRUB_EFI_IMAGE" ::EFI/BOOT/bootx64.efi >/dev/null
65 rm -f "${target}/${TMP_CONFIG}"
66 mv "${target}/${EFI_IMAGE}" "${target}/var/lib/grml_live_efi.img"
67 mv "${target}/${GRUB_EFI_IMAGE}" "${target}/var/lib/grml_live_bootx64.efi"
69 echo "Generated EFI image ${target}/var/lib/grml_live_efi.img"
70 echo "Generated bootx64 image ${target}/var/lib/grml_live_bootx64.efi"
72 ## END OF FILE #################################################################
73 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2