Root on LVM support

  • Open
  • quality assurance status badge
Details
5 participants
  • ashish.is
  • Emmanuel Beffara
  • Maxim Cournoyer
  • Michael Rohleder
  • Mikhail Tsykalov
Owner
unassigned
Submitted by
Mikhail Tsykalov
Severity
normal
M
M
Mikhail Tsykalov wrote on 26 Nov 2020 00:53
(address . bug-guix@gnu.org)
31b2cc61-04ab-6d2b-880e-a22af5677d3f@gmail.com
Guix System in current state can't boot from lvm partition because grub
can't find kernel and initrd. This also applies to systems where
/gnu/store is on lvm partition. Grub has lvm support in the form of
"lvm" module, but it isn't loaded currently. Making grub config
generator emit "insmod lvm" before grub starts accessing stuff on
/gnu/store (so immediately after initial commit) will fix this.
M
M
Michael Rohleder wrote on 13 Mar 2023 14:56
Re: bug#62140: enable LVM in Grub
(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
A
A
ashish.is wrote on 8 Jun 18:13 +0200
[PATCH] gnu: grub: load lvm grub module.
(address . 44877@debbugs.gnu.org)(name . Ashish SHUKLA)(address . ashish.is@lostca.se)
8eb817a7e3e7a6033b2f102d55c0095f2b7a075a.1717863216.git.ashish.is@lostca.se
From: Ashish SHUKLA <ashish.is@lostca.se>

* gnu/bootloader/grub.scm (make-grub-configuration): load lvm grub module
when generating configuration for cryptodisks setup.

Change-Id: I1dbb0c7dbf68a5f93db76dc29793a1f73be49ee2
---
Hi,

I have a Guix setup which has a LUKS2 partition containing a LVM
volume group on which kernels and initrds reside. I think this is one
of the common setups in which folks uses disk-encryption on
GNU/Linux. Since in Guix the kernels/initrd don't get copied to /boot
it requires GRUB to be able to unlock the LUKS2 volume, and look
inside the LVM partitions to find initrd, and kernel. The former part
is already there, this patch enables the latter part, so folks like me
who use LVM on top of LUKS be able to boot, otherwise it requires
going to grub command-line, and running "insmod lvm" prior to
selecting a boot option.

Thanks,
Ashish

gnu/bootloader/grub.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (17 lines)
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 2723eda5f4..a4ca0bc217 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -445,7 +445,7 @@ (define* (make-grub-configuration grub config entries
;; Other type of devices aren't implemented.
#~()))
(let ((devices (map crypto-device->cryptomount store-crypto-devices))
- (modules #~(format port "insmod luks~%insmod luks2~%")))
+ (modules #~(format port "insmod luks~%insmod luks2~%insmod lvm~%")))
(if (null? devices)
devices
(cons modules devices))))

base-commit: 580d77d0fb12448ef1621699cc0c56e787e2aadb
--
2.45.2
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 44877@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 44877
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch