enable LVM in Grub

  • Open
  • quality assurance status badge
Details
4 participants
  • Erik Eduardo
  • Emmanuel Beffara
  • Maxim Cournoyer
  • Michael Rohleder
Owner
unassigned
Submitted by
Emmanuel Beffara
Severity
normal
E
E
Emmanuel Beffara wrote on 11 Mar 2023 19:02
(address . bug-guix@gnu.org)
20230311190206.GD20567@beffara.org
Hello Guix,

Unless I missed something in the configuration process, the `grub.cfg`
generated by `guix system reconfigure` does not enable LVM, even if the store
is in an LVM volume. The immediate consequence is that Grub cannot load its
data files nor boot the system. The fix is as simple as adding `insmod lvm` in
`grub.cfg` before any `search` command, which I do by hand on each
`reconfigure`, but obviously Guix itself should do that.

I looked at `grub.scm` to see where things happen, and I see no mention of LVM
in this file. This surprises me because I am probably not the only one using
it. Actually, I use LVM on LUKS for full-system encryption, but this is
probably not rare either.

--
Emmanuel
M
M
Michael Rohleder wrote on 13 Mar 2023 14:56
(name . Emmanuel Beffara)(address . manu@beffara.org)
87sfe8n4ao.fsf@rohleder.de
Hello Emmanuel!

Thx for the report!

I think this is bug 44877, maybe we can/should merge it.
Here [1] is a patch (and testcase).


--
Man braucht zwei Jahre, um sprechen zu lernen,
und fünfzig, um schweigen zu lernen. E.Hemingway
-----BEGIN PGP SIGNATURE-----

iQFFBAEBCAAvFiEEdV4t5dDVhcUueCgwfHr/vv7yyyUFAmQPK38RHG1pa2VAcm9o
bGVkZXIuZGUACgkQfHr/vv7yyyV20Af/Y60a+oenaXE+D8/VWjvHjxtSoBkkMCeV
lwCiNFWRVogvjdDr+YeF2Rbr9xT1WhXcdkKkoucYol9ViQ6MB2D89q4TNo0+PtaD
FfJDh3SV9hb6aRHDnKU4jcXgcVVzSxKViyaTuiLblHCiPZ3ehBNh6cdNvDrP38S9
loYexndXef57MZ3ceFSK/i4ot/HzOePovQeRoVsY7ArXDK29xzrfsywqiVnfo9RF
Zdf6w2aPy69vJfBW84CRIrGTS+idq8A2ZRFxI5VsjYXxnZ8fX6R0SVOXZyHaVtPH
imFn+fqOqm0muIlNPKuB06xcB1iye4/unAVv6FdXHu13+1G3wwy4jg==
=ywS/
-----END PGP SIGNATURE-----

E
E
Emmanuel Beffara wrote on 14 Mar 2023 22:26
(name . Michael Rohleder)(address . mike@rohleder.de)
20230314222628.GE14391@beffara.org
De Michael Rohleder le 13/03/2023 à 14:56:
Toggle quote (10 lines)
> Hello Emmanuel!
>
> Thx for the report!
>
> I think this is bug 44877, maybe we can/should merge it.
> Here [1] is a patch (and testcase).
>
>
> [1] https://issues.guix.gnu.org/60442

Indeed, it seems to be the same issue.

However, the patch sets the value of `GRUB_PRELOAD_MODULES`, which afaik is
used by `grub-mkconfig` to produce `grub.cfg`, but there seems to be code in
`grub.scm` that also produces `grub.cfg`, and no call to `grub-mkconfig`
there. I'm not sure I understand how all this works anyway…

--
Emmanuel
M
M
Maxim Cournoyer wrote on 23 Mar 2023 13:48
(name . Emmanuel Beffara)(address . manu@beffara.org)
87v8ireiq9.fsf@gmail.com
Hi,

Emmanuel Beffara <manu@beffara.org> writes:

Toggle quote (18 lines)
> De Michael Rohleder le 13/03/2023 à 14:56:
>> Hello Emmanuel!
>>
>> Thx for the report!
>>
>> I think this is bug 44877, maybe we can/should merge it.
>> Here [1] is a patch (and testcase).
>>
>>
>> [1] https://issues.guix.gnu.org/60442
>
> Indeed, it seems to be the same issue.
>
> However, the patch sets the value of `GRUB_PRELOAD_MODULES`, which afaik is
> used by `grub-mkconfig` to produce `grub.cfg`, but there seems to be code in
> `grub.scm` that also produces `grub.cfg`, and no call to `grub-mkconfig`
> there. I'm not sure I understand how all this works anyway…

Guix indeed takes care to generate the grub.cfg itself, via the
make-grub-configuration procedure from (gnu bootloader grub), and
grub-mkconfig is *not* used.

