How to list and edit GRUB2's "menuentry" in command-line under Centos-8? - rhel

How to list GRUB2's “menuentries” in command-line under Centos-8?
The used workable method "fgrep menuentry /etc/grub2.conf" failed.
Because at Centos-8/RHEL-8, they DO NOT store menuentry in /etc/grub2.conf.
Instead, they search and build entries at booting runtime.
And how to add a custom cmdline parameter to special menuentry?
There is no menuentry in /etc/grub2.conf, I can not edit any menuentry.

Grub menu entries in RHEL/CentOS 8 are assembled from various files and scripts so we won't see static entries as was the case for previous versions of the OSes. (You can see the un-expanded boot entry configuration files located in the /boot/loader/entries/ directory)
In order to view the default menu entry, you can use:
grubby --info DEFAULT
In order to view all the menu entries, you can use:
grubby --info ALL
The latter also gives us the corresponding index for each of the entries that can be useful. For instance, the following will list the meny entry details for the 3rd entry:
grubby --info 2
In order to customize a specific entry you can do so by either referencing the index:
grubby --args amd_iommu=on --update-kernel 2
Or by simply using the kernel version as the following for the current kernel:
grubby --args amd_iommu=on --update-kernel=/boot/vmlinuz-$(uname -r)
Once you do a modification to an entry, the options should be expanded and listed in the corresponding entry file in /boot/loader/entries/ (otherwise you will see variables).

Unfortunately, grubby won't list menu entries that you've added to /boot/grub2/custom.cfg (loaded by /etc/grub.d/41_custom). I'm not sure if it will include entries loaded in /etc/grub.d/40_custom, either.
I've had some success seeing grub's menu entries by compiling grub2-emu and running that:
https://github.com/Jolicloud/grub2/blob/master/util/grub-emu.c
It's available in some repositories as the grub-emu or grub2-emu package. It shows you a simulation of the grub menu, as it would appear at boot time.

Related

where in menuconfig is CONFIG_SMP located?

