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

Re: Clarification Re: Customizing Grub menus



On Thu 09 Dec 2021 at 09:09:42 (-0600), Richard Owlett wrote:
> On 12/08/2021 06:33 AM, Richard Owlett wrote:
> > I have a machine set aside for experimenting with different
> > configurations of Debian. The default Grub2 menu will display
> > OS(with version) and partition designation in /dev/sdXY format.
> > 
> > I give all partitions descriptive labels.
> > I want the Grub menu to display OS and the partition label.
> > I want it to update appropriately after using update-grub.
> > 
> > Is there an appropriate tool?
> > TIA
> > 
> 
> Received answers did not seem to answer my question.
> That suggests a unclear question ;}
> 
> On my test system partition labels are:
>   /dev/sda7	full-10
>   /dev/sda9	minimal-11
> 
> Default Grub menu after install of buster reads:
>   Debian GNU/Linux 10 (buster) (on /dev/sda7)

I would recommend you use UUID rather than kernel names.
You get the syntactic sugar (like --fs-uuid, which you
replace with --label), and you don't have to change
anything if you fit an SSD in place of spinning rust.

> I wish it to read:
>   Debian GNU/Linux 10 (buster) (full-10)
> 
> After installing bullseye and running update-grub without any manual
> intervention, I wish appropriate lines to read:
>   Debian GNU/Linux 10 (buster) (full-10)
>   Debian GNU/Linux 10 (bullseye) (minimal-11)
> 
> Possible?

Yes, though you have a little scripting to do.

> If so, how?

First, you run lsblk -o UUID,LABEL (or lsblk -lo NAME,LABEL
if you insist), extracting the values to make a lookup
table UUID/NAME → LABEL.

Then you read the grub.cfg that's just been generated and,
for each menuentry, pick up the UUID from $menuentry_id_option
at the end of the line, and insert the corresponding LABEL
before the second quote at the beginning of the line.

While you're about it, you could modify the root=UUID=…
values, and also the --fs-uuid --set=root …, if you like.
You could also do some tidying up, as the file is stuffed
with code that you probably don't use or need.

How to avoid manual intervention: either you drop your
script into /etc/grub.d/ with a higher number than the
rest, or you insert the update-grub command at the beginning
of your script. (The latter is closer to my own method.)

Cheers,
David.


Reply to: