Skip to content

Commit

Permalink
Rework memtest handling, incl. usage of latest available memtest file
Browse files Browse the repository at this point in the history
If we try to copy the memtest86+.bin file as shipped with memtest86+
versions <=5.01-3.1, we either copy such an old file from the build
directory (grml_chroot), or if that doesn't exist (e.g. because the
memtest86+ package isn't installed), we might end up copying an old
memtest file from the build host system instead.

AS ${BUILD_OUTPUT}/boot/addons/memtest exists already then, we don't
update the file any longer (e.g. from a more recent memtest86+ package),
and therefore end up with an old and outdated memtest version in BIOS
boot, while EFI boot provides a more recent memtest version. This is
inconsistent and unexpected behavior.

So instead try to use the most recent version of memtest86* files first,
and only then fall back to the old memtest86+ <=5.01-3.1 file behavior.

While looking into this, I also noticed that until memtest86+ versions
<=6.10-2 it used to be named memtest86+x32.bin, while as of memtest86+
versions >=6.10-3 it's memtest86+ia32.bin instead. As we have version
6.10-4 in bookworm/stable and only pre-6 version 5.01-3.1 in e.g.
bullseye/oldstable, let's skip any backwards compatibility for
memtest86+x32.bin.

Furthermore while at it, drop duplicate execution of `copy_addon_file
memtest86+x64.bin /boot addons` and `copy_addon_file memtest86+x32.bin
/boot addons` to avoid ending up with further duplicate files on the
ISO. So related to #128, we now
ship /boot/addons/memtest on each of grml64 + grml32, and respectively
only /boot/addons/memtest86+x64.efi on grml64 only and
/boot/addons/memtest86+ia32.efi on grml32 only. To rename the files into
FAT16/8.3 compatible "/boot/addons/memtest", let's provide a proper
return code from within copy_addon_file() if we couldn't find any
matching file.

Related to #128

Closes: grml/grml#178
  • Loading branch information
mika committed Oct 16, 2023
1 parent f365415 commit 1a9a788
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
36 changes: 21 additions & 15 deletions grml-live
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ copy_addon_file() {
msg="Missing addon file: \"$1\""
ewarn "$msg" ; eend 1
log "copy_addon_file: $msg"
return 1
}

# replace placeholders in template files with actual information
Expand Down Expand Up @@ -1193,34 +1194,39 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] || [ "$ARCH" = arm64 ] ; then
copy_addon_file ipxe.efi /usr/lib/ipxe addons
copy_addon_file pci.ids /usr/share/misc addons

# memtest86+ <=5.01-3.1
copy_addon_file memtest86+.bin /boot addons
# make memtest filename FAT16/8.3 compatible
if [ -r "${BUILD_OUTPUT}/boot/addons/memtest86+.bin" ] ; then
mv "${BUILD_OUTPUT}/boot/addons/memtest86+.bin" \
"${BUILD_OUTPUT}/boot/addons/memtest"
fi

# memtest86+ >=6.00-1
copy_addon_file memtest86+x32.bin /boot addons
copy_addon_file memtest86+x32.efi /boot addons
copy_addon_file memtest86+x64.bin /boot addons
copy_addon_file memtest86+x64.efi /boot addons
if [[ "$ARCH" == "amd64" ]] ; then
copy_addon_file memtest86+x64.efi /boot addons
elif [[ "$ARCH" == "i386" ]] ; then
copy_addon_file memtest86+ia32.efi /boot addons
fi

# provide memtest86+ >=6.00-1 files as "memtest" file
# for BIOS boot in isolinux/syslinux
if ! [ -r "${BUILD_OUTPUT}/boot/addons/memtest" ] ; then
if [[ "$ARCH" == "amd64" ]] ; then
copy_addon_file memtest86+x64.bin /boot addons
copy_addon_file memtest86+x64.bin /boot addons &&
# make memtest filename FAT16/8.3 compatible
mv "${BUILD_OUTPUT}/boot/addons/memtest86+x64.bin" \
"${BUILD_OUTPUT}/boot/addons/memtest"
elif [[ "$ARCH" == "i386" ]] ; then
copy_addon_file memtest86+x32.bin /boot addons
mv "${BUILD_OUTPUT}/boot/addons/memtest86+x32.bin" \
copy_addon_file memtest86+ia32.bin /boot addons &&
# make memtest filename FAT16/8.3 compatible
mv "${BUILD_OUTPUT}/boot/addons/memtest86+ia32.bin" \
"${BUILD_OUTPUT}/boot/addons/memtest"
fi
fi

# fallback: if we still don't have /boot/addons/memtest available, we
# might have an older memtest86+ version (<=5.01-3.1) which ships
# file "memtest86+.bin" instead
if ! [ -r "${BUILD_OUTPUT}/boot/addons/memtest" ] ; then
copy_addon_file memtest86+.bin /boot addons &&
# make memtest filename FAT16/8.3 compatible
mv "${BUILD_OUTPUT}/boot/addons/memtest86+.bin" \
"${BUILD_OUTPUT}/boot/addons/memtest"
fi

# since syslinux(-common) v3:6.03~pre1+dfsg-4 the files are in a
# different directory :(
if [ -d "${CHROOT_OUTPUT}/usr/lib/syslinux/modules/bios/" ] ; then
Expand Down
12 changes: 6 additions & 6 deletions templates/boot/grub/addons.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ if [ "${grub_platform}" == "efi" ] ; then
}
fi
else # assume i386
if test -e /boot/addons/memtest86+x32.efi ; then
menuentry "Memory test (memtest86+x32.efi)" {
linuxefi /boot/addons/memtest86+x32.efi
if test -e /boot/addons/memtest86+ia32.efi ; then
menuentry "Memory test (memtest86+ia32.efi)" {
linuxefi /boot/addons/memtest86+ia32.efi
}
fi
fi
Expand All @@ -39,10 +39,10 @@ if [ "${grub_platform}" != "efi" ] ; then
}
fi
else # assume i386
if test -e /boot/addons/memtest86+x32.bin ; then
menuentry "Memory test (memtest86+x32.bin)" {
if test -e /boot/addons/memtest86+ia32.bin ; then
menuentry "Memory test (memtest86+ia32.bin)" {
insmod linux16
linux16 /boot/addons/memtest86+x32.bin
linux16 /boot/addons/memtest86+ia32.bin
}
elif test -e /boot/addons/memtest ; then # fallback to old memtest
menuentry "Memory test (memtest86+)" {
Expand Down

0 comments on commit 1a9a788

Please sign in to comment.