when I do 'make menuconfig' and search for a config variable by typing /PL011, the search result shows where in the menu hierarchy the config variables are located and what the prompt value is. But in some cases like CONFIG_SMP, even if I type /SMP, it shows only the this.
Symbol: SMP [=y]
Type : bool
Defined at arch/arm64/Kconfig:304
But this doesn't help because I cannot find the menu for CONFIG_SMP and set the value as I want. If I change the arch/arm64/Kconfig file directly, it causes build error. Where is this CONFIG_SMP in the menu hierarchy (linux-5.10.0) and how can I find this kind of menu item in general?
I want to know how to get to the menu
The Kconfig definition for that config option has no menu prompt (in quotes).
config SMP
def_bool y
So that's the reason why you couldn't (and will not) find (or be able to change) CONFIG_SMP in the menu.
My previous suggestion of "defining it manually in a defconfig" is not feasible.
Any prior definition of the config option (using #CONFIG_SMP is not set or CONFIG_SMP=n) in either a _defconfig file or the .config file was ineffective in overriding the default value specified by the Kconfig. On exit from the 'make xxx_defconfig' or 'make menuconfig' procedure, the .config file would always contain CONFIG_SMP=y.
I'm inclined to believe that such configuration options are intended to be fixed for that arch, and are not intended to be changed. Your unspecified "build failures" lend credence to this belief.
Perhaps you need to reevaluate why you want to change this config option from its default value.

How to create a consistent .config file to compile Linux kernel?

To compile Linux kernel, I created a default .config file using make defconfig. Since I didn't want to browse thousands of options through a menu-driven interface (make menuconfig), I set CONFIG_KALLSYMS=n manually, and then triggered the build (make -j8). I noticed the build system overwrote my changes and set CONFIG_KALLSYMS=y again. I suspect there might be other options present in the configuration which rely on CONFIG_KALLSYMS. How can I create a consistent .config file without using any menu-driven interface?
It might be burdensome to browse thousands of options through a menu-driven interface (make menuconfig). When you only want to change a couple of options and don't remember where they are in the menu hierarchy, you can use search to find any specific option. Just press / (slash) and type the full or partial name of the option. The result of the search will show where the options are located in the menu hierarchy, and what are the dependencies. Save and exit after you are done with the changes, and you should have a consistent .config file.
After you create a .config using make defconfig, to change just a few config options after that "make menuconfig" is the best way to do this. It also tells you about the dependencies and doesn't allow you to make a change unless the dependencies are met.

how to let cg_annotate include a dictionary?

I've tried to use cg_annotate to include a dictionary by use --include flag. However, no matter what I typed after --include=, it always shows the manual (indicating that my path is wrong).
for example, I typed ".util" after --include= but it shows the manual:
the sceenview
The official manual says:
-I --include= [default: none] Adds a directory to the list in which to search for files. Multiple -I/--include options can be given to add multiple directories.
There is no 'dictionnary' of directories stored somewhere, you always have
to give the list of directories each time you launch cg_annotate.
So, in your case, the mandatory argument cachegrind-out-file is not provided in your command. This causes cg_annotate to stop and show its usage.
You might possibly use kcachegrind (and --tool=callgrind), as kcachegrind has some support for specifying source directories (if ever that is needed, as normally kcachegrind+callgrind will find automatically the source files).
To add some directories in kcachegrind, you can use the menu entry Settings->Configure Kcachegrind and add directories in the Annotations tab.

Centos option deletion possible

In my boot options of my installed CentOS on VBox, I have the followings that really mess me up to figure out how to eliminate those that doesn't work anymore, e.g the first one which is reported as unavailability of kernel root to boot. I can only choose the last one to boot the system.
> CentOS(2.6.32-200.17.1.e16.x86_64)
> CentOS(2.6.32-200.17.1.e16.x86_64.debug)
> CentOS(2.6.32-200.4.2.e16.x86_64.debug)
> CentOS(2.6.32-200.4.2.e16.x86_64)
> CentOS(2.6.32-200.4.1.e16.x86_64)
> CentOS(2.6.32-200.e16.x86_64)
Where are these stored once I boot the system with the last option ? What if I would like to delete (completely) one of them ? I don't know what the xxx.debug's are there for ?
Thank you for any help
On most distros today the boot manager is GRUB. The configuration of boot menu is usually stored in /boot/grub in a file called menu.lst or grub.cfg depending on GRUB version and distro. In that file, you can comment out sets of lines corresponding to the OS you don't want in the menu - syntax should be pretty intuitive.
On some distros the file is generated by a set of scripts, in this case a comment at the top say you shouldn't edit that file directly. For example in Debian, the scripts which generate the configuration reside in /etc/grub.d/ and they do all sorts of auto-probing for available OS's. In this case one needs to either modify the script or to remove the OS images which are automatically appended to the menu. The exact way to do this cleanly may vary depending on your setup - perhaps some of these boot images can be removed using a package manager which would be more elegant than just removing files manually.
Either way, be careful, since removing the wrong file related to booting may make it impossible to boot your OS or even to start GRUB at all if you're extremely unlucky.

What is the recommended way to perform source-level debugging of system library calls? [duplicate]

I have a need to debug into some calls in system libraries, to understand how the calls differ, and why one or another would be failing.
It is now common for Linux distros to provide stripped system libraries and separate debug symbol files. For example, /lib/libc-2.8.so is stripped of symbols, leaving behind a section named .gnu_debuglink that contains info to find a separate debug file. The separate debug files are installable through a debug package, and contain symbolic info needed by gdb. It's well described here http://www.technovelty.org/code/debug-info-symbols.html and http://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
After installing the debug package and the sources, I was expecting that GDB would find the symbols and sources and I would be able to view listings and step into the calls. Instead, gdb tells me "no line number known for xyz"
I've verified that debug-file-location is correct, and directories is set to the source directories.
Is it even possible to do what I want? Am I going about this the wrong way? Is there a simpler way?
Did you try to set the debug-file-directory parameter in GDB? As per the documentation you pointed out, it should do what you want:
set debug-file-directory directories
Set the directories which gdb searches for separate debugging
information files to directory. Multiple directory components can be
set concatenating them by a directory separator.
show debug-file-directory
Show the directories gdb searches for separate debugging
information files.
For instance in my Fedora distribution, the directory is /usr/lib/debug.
You can also define it at compile time with
configure --with-separate-debug-dir=/usr/lib/debug ...

Resources