On Mon, 18 Dec 2023 at 22:15, Felix Miata <mrma...@earthlink.net> wrote: > > I can't answer why Grub scripts to what the do, because I don't really use > them, > and don't need to understand much about them. Grub config files in > /boot/grub/ are > akin to scripts, but they are really simple, mainly just command scripts. The > usual one is grub.cfg, the one os-prober feeds from other Linux > installations. A > less common one is custom.cfg. To use it requires the admin build it. When it > exists, grub-mkconfig incorporates its use by/in grub.cfg. It actually gets > called > by default from /etc/grub.d/41_custom, which adds the stanzas from it to the > Grub > boot menu - after those that it has generated itself. I copy it to > /etc/grub.d/07_custom, and empty 41_custom. That causes my custom stanzas to > appear first in Grub's boot menu. /etc/grub.d/40_custom acts, and a copy of > it as > 06_custom would act, in similar fashion, except that the admin's custom > stanzas > are put into it by the admin instead of into a custom.cfg file. > > Thus, you, as admin, construct working stanzas however you like, with or > without > UUIDS, with or without device names, with or without volume LABELS, however > you > like boot to go, and they don't get changed, except by the admin - you. This > is > easy, because you as admin can use the kernel (and initrd) symlinks Debian > puts in > /, or anywhere you'd like symlinks to them to go, for distros that don't > automatically create them for you. There's no need for maintenance when new > kernels are installed in the case of Debian and other distros that > automatically > generate new symlinks. For those that don't, creating them is trivial. >
I have just tried this, I see 41_custom in /etc/grub.d and I see that the text from that file ends up in my grub.cfg when I run update-grub. So I have disabled os-prober, since I won't need it if I can get this working, and created a cusom.cfg file with approximately what os-prober generated as manuentry stanza lines for my LFS instance (with references to os-prober removed and the root=/dev/sdc2 changed to root=PARTUUID=<part UUID>) And... on reboot, the menu entry for LFS is not included. Now looking closer at 41_custom, it says this: #!/bin/sh cat <<EOF if [ -f \${config_directory}/custom.cfg ]; then source \${config_directory}/custom.cfg elif [ -z "\${config_directory}" -a -f \$prefix/custom.cfg ]; then source \$prefix/custom.cfg fi EOF I read that as saying if custom.cfg exists *in whatever directory is pointed at by the variable config_directory*, then read that file. If the directory pointed at by config_directory doesn't exist and there is a custom.cfg in whatever directory is pointed at by the variable prefix, use that. The question is, what values are config_directory and prefix set to? "prefix" is referenced in other scripts in /etc/grub.d and set to /usr -- which is no use here as /usr is on the partition we are trying to find so grub won't be able to see that at boot time. The only script in that directory that references config_directory is 41_custom and it doesn't set it. Looking at my /boot/grub/grub.cfg it doesn't contain any references to config_directory except those that were copied from 41_custom. Am I supposed to change 41_custom or something? And if I am, I guess I would want it to say /grub/custom.cfg since this path is presumably relative to the root of the /boot partition, that at the time this is being consulted that is the only partition mounted? I feel like I am getting close but am not quite there. Mark