Skip to content

Instantly share code, notes, and snippets.

@aont
Created June 16, 2025 15:41
Show Gist options
  • Save aont/0394c672e448906cf83ffd10c9cc29f3 to your computer and use it in GitHub Desktop.
Save aont/0394c672e448906cf83ffd10c9cc29f3 to your computer and use it in GitHub Desktop.

Adding memtest86+ to a Linux Live USB

Assuming you have already created an Ubuntu Live USB using Rufus, this guide explains how to add memtest86+ to the grub boot menu on that USB.

Item Value
Media Ubuntu 24.04 x86_64
Live USB Creation Method Rufus ISO mode

In Rufus ISO mode, a FAT partition is created on the USB, and the Ubuntu boot files and grub files are placed there.

Note: If booting via MBR (not EFI), the menu already shows Test memory, which can be used directly.

Easiest Method

Open /boot/grub/grub.cfg on the USB, where you will find something like:

if [ "$grub_platform" = "efi" ]; then
  (omitted)
else
  menuentry 'Test memory' {
    linux16 /boot/memtest86+x64.bin
  }

This Test memory entry is only shown for MBR boots. To enable it on EFI as well, add a similar menu entry under the EFI condition.

Since linux16 does not work on EFI, change it to linux like this:

if [ "$grub_platform" = "efi" ]; then
  (omitted)
  menuentry 'Test memory' {
    linux /boot/memtest86+x64.bin
  }
else
  menuentry 'Test memory' {
    linux16 /boot/memtest86+x64.bin
  }

Using Official Binary

Download from the official site: Memtest86+ | The Open-Source Memory Testing Tool

Select the Binary Files (.bin/.efi) option. At the time of writing, the link was: mt86plus_7.00.binaries.zip

From the archive, take memtest64.efi and place it on the USB, for example at /boot/memtest_efi.

Then edit /boot/grub/grub.cfg and add the following entries:

menuentry "Start Memtest86+, use built-in support for USB keyboards" {
    linux /boot/memtest_efi keyboard=both
}
menuentry "Start Memtest86+, use BIOS legacy emulation for USB keyboards" {
    linux /boot/memtest_efi keyboard=legacy
}
menuentry "Start Memtest86+, disable SMP and memory identification" {
    linux /boot/memtest_efi nosmp nosm nobench
}

These entries are based on those found under Linux ISO w/ GRUB (64 bits) from the official distribution.

Notes

  • The reason why memtest86+ is not enabled by default on EFI is unclear.
  • The official EFI binary was also bootable from MBR, and conversely the MBR binary booted from EFI as well (though full functionality was not verified).
  • The rationale for separate binaries is unknown.
  • Depending on the motherboard, selecting the appropriate binary may be necessary.

Final grub.cfg

Here is the final grub.cfg enabling both methods. The author slightly customized Ubuntu boot options (unrelated to memtest86+), so please ignore those parts:

set timeout=30

loadfont unicode

set menu_color_normal=white/black
set menu_color_highlight=black/light-gray

menuentry "Try or Install Ubuntu" {
	set gfxpayload=keep
	linux	/casper/vmlinuz  --- verbose
	initrd	/casper/initrd
}
menuentry "Ubuntu (safe graphics)" {
	set gfxpayload=keep
	linux	/casper/vmlinuz nomodeset  --- verbose
	initrd	/casper/initrd
}
menuentry "Console" {
	set gfxpayload=keep
	linux	/casper/vmlinuz  --- verbose systemd.unit=multi-user.target
	initrd	/casper/initrd
}
menuentry "Console (safe graphics)" {
	set gfxpayload=keep
	linux	/casper/vmlinuz nomodeset --- verbose systemd.unit=multi-user.target
	initrd	/casper/initrd
}
grub_platform
if [ "$grub_platform" = "efi" ]; then
menuentry 'Boot from next volume' {
	exit 1
}
menuentry 'UEFI Firmware Settings' {
	fwsetup
}
menuentry 'Test memory' {
	linux /boot/memtest86+x64.bin
}
menuentry "Start Memtest86+, use built-in support for USB keyboards" {
    linux /boot/memtest_efi keyboard=both
}
menuentry "Start Memtest86+, use BIOS legacy emulation for USB keyboards" {
    linux /boot/memtest_efi keyboard=legacy
}
menuentry "Start Memtest86+, disable SMP and memory identification" {
    linux /boot/memtest_efi nosmp nosm nobench
}
else
menuentry 'Test memory' {
	linux16 /boot/memtest86+x64.bin
}
menuentry "Start Memtest86+, use built-in support for USB keyboards" {
    linux /boot/memtest_mbr keyboard=both
}
menuentry "Start Memtest86+, use BIOS legacy emulation for USB keyboards" {
    linux /boot/memtest_mbr keyboard=legacy
}
menuentry "Start Memtest86+, disable SMP and memory identification" {
    linux /boot/memtest_mbr nosmp nosm nobench
}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment