On Sun, 21 Jul 2024 at 15:27, David Wright <deb...@lionunicorn.co.uk> wrote:
> On Sun 21 Jul 2024 at 10:45:59 (+0000), David wrote:
> > On Sun, 21 Jul 2024 at 09:46, Thomas Schmitt <scdbac...@gmx.net> wrote:
> > > hede wrote:

> > Don't be discouraged by all the junk that the autogenerated grub.cfg
> > contains these days, most of it is not necessary. I have never had any
> > trouble ignoring it completely and just writing something simple in the 
> > style
> > of grub1. That way you can take advantage of the very useful scripting
> > language that grub2 provides, and hopefully make it do exactly what you 
> > want.

> "All the junk" that you're ignoring will be the code that implements
> properly what you're trying to do with Grub. Overall, it's a hack, but
> you don't need to hack on top of the hack.

[snip]

> The hack is booting Windows after starting via the power button.

Oh, thanks for the extra info, when writing my answer I forgot the
requirement to boot into Windows. That's something I really don't
care to know about any more.

grub2 autogenerated files are full of un-necessary junk and are
so complicated that users are expected to only interact with them
indirectly through constrained configfiles and are deterred from
instead just writing the code themselves for what they want to
accomplish, which was the old way. grub2 is very cool and supports
functions for example, but unfortunately the autogenerated files dont
take advantage of that feature, so they are hard to read and break
the "do not repeat yourself" principles, with the same UUIDs for
example appearing in multiple places.

Here
  https://paste.debian.net/1323940/
is an example of what my grub.cfg files look like, for anyone who
is interested in different approaches. I maintain them manually
and disable or deflect the autogeneration.
The approach is to use grub1 style stanzas created by functions.
The magnetic disk layout is 3 unencrypted primary partitions boot,
X and Y, and one more partition is encrypted LVM containing bootable
logical volumes A,B,C,D,E. Partition table is MSDOS format.
I prefer the use of functions because it makes it easy to manually
edit them and see useful diffs in version control.

This probably would be more helpful if I wrote a blog post about
it or contributed to the code, but I'm busy with other projects and
don't have time to do that, so I'm just throwing it out here for
anyone interested. The example file is from a laptop
running Debian 11, so it's a bit out of date, but I wanted to show
a simple one. My hardware isn't "modern", I don't care because
it meets my needs.

Thanks to the regular contributors here for sharing your
knowledge, I learn a lot, and so I occasionally try to give back.
But I know that others here are more capable or more dedicated
to doing that than I am, so I am mostly a reader not a writer here.

Reply via email to