53

If using UEFI Please see this question, "Can I boot memtest86+ if I'm using UEFI?"

After having installed the 64bit version of Ubuntu 12.04 on my Lenovo B570 I ran into the same problems I had when installing 11.10 with Grub not playing nicely with a uEFI system. I used the same technique as last time to solve the problem (using a Super Grub Disc LiveCD session to repair Grub) and my system happily dual boots between Ubuntu and Windows 7

However now when I boot up the Grub menu only displays

  • Ubuntu, with Linux 3.2.0-24-generic
  • Ubuntu, with Linux 3.2.0-24-generic (recovery mode)
  • Previous Linux versions
  • Windows 7 (loader) (on /dev/sda1)
  • Windows Recovery Environment (loader) (on /dev/sda4)

I no longer see the option to use Memtest86+ which was there previously, having checked in the Ubuntu Software Center I can see that the package is installed, but how to I make the option to run it once again appear in the Grub menu?

I've tried:

sudo update-grub 

which doesn't make any difference.

sudo chmod +x /etc/grub.d/20_memtest86+ 

results in:

chmod: cannot access /etc/grub.d/20_memtest86+': No such file or directory

and entering

ls /etc/grub.d/

results in:

00_header        10_linux      30_os-prober  41_custom
05_debian_theme  20_linux_xen  40_custom     README
sourcejedi
  • 448
  • 3
  • 15
coversnail
  • 6,336
  • 14
  • 40
  • 70

6 Answers6

32

Try opening a terminal and running

sudo chmod +x /etc/grub.d/20_memtest86+
sudo update-grub

Check to see if it's there

grep memtest /boot/grub/grub.cfg

Just done the same as I had it disabled

hob@hob-HP-dx5150-MT:~$ cat /boot/grub/grub.cfg |grep memtest
hob@hob-HP-dx5150-MT:~$ sudo chmod +x /etc/grub.d/20_memtest86+
[sudo] password for hob: 
hob@hob-HP-dx5150-MT:~$ sudo update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-24-generic
Found initrd image: /boot/initrd.img-3.2.0-24-generic
Found linux image: /boot/vmlinuz-3.2.0-23-generic
Found initrd image: /boot/initrd.img-3.2.0-23-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Ubuntu 11.10 (11.10) on /dev/sda6
Found Trisquel 5.5 (5.5) on /dev/sda8
Found Ubuntu 12.04 LTS (12.04) on /dev/sda9
done
hob@hob-HP-dx5150-MT:~$ cat /boot/grub/grub.cfg |grep memtest
### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
    linux16 /boot/memtest86+.bin
