Re: Grub menu entry for a system on a second drive.
On Fri 25 Oct 2024 at 13:51:06 (-0400), Felix Miata wrote:
> My actual custom stanzas are in /boot/grub2/custom.cfg, because I use only one
> bootloader per PC, no matter how many installations it contains, which averages in
> excess of 20, and I use whatever version of Grub2 that Tumbleweed provides,
> usually the latest available. That shouldn't make any difference in Debian use,
> other than the "2" in directory name.
>
> In /etc/grub.d/ I copy 41_custom to 07_custom. Then I empty 41_custom and make it
> immutable so that the entries 07_custom refers to are not duplicated by 41_custom
> after every time whatever Grub package providing it is updated.
Do you mean that the previously inserted copies of custom.cfg are
preserved, and a new copy inserted, each time grub-mkconfig runs?
If that's not the case, then does it really matter that you have
the same menuentry contents at positions 07 and 41?
> Details of 40_custom use I'm completely unfamiliar with, as I've never used it,
> though I empty and lock it the same it as I do 41_custom.
It's static, and just gets inserted as is, which you can see from
any grub.cfg created in the normal manner. Mine currently contains:
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Install Debian via HTTP" {
search --no-floppy --label --set=root noah03
linux /boot/vmlinuz priority=low
initrd /boot/initrd.gz
}
on a machine that can't reliably boot from a USB stick,
particularly a Debian netinst confection. (The two files come from
http://http.us.debian.org/debian/dists/<codename>/main/install
er-i386/current/images/hd-media/
rather than
https://cdimage.debian.org/cdimage/release/current/amd64/iso-cd/
)
I also use 07_custom on the same machine, avoiding the
filename versioning in the system-generated entries:
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry 'My bullseye' $menuentry_id_option 'custom' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
search --no-floppy --set=root --label noah03
echo 'Load /vmlinuz …'
linux /vmlinuz root=LABEL=noah03 ro systemd.show_status=true quiet
echo 'Load initial ramdisk /initrd.img …'
initrd /initrd.img
}
> Manual editing of /boot/grub/grub.cfg does not persist. Every kernel addition or
> removal causes its regeneration anew based upon the content of /etc/default/grub
> and the regeneration script(s), same as running grub-mkconfig.
FTR, editing the Grub menu itself is, of course, totally ephemeral.
Type whatever you like, boot from it, and the edits are gone for good.
But editing /boot/grub/grub.cfg does persist as long as
that particular grub.cfg is not reconfigured with
grub-mkconfig/update-grub, which is done by kernel upgrades,
and, of course, the very occasional Grub upgrades.
I postprocess my grub.cfg files as a matter of routine, mainly
to convert UUIDs to LABELs, but also to uniquify them, if I may
use that word. In the OP's case, I would do just that: after
grub-mkconfig/update-grub runs, I would edit grub.cfg to add
something, anything, to one or more menuentry labels; say,
Debian 2024-10-25 A GNU/Linux so that you can correlate
the menu you later see with the file you earlier wrote.
Cheers,
David.
Reply to: