Skip to content

Commit

Permalink
Ensure GRUB finds the running ISO
Browse files Browse the repository at this point in the history
Instead of relying on the presence of the /conf/bootid.txt file, which
might be present on several Grml ISOs, let's generate a unique filename
which GRUB then can search for.

JFTR: The redirection within the layers (scripts/GRMLBASE/45-grub-images
vs main grml-live script) is necessary, because the GRUB image is
generated from within the rootfs (grml_chroot), but the rootfs is
compressed within a squashfs file, while we can only access files
available directly inside the ISO (corresponding to the files inside
grml_cd, and not the files inside grml_chroot which
scripts/GRMLBASE/45-grub-images has access to).
  • Loading branch information
mika committed Nov 22, 2018
1 parent c036873 commit 642e1b3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
9 changes: 7 additions & 2 deletions etc/grml/fai/config/scripts/GRMLBASE/45-grub-images
Expand Up @@ -11,12 +11,17 @@ set -u

TMP_CONFIG="/tmp/grub_config_efi"

# this allows us to find this specific Grml ISO,
# even if there are multiple Grml ISOs present
bootfile="${GRML_NAME}_$(TZ=UTC date +%s)"
echo "$bootfile" > "${target}/"boot/grub/bootfile.txt

cat > "${target}/${TMP_CONFIG}" <<EOF
search.file /conf/bootid.txt root
search.file /conf/bootfile_$bootfile root
set prefix=(\$root)/boot/grub
insmod normal
normal
echo "E: Could not find root device!"
echo "E: Could not find root device (for /conf/bootfile_$bootfile)!"
EOF

ARCHS=(i386-pc)
Expand Down
20 changes: 20 additions & 0 deletions grml-live
Expand Up @@ -1011,6 +1011,26 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
eend $?
fi

# every recent Grml ISO ships a /conf/bootid.txt, though GRUB might find
# the /conf/bootid.txt of a different (Grml) ISO than the one that's
# supposed to be running, so within scripts/GRMLBASE/45-grub-images
# we generate a random filename, stored inside /boot/grub/bootfile.txt,
# which we place on the resulting ISO here
if [ -r "${CHROOT_OUTPUT}"/boot/grub/bootfile.txt ] ; then
mkdir -p "${BUILD_OUTPUT}"/conf
rm -f "${BUILD_OUTPUT}"/conf/bootfile* # ensure we don't leave any old(er) files behind

einfo "Generating "${BUILD_OUTPUT}"/conf/bootfile* files"
log "Generating "${BUILD_OUTPUT}"/conf/bootfile* files"

# save information about the random filename inside /conf/bootfile.txt
echo "/conf/bootfile_$(cat "${CHROOT_OUTPUT}"/boot/grub/bootfile.txt)" > \
"${BUILD_OUTPUT}"/conf/bootfile.txt
echo "# This file is relevant for GRUB boot with the Grml ISO." > \
"${BUILD_OUTPUT}"/conf/bootfile_"$(cat "${CHROOT_OUTPUT}"/boot/grub/bootfile.txt)"
eend $?
fi

grub_setup

# EFI boot files
Expand Down

0 comments on commit 642e1b3

Please sign in to comment.