On my Fedora-40 Linux x86_64 laptop box, /boot/grub2/grub.cfg is configured to use BLSCFG - could anyone please explain more about BLSCFG , and how I might use it from bash command line to list menu entries so that I can use grub2-reboot command, giving menu entry number ?
The problem is, my /boot/grub2/grub.cfg thus uses DYNAMIC menu-entries , ie. BLSCFG looks at what is in the /boot/vmlinux* on the target boot device and then chooses the latest / last booted entry ?
Then how can I tell FC-40 to âreboot to selected grub menu entryâ with the grub2-reboot command , if I cannot list the menu entries ?
I want to ensure, if âlernel-install add âŚâ has rebuilt the Rescue kernel initramfs & done UEFI cfg updates AFTER it has rebuilt the non-rescue kernel images & done its cfg, then the non-rescue kernel remains the default next boot kernel, or I can SET the default next boot kernel with grub2-reboot . How, precisely can I do this if BLSCFG is in use ?
ie. I am looking for some âgrub2-show-menu-entriesâ shell script / command , that displays menu entry index #s I can pass to grub2-reboot âŚ
I donât know how to set the index for the next boot dynamically which seems to be what you are asking. If the grub menu is displayed it is easy to select on-screen, or the default index can be set. But selecting the entry dynamically from a script or the cli seems difficult at best.
Grub works from the configuration file and is loaded by the bios before the os is loaded, so it cannot be controlled from the OS, but only by using the config file.
Note that the GRUB_DEFAULT="saved" entry (which can also be set to an index number) sets the default to be booted without using the grub menu and that then gets put into the grub.cfg file when running grub2-mkconfig. Changes are not dynamic since it must be saved into the grub.cfg file before rebooting.
Then I think at least the âgrub2-rebootâ command manual page is in need of a major overhaul ?
RE: > that then gets put into the grub.cfg file when running grub2-mkconfig
No, NO proper grub Menu Entry syntax text sections are added to /boot/grub2/grub.cfg
except those I added manully in a local /etc/grub.d/ conf file for my bootable VMs .
This is the problem - yes , it is easy to parse the menu entries if they exist, but they donât.
ie. maybe I should raise a grub2 âRequest for Improvementâ bugzilla:
âProvide a method to store and list the Sequence of Grub Menu Entries if BLSCFG==true is setâ :
Couldnât grub2+, IFF BLSCFG is true (set) (and perhaps if some new
GRUB_XML_MENU=/boot/grub2/Menu.xml" is set ?), write a /boot/grub2/Menu.xml file with
the ( Sequence #, Name, VM Linux Path, Boot Args) for each Menu entry as XML nodes,
on each boot, with the chosen entry with a âSelected=trueâ node / attribute, then this file could be
very easily parsed by any script.
But best longterm method would be if grub would write some permanent record of
the actual generated menu entry list used, together with which was the selected entry.
But thatâs the whole point, with BLSCFG enabled there is no need to have extra entries in grub.cfg & Co.
AFAIK, the grub loader compiles the list on-the-fly and does not rely anymore on fixed entries that could get misconfigured.
see /boot/grub2/grub.cfg
insmod blscfg
blscfg
and the comments in this file regarding blscfg.
I did not try to use grub2-reboot, so I don´t know it it works with BLSCFG, but you can change settings with grubby and change the default kernel or kernel-index to something else, not for the next boot only, though.
e.g. sudo grubby -set-default-index=1 would boot the 2nd kernel in the list.