vds89

20_memtest86+

Jan 2nd, 2023
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. #!/bin/sh
  2. set -e
  3.  
  4. if [ -f /usr/lib/grub/grub-mkconfig_lib ]; then
  5. . /usr/lib/grub/grub-mkconfig_lib
  6. LX=linux16
  7. elif [ -f /usr/lib/grub/update-grub_lib ]; then
  8. . /usr/lib/grub/update-grub_lib
  9. LX=linux
  10. else
  11. # no grub file, so we notify and exit gracefully
  12. echo "Cannot find grub config file, exiting." >&2
  13. exit 0
  14. fi
  15.  
  16. # We need 16-bit boot, which isn't available on EFI.
  17. if [ -d /sys/firmware/efi ]; then
  18. echo "Memtest86+ needs a 16-bit boot, that is not available on EFI, exiting" >&2
  19. exit 0
  20. fi
  21.  
  22. if [ -f /etc/default/grub ]; then
  23. GRUB_DISABLE_MEMTEST=`sed -n 's/^GRUB_DISABLE_MEMTEST=\(.*\)/\1/p' < /etc/default/grub`
  24. GRUB_MEMTEST_DISABLE_SERIAL=`sed -n 's/^GRUB_MEMTEST_DISABLE_SERIAL=\(.*\)/\1/p' < /etc/default/grub`
  25. GRUB_MEMTEST_ENABLE_MULTIBOOT=`sed -n 's/^GRUB_MEMTEST_ENABLE_MULTIBOOT=\(.*\)/\1/p' < /etc/default/grub`
  26. GRUB_MEMTEST_SERIAL_PARAMS=`sed -n 's/^GRUB_MEMTEST_SERIAL_PARAMS=\(.*\)/\1/p' < /etc/default/grub`
  27. fi
  28.  
  29. if [ "x${GRUB_MEMTEST_SERIAL_PARAMS}" = "x" ] ; then
  30. GRUB_MEMTEST_SERIAL_PARAMS="ttyS0,115200n8"
  31. fi
  32.  
  33. # With GRUB_DISABLE_MEMTEST=true don't add memtest entries
  34. if [ "x${GRUB_DISABLE_MEMTEST}" = "xtrue" ] ; then
  35. exit 0
  36. fi
  37.  
  38. # We can't cope with loop-mounted devices here.
  39. case ${GRUB_DEVICE_BOOT} in
  40. /dev/loop/*|/dev/loop[0-9]) exit 0 ;;
  41. esac
  42.  
  43. export TEXTDOMAIN=memtest86+
  44.  
  45. prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
  46.  
  47. if test -e /boot/memtest86+.elf ; then
  48. MEMTESTPATH=$( make_system_path_relative_to_its_root "/boot/memtest86+.elf" )
  49. echo "Found memtest86+ image: $MEMTESTPATH" >&2
  50. cat << EOF
  51. menuentry '$(gettext_printf "Memory test (memtest86+.elf)")' {
  52. EOF
  53. printf '%s\n' "${prepare_boot_cache}"
  54. cat << EOF
  55. knetbsd $MEMTESTPATH
  56. }
  57. EOF
  58. fi
  59.  
  60. if [ "x${GRUB_MEMTEST_DISABLE_SERIAL}" != "xtrue" -a -e /boot/memtest86+.bin ]; then
  61. MEMTESTPATH=$( make_system_path_relative_to_its_root "/boot/memtest86+.bin" )
  62. echo "Found memtest86+ image: $MEMTESTPATH" >&2
  63. cat << EOF
  64. menuentry '$(gettext_printf "Memory test (memtest86+.bin, serial console)")' {
  65. EOF
  66. printf '%s\n' "${prepare_boot_cache}"
  67. cat << EOF
  68. $LX $MEMTESTPATH console=${GRUB_MEMTEST_SERIAL_PARAMS}
  69. }
  70. EOF
  71. fi
  72.  
  73. if [ "x${GRUB_MEMTEST_ENABLE_MULTIBOOT}" = "xtrue" -a -e /boot/memtest86+_multiboot.bin ]; then
  74. MEMTESTPATH=$( make_system_path_relative_to_its_root "/boot/memtest86+_multiboot.bin" )
  75. echo "Found memtest86+ multiboot image: $MEMTESTPATH" >&2
  76. cat << EOF
  77. menuentry '$(gettext_printf "Memory test (memtest86+, experimental multiboot)")' {
  78. EOF
  79. printf '%s\n' "${prepare_boot_cache}"
  80. cat << EOF
  81. multiboot $MEMTESTPATH
  82. }
  83. EOF
  84. if [ "x${GRUB_MEMTEST_DISABLE_SERIAL}" != "xtrue" ]; then
  85. cat << EOF
  86. menuentry '$(gettext_printf "Memory test (memtest86+, serial console, experimental multiboot)")' {
  87. EOF
  88. printf '%s\n' "${prepare_boot_cache}"
  89. cat << EOF
  90. multiboot $MEMTESTPATH console=${GRUB_MEMTEST_SERIAL_PARAMS}
  91. }
  92. EOF
  93. fi
  94. fi
Advertisement
Add Comment
Please, Sign In to add comment