1 |
Rich Freeman <rich0@g.o> wrote: |
2 |
> On Sun, Apr 17, 2022 at 3:00 PM Martin Vaeth <martin@×××××.de> wrote: |
3 |
>> |
4 |
>> Yes, without a manually written grub.cfg you get none of these features - |
5 |
>> the default grub.cfg is just horrible. |
6 |
>> Well, the most powerful feature is probably still available: |
7 |
>> The possibility to edit the kernel's command line, partition and path which |
8 |
>> theoretically can cover everything else, though it is rather inconvenient. |
9 |
|
10 |
Just to clarify: I mean to edit the kernel's command line immediately |
11 |
before booting (that is, for instance, in emergency cases like a non-booting |
12 |
new kernel together with a damaged init-system. Or when you are at a |
13 |
conference with your laptop and need to connect to a beamer which for some |
14 |
reason did not display anything so that perhaps forcing a different |
15 |
resolution helps. I had all this, and wouldn't like to miss grub in such |
16 |
situations). |
17 |
|
18 |
> The GRUB bootloader just parses its config file, which can be manually |
19 |
> edited as you point out. |
20 |
|
21 |
This config file has many shell-like features like functions and variables |
22 |
and can source helper libraries. I suggest to use of all this! (See below.) |
23 |
|
24 |
> You also have grub-mkconfig |
25 |
|
26 |
grub-mkconfig is meant for binary distributions. A gentoo user typically |
27 |
compiles the kernel manually, anyway, and they typically know precisely |
28 |
which kernel they want to boot. So they have no use for any of the |
29 |
(mis-)features from grub-mkconfig. |
30 |
They might use it *once* to get some grub.cfg to start with, but then |
31 |
I recommend to dump grub-mkconfig. |
32 |
|
33 |
> grub-mkconfig just runs a bunch of shell scripts to generate |
34 |
> everything [...] Obviously it would be more elegant to add a loop over |
35 |
> a configuration variable. |
36 |
|
37 |
That's not what I meant. I meant to dump grub-mkconfig completely and |
38 |
not writing any substitute for it. Instead, write your grub.cfg manually, |
39 |
making full use of its features like variables and functions. |
40 |
|
41 |
For instance, I have one menu entry for each init-system (openrc, |
42 |
systems, and 3 more for emergency shells). But selecting such an |
43 |
entry just changes a (grub.cfg) variable and does not boot yet. |
44 |
|
45 |
Then there are menu entries for selecting/editing the resolution |
46 |
variables, etc. |
47 |
|
48 |
And only a few menu entries are for actually choosing the kernel and |
49 |
booting it (according to the previously set variables). |
50 |
|
51 |
Of course, there are default values for the variables if I make no |
52 |
selection and a default boot entry as well which normally is |
53 |
auto-booted after a few seconds. |
54 |
|
55 |
Note that if I would like to have a separate entry for each |
56 |
combination I might ever have a need for, I would need hundreds of |
57 |
menu entries, as their number is exponential in the number of |
58 |
variables which are used. |
59 |
|
60 |
> I'm not aware of anybody having actually done this, however, so you'd |
61 |
> have to DIY. |
62 |
|
63 |
https://github.com/vaeth/grub-cfg-mv/releases/ |
64 |
You can install it with sys-boot/grub-cfg-mv in the mv overlay, but |
65 |
you still have to read the instructions and write the "main" grub.cfg |
66 |
by yourself (although you can start from the example and from the |
67 |
grub.cfg generated by one initial call of grub-mkconfig). |