16

I want to change my default boot OS in GRUB2. But the only way I know of seeing the order of the OS I want in the GRUB menu is doing a reboot and seeing the menu displayed.

In grub.cfg there are many more menuentry lines than actual choices in the GRUB menu, so I can't identify in that file the one I want.

Is there any place where the actually displayed menu is stored so that I can see it without having to reboot?

daisy
  • 54,555
ARX
  • 457

3 Answers3

21

Note: This answer was originally written when legacy grub was used. It has been updated to work with GRUB2.

I believe that grub2-emu should work for you. In a terminal, execute:

sudo apt install grub2-emu && grub2-emu

enter image description here

See here for more information.

Be aware: You have to set focus to the terminal in which you started the emulator to be able to do inputs! The window of the emulator self will not react to any inputs at all.

eyoung100
  • 6,252
  • 23
  • 53
daisy
  • 54,555
  • 2
    Yep, this is the answer. Thanks! By the way, how do you close the grub-emu window? When I open it, my keyboard becomes unresponsive and the only thing that works is closing the terminal window from which I run grub-emu. – ARX Nov 19 '17 at 02:19
  • @ARX Have you tried the reboot or exit command in GRUB? – daisy Nov 19 '17 at 02:27
  • 1
    Can't. No keyboard. While grub-emu's window is focused, it's dead. – ARX Nov 19 '17 at 05:03
  • 7
    NOTE: Type in the ORIGINAL shell window (where you start it from), not the "display"-window. After c (for grub prompt) and then exit the Shell-prompt is missing, type reset (a command from 'terminfo') and ENTER to get it back. – Hannu Nov 19 '17 at 17:08
  • 2
    That last comment should be added to the answer IMHO. – pchaigno May 08 '18 at 10:24
  • 2
    The accepted answer is fine, but make sure the run the grub-emu as sudo. Without sudo, grub-emu would just jump to the grub commandline, which won't be as useful. – ryuzaki Jun 23 '19 at 13:06
  • Pity that not available for Redhat Linux :-( – Muzammil Mar 07 '22 at 17:27
  • ℹ️ In grub.cfg you can control if the emulator launches in the terminal or in a separate window with the command terminal_output [output]. Where output can be console, gfxterm or both. – Alberto Salvia Novella Feb 27 '24 at 11:07
6

grub2-theme-preview__gutsblack-archlinux

You can install grub2-theme-preview, which is a PyPi package. It uses QEMU and seems to work well for testing grub themes and this without having to restart after every change.

It's also available directly from AUR, which is the version I used, as I'm using Manjaro.

It requires the following non-PyPi dependencies (see README.md for links, more details and potential updates):

  • grub-mkrescue of GRUB 2 (package grub-common on Debian and Ubuntu)
  • QEMU — hypervisor that performs hardware virtualization
  • OVMF — EFI bios image for use with QEMU
  • mtools — collection of utilities to access MS-DOS
  • xorriso of libisoburn — frontend which enables creation and expansion of the ISO format
  • And python / pip, of course

To install, run the following command:

pip install --user grub2-theme-preview

Once installed you can run grub2-theme-preview /path/to/your/theme/directory from the terminal to launch it (more on usage here.)

Note: if you have any custom configs, e.g. custom.cfg or, say, liveiso.cfg, that you pull into your grub.cfg separately, thanks to the script in /etc/grub.d/41_custom, for example, their entries may not show up, in which case you'll need to use the newly added --add flag. Your command might look like the following, with --add TARGET=/SOURCE for each custom config you want added:

grub2-theme-preview --verbose --grub-cfg /boot/grub/grub.cfg --add /boot/grub/custom.cfg=/boot/grub/custom.cfg --add /boot/grub/gpu-switcher.cfg=/boot/grub/gpu-switcher.cfg --add /boot/grub/liveiso.cfg=/boot/grub/liveiso.cfg /usr/share/grub/themes/manjaro

More context here: https://github.com/hartwork/grub2-theme-preview/issues/29#issuecomment-980802808


You can also check out the answers here if you want something a bit more terminal centric and only needing to see order. This awk command, for example, will give you entries and sub entries as well:

awk -F\' '/(^|| )nuentry / {print $2}' /boot/grub/grub.cfg|cat -n|awk '{print $1-1,$1="",$0}'

Source


I like these options better than grub-emu, as that seems to have an issue closing, without having to close your terminal completely, as mentioned in the comments of that answer. Plus, grub2-theme-preview will actually show you the theme (although it does require more dependency setup) and the awk command is quick and easy; perhaps add it as an alias if you use it often so you don't have to remember it.

Pang
  • 241
Natetronn
  • 161
0

grub-emu works fine for me. I simply use the following command to kill grub-emu if it gets stuck.

ps -a | grep grub-emu | cut -d' ' -f2 | xargs kill -9