Extending Grub2 to detect Memtest+

Grub2 using Gentoo doesn’t detect if a Memtest86+ boot image is available – so I tried to come up with a solution which looks as follows:

20_memtest86+:


#! /bin/sh
set -e

# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see .

prefix=/usr
exec_prefix=${prefix}
bindir=/bin
libdir=/lib64
datarootdir=${prefix}/share

. ${libdir}/grub/grub-mkconfig_lib

MEMTEST86_IMAGE="/boot/memtest86plus/memtest.bin"
CLASS="--class memtest86 --class gnu --class tool"

if [ -e $MEMTEST86_IMAGE ] && is_path_readable_by_grub $MEMTEST86_IMAGE; then
# image exists, create menu entry
echo "Found memtest86+ image: $MEMTEST86_IMAGE" >&2
cat << EOF menuentry "Memory test (memtest86+)" $CLASS { EOF prepare_grub_to_access_device `${grub_probe} --target=device $MEMTEST86_IMAGE` | sed -e "s/^/ /" cat << EOF linux16 (\$root)`make_system_path_relative_to_its_root $MEMTEST86_IMAGE` } EOF fi

Author:

One thought on “Extending Grub2 to detect Memtest+”

  • Der Tipp war gut, auch wenn es ausreicht einen fixen Eintrag in der Config immer wieder anzuhängen.

Leave a Reply

Your email address will not be published. Required fields are marked *