1

is it possible to reboot directly into the memtest86+ (without giving any input during boot) , like the Windows command mdsched does?

eadmaster
  • 299
  • 1
    You should be able to tweak the answers in https://askubuntu.com/questions/18170/how-to-reboot-into-windows-from-ubuntu to apply for memtest instead of Windows. – Byte Commander May 27 '19 at 15:45
  • 1
    if i use that script, it will keep booting into memtest86+ as default, while i'd like to run the tests only once. – eadmaster May 27 '19 at 15:54
  • memtest86+ runs infinitely - you must be present at restart anyway. – FelixJN May 27 '19 at 16:06
  • If you use EFI boot mode you can't run memtest+, there shouldn't be bootmenu entries in that case. See https://askubuntu.com/questions/917961/can-i-boot-memtest86-if-im-using-uefi – mook765 May 28 '19 at 05:11

1 Answers1

0

Using apropos we can see what app is used for the next boot only:

$ apropos "next boot only"
grub-reboot (8) - set the default boot entry for GRUB, for the next boot only

With using grub-reboot for a one-time boot, I have found that it is best to use the name of the entry and not the number of the entry like some of the linked answers here have had. I just cannot get it to work with the numbers of the entries. Here is something that I have found works with using the names of the entries.

If you cat the /boot/grub/grub.cfg there are a lot of entries that we are looking for. The one in particular is the Memory test entry.

$ grep -i "memory test" /boot/grub/grub.cfg
menuentry 'Memory test (memtest86+)' {
menuentry 'Memory test (memtest86+, serial console 115200)' {

Since all we need is just the first entry and we need the full name of Memory test (memtest86+) to tell the grub-reboot that is what we need, we can use the following line to grab only that name and the first entry, specified by the exit command.

awk -F"'" '/Memory test/ {print $2; exit}' /boot/grub/grub.cfg

Which gives us output like:

$ awk -F"'" '/Memory test/ {print $2; exit}' /boot/grub/grub.cfg
Memory test (memtest86+)

Now we can combine that line into our one line command to reboot our system to Memtest as a one-time boot.

sudo grub-reboot "$(awk -F"'" '/Memory test/ {print $2; exit}' /boot/grub/grub.cfg)"; reboot

The reboot part at the end will go ahead and reboot your system for now.

Hope this helps!

Terrance
  • 41,612
  • 7
  • 124
  • 183