grub-install is used though, so perhaps GRUB_PRELOAD_MODULES could be
honored by it (although it's not documented so I doubt it). It seems to
me that since we produce grub.cfg ourselves if there's something to add
there for LVM support (which I'm not sure there is -- apparently it
already works for you ?), it should be explicitly coded in (gnu
bootloader grub).

info '(grub) Changes from GRUB Legacy' mentions that "* GRUB 2 can read
files directly from LVM and RAID devices.", so I would think there's
nothing special to do?

--
Thanks,
Maxim
E
E
Emmanuel Beffara wrote on 23 Mar 2023 15:58
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
20230323155819.GC5268@beffara.org
Hello,

De Maxim Cournoyer le 23/03/2023 à 13:48:
Toggle quote (5 lines)
> It seems to me that since we produce grub.cfg ourselves if there's something
> to add there for LVM support (which I'm not sure there is -- apparently it
> already works for you ?), it should be explicitly coded in (gnu bootloader
> grub).

It does not work for me, that is why I reported this! The system does not boot
unless I manually add `insmod lvm` in `grub.cfg` because Grub does not find
the partition that contains the store.

So I agree something has to be done there.

Toggle quote (4 lines)
> info '(grub) Changes from GRUB Legacy' mentions that "* GRUB 2 can read
> files directly from LVM and RAID devices.", so I would think there's nothing
> special to do?

As I understand it, this just means that Grub 2 has a module for reading LVM
devices and a module for reading RAID devices. But it still has to load them
somehow (unless there is a way to include them statically so they are
available from the beginning).

--
Emmanuel
M
M
Maxim Cournoyer wrote on 24 Mar 2023 13:24
(name . Emmanuel Beffara)(address . manu@beffara.org)
87edpe1gn5.fsf@gmail.com
Hi,

Emmanuel Beffara <manu@beffara.org> writes:

Toggle quote (14 lines)
> Hello,
>
> De Maxim Cournoyer le 23/03/2023 à 13:48:
>> It seems to me that since we produce grub.cfg ourselves if there's something
>> to add there for LVM support (which I'm not sure there is -- apparently it
>> already works for you ?), it should be explicitly coded in (gnu bootloader
>> grub).
>
> It does not work for me, that is why I reported this! The system does not boot
> unless I manually add `insmod lvm` in `grub.cfg` because Grub does not find
> the partition that contains the store.
>
> So I agree something has to be done there.

OK, thanks for explaining. Could you please try
https://issues.guix.gnu.org/60442(by applying the patch to a local guix
checkout, building it, then 'sudo -E ./pre-inst-env sudo guix system
reconfigure /path/to/your/config.scm)? The test suite was broken it
seems (it passed without the fix), but perhaps the fix still does work?

--
Thanks,
Maxim
E
E
Emmanuel Beffara wrote on 28 Mar 2023 14:32
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
20230328143236.GD1964@beffara.org
Hi,

De Maxim Cournoyer le 24/03/2023 à 13:24:
Toggle quote (6 lines)
> OK, thanks for explaining. Could you please try
> https://issues.guix.gnu.org/60442 (by applying the patch to a local guix
> checkout, building it, then 'sudo -E ./pre-inst-env sudo guix system
> reconfigure /path/to/your/config.scm)? The test suite was broken it
> seems (it passed without the fix), but perhaps the fix still does work?

I did as you suggested, and unfortunately the patch has no observable effect
on my system.

I can't say it comes as a surprise. Indeed, what the patch does is set the
environment variable `GRUB_PRELOAD_MODULES` before calling `grub-install`,
which is expected to have no effect: this variable is used by `grub-mkconfig`
to generate a `grub.cfg`, but the code in Guix assembles a Grub configuration
file itself and never calls `grub-mkconfig`. The same applies to the variable
`GRUB_ENABLE_CRYPTODISK`, by the way. Maybe the way `grub.cfg` is produced has
changed at some point in history ?

The only hypothesis I can make is that it would influence `grub-install` by
preloading the given modules in the installed image, but that is not the case.
According to Grub's documentation, passing `--modules=...` to `grub-install`
would have this effect, but I'm not sure it is the right approach.

--
Emmanuel
M
M
Maxim Cournoyer wrote on 28 Mar 2023 16:10
(name . Emmanuel Beffara)(address . manu@beffara.org)
87v8ilnezm.fsf@gmail.com
Hi,

Emmanuel Beffara <manu@beffara.org> writes:

Toggle quote (12 lines)
> Hi,
>
> De Maxim Cournoyer le 24/03/2023 à 13:24:
>> OK, thanks for explaining. Could you please try
>> https://issues.guix.gnu.org/60442 (by applying the patch to a local guix
>> checkout, building it, then 'sudo -E ./pre-inst-env sudo guix system
>> reconfigure /path/to/your/config.scm)? The test suite was broken it
>> seems (it passed without the fix), but perhaps the fix still does work?
>
> I did as you suggested, and unfortunately the patch has no observable effect
> on my system.

Thanks for testing it!

Toggle quote (8 lines)
> I can't say it comes as a surprise. Indeed, what the patch does is set the
> environment variable `GRUB_PRELOAD_MODULES` before calling `grub-install`,
> which is expected to have no effect: this variable is used by `grub-mkconfig`
> to generate a `grub.cfg`, but the code in Guix assembles a Grub configuration
> file itself and never calls `grub-mkconfig`. The same applies to the variable
> `GRUB_ENABLE_CRYPTODISK`, by the way. Maybe the way `grub.cfg` is produced has
> changed at some point in history ?

I'm not sure, but I agree it's confusing to have extraneous setenv
there if they serve no purpose (and my understanding is the same as
yours: I don't see how that'd work).

Toggle quote (5 lines)
> The only hypothesis I can make is that it would influence `grub-install` by
> preloading the given modules in the installed image, but that is not the case.
> According to Grub's documentation, passing `--modules=...` to `grub-install`
> would have this effect, but I'm not sure it is the right approach.

Since we already generate a custom grub.cfg, the right approach is
probably to add any needed directive directly to it.

--
Thanks,
Maxim
E
E
Erik Eduardo wrote on 23 Jan 17:36 +0100
enable LVM in Grub
(address . 62140@debbugs.gnu.org)
j3JNI3cJ73M8gPL8tCbn797vwvri_5zfMhOcCZ2cDetWBClEuQC0DY_Q3hLZtEHO7dLLmn5bW3Hq2K6dhA0dC0IMclldKpjMbYHXGWvdEE0=@protonmail.com
I could correctly implement lvm as root (I think), however there is any intention on support this on guix? Let me know and I will try to send a patch.
Attachment: file
?