help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coerce Grub2 to display partition LABEL in displayed menu


From: Jordan Uggla
Subject: Re: Coerce Grub2 to display partition LABEL in displayed menu
Date: Fri, 9 Feb 2018 21:55:25 -0800

There are multiple ways to approach this problem, and my personal
preference for your case would be to disable os-prober and write
custom menuentries manually. These menuentries would then use
configfile to load the grub.cfg from your other OSs, rather than
having your custom menuentries include commands that directly load a
kernel. This way, your menus always stay up to date, and you can make
the titles whatever makes the most sense to you.

For some details, to disable os-prober in the OS that's controlling
the grub menu add GRUB_DISABLE_OS_PROBER=true to /etc/default/grub and
re-run grub-mkconfig to generate a new grub.cfg. You'll probably also
want to make a reasonable name for GRUB_DISTRIBUTOR to know which
installation the menuentries from the controlling OS will boot.

To add custom entries, create a new file /boot/grub/custom.cfg (*not*
grub.cfg) to store your entries. I prefer this to editing
/etc/grub.d/40_custom because you can make changes without having to
re-run grub-mkconfig and because I generally think that users
shouldn't touch anything in /etc/grub.d/ .

Two menuentry examples would be:

menuentry "Debian Stretch, the Foobar one" {
    search --set=root --fs-uuid UUID_HERE
    configfile /boot/grub/grub.cfg
}

menuentry "Debian Stretch, but with more baz" {
    search --set=root --fs-uuid BAZ_UUID_HERE
    configfile /boot/grub/grub.cfg
}


Another solution would be to modify the scripts in /etc/grub.d/ to use
labels in generated menuentries. I would not recommend this because
whenever an improvement to these scripts is made, your new changes
will need to be merged with the new grub.d scripts, including hassle
from your package manager when the upgrade happens (even if the merge
would be trivial). You might also get good results by just changing
GRUB_DISTRIBUTOR in each distro's /etc/default/grub . I am writing
this email quickly so I haven't checked if that would solve your
problem.


If I have some time tomorrow I'll also post a snippet that you could
add to your custom.cfg that will check at boot for all
/boot/grub/grub.cfg files on all volumes and generate menuentries for
them where the menuentry title contains the filesystem's label.

-- 
Jordan Uggla (Jordan_U on irc.freenode.net)

On Fri, Feb 9, 2018 at 7:12 AM, Richard Owlett <address@hidden> wrote:
> How do I coerce Grub2 to display partition LABEL in displayed menu, instead
> of device id - i.e. sda1 ... sda10.
>
> I have one machine dedicated to experimenting. It has multiple (differently
> configured) installs of the same Linux release.
>
> *WITHOUT* manually editing grub.cfg each time I add/remove an OS how force
> the menu to display the carefully chosen meaningful partition label. I don't
> care if grub uses UUID's internally. I want a meaningful menu displayed.
>
>
>
> _______________________________________________
> Help-grub mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-grub



reply via email to

[Prev in Thread] Current Thread [Next in Thread]