menuentry "Memory test (memtest86+, serial console 115200)" {
    linux16 /boot/memtest86+.bin console=ttyS0,115200n8
### END /etc/grub.d/20_memtest86+ ###

You could try creating the file if it's not there, using nano in a terminal

sudo nano /etc/grub.d/20_memtest86+

or with a gui editor

gksudo gedit /etc/grub.d/20_memtest86+

Fill it with

#!/bin/sh
set -e

if [ -f /usr/lib/grub/grub-mkconfig_lib ]; then
  . /usr/lib/grub/grub-mkconfig_lib
  LX=linux16
elif [ -f /usr/lib/grub/update-grub_lib ]; then
  . /usr/lib/grub/update-grub_lib
  LX=linux
else
  # no grub file, so we notify and exit gracefully
  echo "Cannot find grub config file, exiting." >&2
  exit 0
fi

# We can't cope with loop-mounted devices here.
case ${GRUB_DEVICE_BOOT} in
  /dev/loop/*|/dev/loop[0-9]) exit 0 ;;
esac

prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"

if test -e /boot/memtest86+.bin ; then
  MEMTESTPATH=$( make_system_path_relative_to_its_root "/boot/memtest86+.bin" )
  echo "Found memtest86+ image: $MEMTESTPATH" >&2
  cat << EOF
menuentry "Memory test (memtest86+)" {
EOF
  printf '%s\n' "${prepare_boot_cache}"
  cat << EOF
    $LX $MEMTESTPATH
}
menuentry "Memory test (memtest86+, serial console 115200)" {
EOF
  printf '%s\n' "${prepare_boot_cache}"
  cat << EOF
    $LX $MEMTESTPATH console=ttyS0,115200n8
}
EOF
fi

#if test -e /boot/memtest86+_multiboot.bin ; then
#  MEMTESTPATH=$( make_system_path_relative_to_its_root "/boot/memtest86+_multiboot.bin" )
#  echo "Found memtest86+ multiboot image: $MEMTESTPATH" >&2
#  cat << EOF
#menuentry "Memory test (memtest86+, experimental multiboot)" {
#EOF
#  printf '%s\n' "${prepare_boot_cache}"
#  cat << EOF
#   multiboot   $MEMTESTPATH
#}
#menuentry "Memory test (memtest86+, serial console 115200, experimental multiboot)" {
#EOF
#  printf '%s\n' "${prepare_boot_cache}"
#  cat << EOF
#   multiboot   $MEMTESTPATH console=ttyS0,115200n8
#}
#EOF
#fi

Make sure to run the chmod +x command on it afterwards.

I'd be a bit concerned that it's missing though - do you have everything else in grub.d ?

ls /etc/grub.d/


00_header        10_linux.bak       20_memtest86+  41_custom
05_debian_theme  10_linux.dpkg-old  30_os-prober   README
10_linux         20_linux_xen       40_custom
23 93 26 35 19 57 3 89
  • 5,596
  • 1
  • 29
  • 37
  • `sudo chmod +x /etc/grub.d/20_memtest86+` resulted in: `chmod: cannot access /etc/grub.d/20_memtest86+': No such file or directory` – coversnail Apr 27 '12 at 14:34
  • Edited answer to include this – 23 93 26 35 19 57 3 89 Apr 27 '12 at 19:57
  • Added ls /etc/grub.d/ result to question, no mention of memtest, but your answer has now made it work perfectly, thank you. – coversnail Apr 27 '12 at 20:18
  • 1
    I found `20_memtest86+` lurking in `/etc/grub.d.bak/` somehow. Moved it into place, updated GRUB and everything worked fine for me. – Naftuli Kay Jan 08 '13 at 07:29
  • 5
    `update-grub` doesn't find memtest binary no matter what I do :( – expert Dec 17 '15 at 18:28
  • That file is present and filled with those contents and with those permissions, I added semicolons so you know when the lines of the output end: aaronfranke@aaron-xubuntu:/etc/grub.d$ sudo update-grub; Generating grub configuration file ...; Found linux image: /boot/vmlinuz-4.4.0-22-generic; Found initrd image: /boot/initrd.img-4.4.0-22-generic; Found linux image: /boot/vmlinuz-4.4.0-21-generic; Found initrd image: /boot/initrd.img-4.4.0-21-generic; Found Windows Boot Manager on /dev/sdb2@/EFI/Microsoft/Boot/bootmgfw.efi; Adding boot menu entry for EFI firmware configuration; done; – Aaron Franke May 15 '16 at 18:40
  • 3
    what could be the reason if the file is present but still the option does not come out to the grub menu? – Mpizos Dimitris Feb 20 '17 at 18:10
  • 8
    isn't this because the GPL versions of memtest don't support EFI? So if you are booting through EFI, there is _no way_ to get memtest to work using what's shipped with Ubuntu?? – Jeff Atwood Feb 23 '17 at 09:37
  • 3
    I got the following, X@ubuntu:~$ cat /boot/grub/grub.cfg | grep memtest ### BEGIN /etc/grub.d/20_memtest86+ ### ### END /etc/grub.d/20_memtest86+ ### – DarrenRhodes Apr 26 '17 at 21:30
  • I tried this and after choosing memtest86+ I got blank page, but if I click "enter" or "f1" it makes the bip as it running ,do you any suggestions ? – enjoy343322434 Nov 15 '17 at 21:45
  • @JeffAtwood POKE – Evan Carroll Apr 24 '18 at 08:15
  • when I typed ```sudo nano /etc/grub.d/20_memtest86+``` it opens up the file with everything already in it. But the chmod command doesn't recognise the file nor can I search with grep. I have Ubuntu dual booted with windows. – Awakened Aug 07 '20 at 11:56
  • Linux can do memtest https://unix.stackexchange.com/a/439769/105120 – user1133275 Jan 04 '21 at 20:05
23
apt install memtest86+

This will automatically reconfigure grub and add the entry to the boot menu.

If you get the error memtest86+ is already the newest version then use sudo apt-get install --reinstall memtest86+

If all else fails you can get a bootable ISO that you can burn to a CD and boot from. Of course if you are booting UEFI you should be here instead.

Michael Franzl
  • 652
  • 1
  • 6
  • 12
  • 1
    For Ubuntu 16.04 server this was exactly the solution. Without `apt-get install memtest86+` mentioned file `/etc/grub.d/20_memtest86+` was not present on my system. – mstrap Jul 17 '17 at 08:47
  • 1
    @mstrap, it was the solution for me too. I don't understand why my answer was downvoted two times. – Michael Franzl Jul 18 '17 at 10:44
  • 1
    This solution did not work for me - the above command received a `memtest86+ is already the newest version` message. I suspect this solution only works for non UEFI systems while the original question is specifically regarding memtest on UEFI systems. – Jaydin Jan 01 '18 at 23:23
  • 2
    This didn't work for me either, like JayDin memtest was already installed. I used synaptik package manager to remove memtest, rebooted then re-installed it. This fixed the problem for me. – user111667 Mar 04 '19 at 04:36
  • Does this work on a live USB? – Aaron Franke Nov 29 '21 at 02:46
15

I had the same issue, and due to the fact that I have EFI on my laptop the memtest86+ version 4.x shipped by ubuntu won't work, since EFI is only supported by version 5 and newer.

The latest versions are non-GPL and must be downloaded manually from the memtest website(they have ISO and USB images), but at least they are free of charge.

  • 2
    http://www.memtest86.com/download.htm – Marcos Apr 16 '15 at 22:56
  • 1
    The latest versions are non-GPL and must be downloaded manually from the memtest website(they have ISO and USB images), but at least they are free of charge. memtest86 is non-GPL and proprietary and memtest86+ is GPL. – Ramchandra Apte Aug 12 '15 at 05:33
6

I didn't managed to make this work in 2 days, then I checked Synaptic for grub packages... Seems to be, that the absence of package grub-imageboot are the root of the problem.

sudo apt-get install grub-imageboot
Braiam
  • 66,947
  • 30
  • 177
  • 264
PLaci
  • 61
  • 1
  • 1
3

This what I did to add the now latest (non free) memtest86+ to the grub boot menu for UEFI booting. Current memtest version is 8.2. Tools needed: Disk Image Mounter and grub-customizer, the latter is only for convenience :) Files: memtest binary (see below)

  1. Download the memtest binary from: https://www.memtest86.com/download.htm The 'Image for creating bootable USB Drive on a Windows/Linux/Mac system' is fine.
  2. Extract the IMG file (memtest86-usb.img)
  3. open the img file with disk image mounter (right mouse button on Ubuntu)
  4. from the mounted image extract /EFI/BOOT/BOOTX64.efi
  5. make memtest86 boot directory:
    sudo mkdir /boot/efi/EFI/memtest86
  6. copy the BOOTX64.efi to your new folder on the boot partition (eg /boot/efi/EFI/memtest86)
  7. open grub-customizer
  8. Add menu item, give it a name, choose type: other
  9. add the following boot sequence (assuming you boot from hd0):
insmod part_gpt
insmod fat
set root='hd0,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  1A22-970F
else
  search --no-floppy --fs-uuid --set=root 1A22-970F
fi
chainloader /EFI/memtest86/BOOTX64.efi
  1. save and quit grub-customizer

  2. reboot and enjoy Memtest86

Vic
  • 391
  • 2
  • 9
  • For others/me: #3 Disk Image Mounter = gnome-disks. #6 must be root. #8 Why is type other not memtest? #9 how do you know if you boot from hd0? [click edit on your boot drive entry and copy the entry for that setroot]. Thanks for this excellent answer btw. – dez93_2000 Jul 12 '19 at 17:34
  • If one's ubuntu root is hd2 then presumably you change the 0 to 2 in 4 places, inc ahci? Regardless I get error no such device 1A22-970F & file '/EFI/memtest86/BOOTX64.efi' not found. File is defo in /boot/efi/EFI/memtest86/ . Any thoughts? Cheers – dez93_2000 Jul 12 '19 at 17:50
  • 1
    'error disk hd2,gpt2 not found' now appears with 'no such device'; file not found doesn't appear. not sure why it would change... – dez93_2000 Jul 12 '19 at 18:06
  • This may help others having issues mounting the EFI partition of the img file: https://ubuntuforums.org/archive/index.php/t-1576011.html – Natetronn Oct 21 '20 at 01:16
  • memtest86+ (https://www.memtest.org/) is free and GPL ! memtest86 (no plus sign here) (https://www.memtest86.com/) is not. I just sorted out that confusion for myself. – Martian2020 Nov 30 '21 at 01:47
  • Use "sudo blkid" to get the correct EFI partition UUID. For me the EFI partition was on /dev/sdb3 so root='hd1,gpt3' and ahci0 is replaced by ahci1 – leszek.hanusz Aug 17 '22 at 21:19
1

See also this answer on the Unix StackExchange. In short, the Linux Kernel has a simple memory test built in.

Do grep CONFIG_MEMTEST "/boot/config-$(uname -r)" to determine if it's enabled or not (it'll be commented out if it's not enabled).

Then, edit /etc/default/grub and add memtest to GRUB_CMDLINE_LINUX_DEFAULT, run sudo update-grub, and then reboot.

Once it's finished booting up (it'll take longer than normal given it has to also run the memory test), check /var/log/kern.log for the result of the test.

starbeamrainbowlabs
  • 1,187
  • 3
  • 17
  • 36