GNU bug report logs - #41143
[PATCH 1/2] Add 'lvm-device-mapping'

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: tsmish <tsymsh@HIDDEN>; Keywords: patch; dated Sat, 9 May 2020 01:13:01 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.
Changed bug title to '[PATCH 1/2] Add 'lvm-device-mapping'' from '[PATCH 1/2] mapped-devices: Allow target to be list of strings' Request was from Ludovic Courtès <ludo@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 41143 <at> debbugs.gnu.org:


Received: (at 41143) by debbugs.gnu.org; 15 May 2020 01:17:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 14 21:17:50 2020
Received: from localhost ([127.0.0.1]:35241 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jZOz0-0005td-FV
	for submit <at> debbugs.gnu.org; Thu, 14 May 2020 21:17:50 -0400
Received: from mail-lf1-f53.google.com ([209.85.167.53]:36225)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tsymsh@HIDDEN>) id 1jZOyy-0005tN-Kh
 for 41143 <at> debbugs.gnu.org; Thu, 14 May 2020 21:17:49 -0400
Received: by mail-lf1-f53.google.com with SMTP id c21so419761lfb.3
 for <41143 <at> debbugs.gnu.org>; Thu, 14 May 2020 18:17:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=to:from:subject:message-id:date:user-agent:mime-version
 :content-transfer-encoding:content-language;
 bh=LiAT28NgmctBNUNKcc60PKR0tKC8ZMLQSPKMJxIAGLw=;
 b=RWQnEicRMCXBR9K0ZyXqcq/1/d75qMm0kqHO11AyAbvJTr7eN/HxQ1PCPVLGpeUFeJ
 rl/wctBBm7YuzMBI+dPHFxZcJkZxEY+3ICub0IDDRM10lkRcGUHQWK9YHAbV4ZAE3ZEs
 vZscGx7tufhYxciNd+pcndoxSuMAPC5Zs0ZM+5Xp0G9pEXKuz1i/aQHnq7DAfUJ6O5r1
 hX70Vgw/ZVw148VKviyHgPr1N+Kt6pLUFDoUCHT8QDGYhDoX4FzRd/avEyFuVSUXo7UP
 6mOdnXH4p5cv7dwngvoeSqqh+O5qo9NVjJSXaiRFhGcQyrn+TDuxUxTJIu859Uv9C9Tp
 5SOQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:to:from:subject:message-id:date:user-agent
 :mime-version:content-transfer-encoding:content-language;
 bh=LiAT28NgmctBNUNKcc60PKR0tKC8ZMLQSPKMJxIAGLw=;
 b=OkXpSiRv3NYG8Nl9mKdMbnnvxTkXPwN52rD23pZ9RPs6VVo/77M7APctLvYEfQWmrF
 8YGiWHmQkt77wmbvDfyxSAcQDi506OecJARIy0VuYrwzQ8dTF77WzihzTgIhbIhx3+Tj
 CO5flwCyuILSOJp/gBJSu1OsGkteqgm412PVL9FeYm38kHAQZiJx8NCvEvwM40ZEzbv1
 yoYtX6pdU8QXEfi6zMDy1pfJwkzDWYzVHq4lf5wAvngxQAaWTMAtntyu+rt7SSCR91f1
 /vOywKKvE2euGyk2Id4T+Z6Ldurqx8RHfzxkBselAJJLcXlH78Rw7hVsLCr0ekY4qlZD
 r6PA==
X-Gm-Message-State: AOAM5334dnG3HbABqvE6+SY4c4YihIq5zyr4BQFvLaIWGTvWpx0YcQaJ
 MP1JMTk/6OJH2Cah5Q7F2Xc4P5BlcRM=
X-Google-Smtp-Source: ABdhPJz1eKt/gP7qfAyO5JfIoupPXEo9O5Ei9fx+naVAaPp5hglVsZOvgB/xIiP7gfKN0BFqJYDzSA==
X-Received: by 2002:a19:d97:: with SMTP id 145mr580460lfn.193.1589505461919;
 Thu, 14 May 2020 18:17:41 -0700 (PDT)
Received: from [192.168.0.75] ([88.201.200.191])
 by smtp.gmail.com with ESMTPSA id f23sm333223ljc.72.2020.05.14.18.17.41
 for <41143 <at> debbugs.gnu.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Thu, 14 May 2020 18:17:41 -0700 (PDT)
To: 41143 <at> debbugs.gnu.org
From: Mikhail Tsykalov <tsymsh@HIDDEN>
Subject: [PATCH] mapped-devices: Document lvm-mapping-device.
Message-ID: <b68a706e-a554-8dd8-13d1-963de34cb260@HIDDEN>
Date: Fri, 15 May 2020 04:17:40 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Icedove/68.8.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Content-Language: en-US
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 41143
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

---
  doc/guix.texi | 30 ++++++++++++++++++++++++++----
  1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index d6fbd85fde..612a9b25e5 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -11738,7 +11738,6 @@ Guix extends this notion by considering any 
device or set of devices that
  are @dfn{transformed} in some way to create a new device; for instance,
  RAID devices are obtained by @dfn{assembling} several other devices, such
  as hard disks or partitions, into a new one that behaves as one partition.
-Other examples, not yet implemented, are LVM logical volumes.

  Mapped devices are declared using the @code{mapped-device} form,
  defined as follows; for examples, see below.
@@ -11751,15 +11750,20 @@ the system boots up.
  @item source
  This is either a string specifying the name of the block device to be 
mapped,
  such as @code{"/dev/sda3"}, or a list of such strings when several devices
-need to be assembled for creating a new one.
+need to be assembled for creating a new one. In case of LVM this is a
+string specifying name of the volume group to be mapped.

  @item target
-This string specifies the name of the resulting mapped device. For
-kernel mappers such as encrypted devices of type 
@code{luks-device-mapping},
+This is either a string specifying the name of the resulting mapped
+device, or a list of such strings in case there are several, which is
+common while using LVM.
+For kernel mappers such as encrypted devices of type 
@code{luks-device-mapping},
  specifying @code{"my-partition"} leads to the creation of
  the @code{"/dev/mapper/my-partition"} device.
  For RAID devices of type @code{raid-device-mapping}, the full device name
  such as @code{"/dev/md0"} needs to be given.
+LVM logical volumes of type @code{lvm-device-mapping} need to
+be specified as @code{"VGNAME-LVNAME"}.

  @item type
  This must be a @code{mapped-device-kind} object, which specifies how
@@ -11780,6 +11784,11 @@ module for the appropriate RAID level to be 
loaded, such as @code{raid456}
  for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
  @end defvr

+@defvr {Scheme Variable} lvm-device-mapping
+This defines LVM logical volume(s). Volume group is activated by
+@command{vgchange} command from the package @code{lvm2}.
+@end defvr
+
  @cindex disk encryption
  @cindex LUKS
  The following example specifies a mapping from @file{/dev/sda3} to
@@ -11837,6 +11846,19 @@ Note that the RAID level need not be given; it 
is chosen during the
  initial creation and formatting of the RAID device and is determined
  automatically later.

+LVM logical volumes ``alpha'' and ``beta'' from volume group ``vg0'' can
+be declared as follows:
+
+@lisp
+(mapped-device
+  (source "vg0")
+  (target (list "vg0-alpha" "vg0-beta"))
+  (type lvm-device-mapping))
+@end lisp
+
+Devices @file{/dev/mapper/vg0-alpha} and @file{/dev/mapper/vg0-beta} can
+then be used as the @code{device} of a @code{file-system} declaration
+(@pxref{File Systems}).

  @node User Accounts
  @section User Accounts
-- 
2.26.2





Information forwarded to guix-patches@HIDDEN:
bug#41143; Package guix-patches. Full text available.

Message received at 41143 <at> debbugs.gnu.org:


Received: (at 41143) by debbugs.gnu.org; 14 May 2020 22:53:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 14 18:53:40 2020
Received: from localhost ([127.0.0.1]:35166 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jZMjQ-0001dp-I5
	for submit <at> debbugs.gnu.org; Thu, 14 May 2020 18:53:40 -0400
Received: from mail-lj1-f176.google.com ([209.85.208.176]:42261)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tsymsh@HIDDEN>) id 1jZMjO-0001cz-AG
 for 41143 <at> debbugs.gnu.org; Thu, 14 May 2020 18:53:35 -0400
Received: by mail-lj1-f176.google.com with SMTP id d21so147360ljg.9
 for <41143 <at> debbugs.gnu.org>; Thu, 14 May 2020 15:53:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=to:from:subject:message-id:date:user-agent:mime-version
 :content-transfer-encoding:content-language;
 bh=96RV259xHiZkMoU6IGaxGq/V6XeE05Ikm1BZ6rg0cWs=;
 b=sGZ7ebyVd+Buwl98Y8JOByzInVWXmwYV9vhR3qFjnbg63oN2/qXs5Eqx4zPVvo2/Bc
 t5mEMt8JgWy3xRtzoT0kZB/hr6t0rkpkqzVtu3hisLoipkLEiVLXF+yN+l5TR6e0HxTc
 E5AfRywmLpHxYB0/cf4pk960vW2kIJup2KWHZtr9MvTWWbYKGrL6wj5QO/fMCIkeCMnJ
 LG58+MBsJ+yo9K9Vp5OF8F9gW/80Saf4WsDyw7dy9f/SNOYab+RIKMoXcKhWnKJb9k5V
 A2wb7EBHLdFWuoVl5dUgO5IldZQTNjUlMxgAaKzrIZ5qfXRRaQGVnc1WDa830KrGo5et
 BWVg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:to:from:subject:message-id:date:user-agent
 :mime-version:content-transfer-encoding:content-language;
 bh=96RV259xHiZkMoU6IGaxGq/V6XeE05Ikm1BZ6rg0cWs=;
 b=M9cAxnUG4y7SJylNGrxe3sGY8EW2S2h10stpBFBKikqLMjvAidwfNXkwmzzPPEvOWs
 Y2booTnzO4rH6gSoQjECb/QsTWE5khM7FXvVBhf0I07x0Vgx/O9E9YrYiiA2DtNCVDEQ
 jOvT6Ev46Hfd2T06UeNhFNULc9y/5GFlL+su6VaPiYtcbEGbDif6vL3Se/SFS9XvEWAv
 5h8l5QM4wHPe2GT5Rx48r+yYKq5/r7RYquq5XQhnygzedfSPpwSutp8u70EzLEhufuiF
 JQFnwTQPn1xOckO7JMlUI/0SVQ/X0pAHkhh75Q9Rst+USGEBtP/GIjiX0kxWglFEIcuC
 5M4g==
X-Gm-Message-State: AOAM5310Z2r3IedCp3BS59pCb67AtQ4BDjXdChIXm2o2789nVC3lVJrE
 Vyh07CZ0i5o0wNi5zxaa6JADA+/txFM=
X-Google-Smtp-Source: ABdhPJyBDNyH4UGh65NsphEVtI9l/a8lLhLn7Ext3Nff8wNmXScRFZCrbcshHtQtr/lroo6Ki2wtzw==
X-Received: by 2002:a2e:81d5:: with SMTP id s21mr321948ljg.258.1589496807531; 
 Thu, 14 May 2020 15:53:27 -0700 (PDT)
Received: from [192.168.0.75] ([88.201.200.191])
 by smtp.gmail.com with ESMTPSA id y9sm143259ljy.31.2020.05.14.15.53.26
 for <41143 <at> debbugs.gnu.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Thu, 14 May 2020 15:53:27 -0700 (PDT)
To: 41143 <at> debbugs.gnu.org
From: Mikhail Tsykalov <tsymsh@HIDDEN>
Subject: Some clarification
Message-ID: <7e96c284-c69c-965f-6bae-9546b1c711ad@HIDDEN>
Date: Fri, 15 May 2020 01:53:26 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Icedove/68.8.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 41143
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

In LVM one volume group usually haves more than one logical volume, so 
target need to be a list. Just setting target to list in config doesn't 
work because that field is actually used for checking when (and whether 
at all) the device needs to be mounted. Because we still need to support 
using a string as target, we need to handle two situations: target is a 
string and target is list of strings. Patch converts plain string target 
to single element list and proceeds with assuming a list. grep by 
mapped-device-target revealed two uses in gnu/system.scm and one in 
gnu/services/base.scm. First two checked if any filesystems used a 
device, so I replaced plain string comparison with comparison with every 
element of list and returning true if any of them matched. Last one used 
target for building service name for shepherd, so I replaced plain 
target with concatenation of every target that mapped device has.

Moving on to second patch. Basically to mount LVM you need to activate 
volume group(s) with command "vgchange -ay". It worked fine with 
non-root mounts, but when it got moved in initrd it crashed. Quick look 
around found that while /dev/dm-X devices were being created, 
/dev/mapper/ nodes were not. Looking at man pages (and internet) "vgscan 
--mknodes" looked like what I wanted (there is also dmsetup mknodes, but 
basically first just calls it). After adding it, boot with root on LVM 
started working, so I left it. Also I check that targets actually exist, 
so you get crash in a bit more appropriate place. This check should 
probably be moved to somewhere else, but I haven't found better solution.

Looking at 
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/logical_volume_manager_administration/udev_device_manager 
10-dm.rules looks like what creates /dev/mapper nodes in normal systems, 
so probably more proper solution will be to add udevd to initrd, but I 
don't know how to run daemons in initrd properly. dracut also creates 
file /etc/lvm/lvm.conf, which doesn't seem to be very important, but I 
probably should look closer to it. Also both dracut and LVM add 
"--ignorelockingfailure" flag to vgchange, which I forgot and will 
change in future patches.

There seems to be close to no resources about mounting LVM in initrd, so 
I'm adding code from other initrd generators:

Dracut: 
https://github.com/dracutdevs/dracut/blob/master/modules.d/90lvm/lvm_scan.sh

LVM: 
https://github.com/lvmteam/lvm2/blob/master/scripts/lvm2create_initrd/lvm2create_initrd





Information forwarded to guix-patches@HIDDEN:
bug#41143; Package guix-patches. Full text available.

Message received at 41143 <at> debbugs.gnu.org:


Received: (at 41143) by debbugs.gnu.org; 9 May 2020 01:22:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 08 21:22:24 2020
Received: from localhost ([127.0.0.1]:46517 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jXEC8-0007TU-Hd
	for submit <at> debbugs.gnu.org; Fri, 08 May 2020 21:22:24 -0400
Received: from mail-qv1-f49.google.com ([209.85.219.49]:36767)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tsymsh@HIDDEN>) id 1jXEC7-0007TI-E6
 for 41143 <at> debbugs.gnu.org; Fri, 08 May 2020 21:22:23 -0400
Received: by mail-qv1-f49.google.com with SMTP id w18so1798201qvs.3
 for <41143 <at> debbugs.gnu.org>; Fri, 08 May 2020 18:22:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=XTKWjn5N9JKSwF8DVVPgeAHn6CByEioUIlthzFDy/2o=;
 b=qJ1Wg+j7tJfKotPoesG2PlAk71h23etXe8zW7p8bROM3tqjOVtCmM233I8VP9xVd3z
 WLnsfaG47i69QGxyvaZmuuhnwkX+GQwa7HqNg2MzK8KLIufwfp5blysRCcR03LAxm7rd
 w8zVKKvc1cK4a8hGp/06kPEUPwOTu7LMJC6iPywRqjGVDGh2A2QqfSSbWLYB5OHSrLiF
 B2z6pS7INRg1mfGBA8hHUgbwVvEFgD/lqCrXB8+PlqDzQQwyNjDoH7ABklpolO4qEe1q
 TraIr4C2bxElAblAgnH00rpyvYPDnWsbiMjbaSSye1QPlGD6LZBUypMVTf61t36/jOf5
 +QjA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=XTKWjn5N9JKSwF8DVVPgeAHn6CByEioUIlthzFDy/2o=;
 b=DUu+BLt6d5u+gJuCVwtbMlE2F5Vs4ZDq1zhn7ZxtVMNfe/At69+Mt5dAp3sdlfZd/R
 AuRVx7wLJIO9r2aJZoev9dJ0Yje6mQbuNOXKXUlW1FNcBpV5vecwua4bqfzgH2/VfDi/
 7NtErDKATuwA6zZ2sNAl6nnwQRtEdDEHvhSzqLzH23NRY4BH+PS10t/qSyCaT5+m9SWK
 fUg5Ola6sqZTNR9ItIoJHhby9eeENI/jdTfJR8X+vUl1ebU5sghA6XBx/roorA2+gw+W
 RKpzKzXr5bdCFTIhq/wPQpTVaf32kEYFg5Rpd4iTB5M3K86AOPnChew6/PVLfFSu3ltS
 cblg==
X-Gm-Message-State: AGi0PuaNDkAhioczDAayK1djJBp89A909O64CN8ysrAOXIwCOhoaFiuI
 i+aESGUGYpHl4pC/1unW8dST9t2HYA36mbF3XpMnH1Y4
X-Google-Smtp-Source: APiQypK2Iw1+OnBZu1hqlba9pLoe40PLZ72124okxDcuRAmUFYfhXou0LThEiG2g7kTPe2xzCR16U9x8K6zwya9U88o=
X-Received: by 2002:a0c:b797:: with SMTP id l23mr5537570qve.204.1588987337733; 
 Fri, 08 May 2020 18:22:17 -0700 (PDT)
MIME-Version: 1.0
From: tsmish <tsymsh@HIDDEN>
Date: Sat, 9 May 2020 01:22:07 +0000
Message-ID: <CAMaATaNkBUP-2sg-QX=AXQoP4z=2HcM_c9gpbL7PPLJ+sxDnrg@HIDDEN>
Subject: [PATCH 2/2] mapped-devices: Add 'lvm-device-mapping'
To: 41143 <at> debbugs.gnu.org
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 41143
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

"vgscan --mknodes" is a bit of a hack. Everyone else relies on udev to
create files in /dev/mapper, but since initrd doesn't have working
udevd, they need to be created this way.
Also, while this code is able to boot from root on LVM, grub in
current configuration can't find required files, This can be fixed by
placing (format port "insmod lvm") in grub configuration builder, but
this is somewhat hacky.

---
 gnu/system/mapped-devices.scm | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index 3339e509e0..03bc7c782d 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -34,7 +34,7 @@
   #:autoload   (gnu build linux-modules)
                  (missing-modules)
   #:autoload   (gnu packages cryptsetup) (cryptsetup-static)
-  #:autoload   (gnu packages linux) (mdadm-static)
+  #:autoload   (gnu packages linux) (mdadm-static lvm2-static)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
@@ -59,7 +59,8 @@
             check-device-initrd-modules           ;XXX: needs a better place

             luks-device-mapping
-            raid-device-mapping))
+            raid-device-mapping
+            lvm-device-mapping))

 ;;; Commentary:
 ;;;
@@ -269,4 +270,28 @@ TARGET (e.g., \"/dev/md0\"), using 'mdadm'."
    (open open-raid-device)
    (close close-raid-device)))

+(define (open-lvm-device source target)
+  #~(begin
+       (use-modules
+        (srfi srfi-1)
+        (srfi srfi-26))
+       (and
+        (zero? (system* #$(file-append lvm2-static "/sbin/lvm")
+                        "vgchange" "--activate" "y" #$source))
+        (zero? (system* #$(file-append lvm2-static "/sbin/lvm")
+                         "vgscan" "--mknodes")) ; make /dev/mapper
nodes when in initrd
+        (every file-exists? (map (cut string-append "/dev/mapper/" <>)
+                                 (let ((t '#$target))
+                                   (if (list? t) t (list t))))))))
+
+
+(define (close-lvm-device source target)
+  #~(zero? (system* #$(file-append lvm2-static "/sbin/lvm")
+                    "vgchange" "--activate" "n" #$source)))
+
+(define lvm-device-mapping
+  (mapped-device-kind
+   (open open-lvm-device)
+   (close close-lvm-device)))
+
 ;;; mapped-devices.scm ends here
-- 
2.26.2




Information forwarded to guix-patches@HIDDEN:
bug#41143; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 9 May 2020 01:12:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 08 21:12:59 2020
Received: from localhost ([127.0.0.1]:46511 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jXE31-0007Dr-IP
	for submit <at> debbugs.gnu.org; Fri, 08 May 2020 21:12:59 -0400
Received: from lists.gnu.org ([209.51.188.17]:51774)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tsymsh@HIDDEN>) id 1jXE2z-0007Dg-8K
 for submit <at> debbugs.gnu.org; Fri, 08 May 2020 21:12:57 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:44972)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <tsymsh@HIDDEN>) id 1jXE2z-0003tF-3H
 for guix-patches@HIDDEN; Fri, 08 May 2020 21:12:57 -0400
Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]:36746)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <tsymsh@HIDDEN>) id 1jXE2y-0003s6-13
 for guix-patches@HIDDEN; Fri, 08 May 2020 21:12:56 -0400
Received: by mail-qt1-x841.google.com with SMTP id v4so2187389qte.3
 for <guix-patches@HIDDEN>; Fri, 08 May 2020 18:12:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=pbsQsvhfv4gk/g0/3WrPPyVyeBtSIC4dhO1eo0oDjfg=;
 b=EvX16I4qS1uFt9Ozm2VHFVqLqNEdDEoY08tuzbUzQSrGO7Rz/PYPZwVPlfcj/lP0A9
 XO0fXCjdRgte1JS9ENdkK8582/s9F+1Ye1ABmwaNmOu8BxIJRGrR/sRt2yN5nqIawvJt
 ebNmkVgfLVPoqI7Dl1odTieMsAhVyweHpUxa8EwzTQ5Q9k/xgloCMY/ks9FkbS24ehq0
 j8u4ef8uGqrYnCYa2MuS6DwkYMt8QQghNM1/fGlDJiW4uLBzU3jUgWSIu2dpEIoNRGib
 V70oo3EKaz/8E9u9u1R9IK9kQ3t8+367jhuJ8SRAQPEGZgep3GFx8UgEqG7gIa2+tl72
 Tnqg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=pbsQsvhfv4gk/g0/3WrPPyVyeBtSIC4dhO1eo0oDjfg=;
 b=QdnSDqYmznWEvZjUhq1rz0N4yYmvguf9SL8P62s6D9CIgMJVrlLPpwCvijeDDkPZ9h
 zc9WQ3gSl4mgvKqZkxRbLOVK61D4T6NGERFZ2TG1pqHCdfThKx3fTS8Pi2hfoR7+U96W
 WHr2AuSWs6OGOQLUy0VK5aBzCDr8LhIMm3EEjZvJJKZlcY0InWyO6DDl2ihWwVjl0a3M
 +kAj0K5MVkon8HQHxG0XqaIIdIhyVEXGq8Xf+A0ngoDzXuRJjrdjpUbCNMEQQ5sIbpXV
 n50rzs+KCufr7LHMhdUqbs51jSvqIK20JXzpdqdkI3OD53z+oqEbLhDi3w++nwRxsucA
 t2Zg==
X-Gm-Message-State: AGi0PuYYHJa00DzbyK/KnIqCG+gj2PajqSeCJTIz37b8USHtKfR1B4fd
 lxpipe5s/QvWCJPZ/n/oX43943r6LklTv5qWrNxNL117
X-Google-Smtp-Source: APiQypL1Z9F+xuTbqJv19eknpy/ZEBKgiFajVDINt99p73/7sjpggOorgZsqcEUZVeDcjFMkPG2bVYg8K4bsaSHylpI=
X-Received: by 2002:ac8:2c78:: with SMTP id e53mr6191492qta.365.1588986774409; 
 Fri, 08 May 2020 18:12:54 -0700 (PDT)
MIME-Version: 1.0
From: tsmish <tsymsh@HIDDEN>
Date: Sat, 9 May 2020 01:12:43 +0000
Message-ID: <CAMaATaPqFZTB-j9MyhS4+vrn8sjA25xzu2+DD71nE541yCiRwQ@HIDDEN>
Subject: [PATCH 1/2] mapped-devices: Allow target to be list of strings
To: guix-patches@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Received-SPF: pass client-ip=2607:f8b0:4864:20::841;
 envelope-from=tsymsh@HIDDEN; helo=mail-qt1-x841.google.com
X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache.
 That's all we know.
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001 autolearn=_AUTOLEARN
X-Spam_action: no action
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

(let ...) stuff should be in function, but I don't know in which
module it should go.
Code is somewhat untested, proceed with caution.

---
 gnu/services/base.scm         |  5 ++++-
 gnu/system.scm                | 13 ++++++++-----
 gnu/system/mapped-devices.scm |  2 +-
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 0c154d1c4e..3d09e8220c 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -408,7 +408,10 @@ FILE-SYSTEM."
 (define (mapped-device->shepherd-service-name md)
   "Return the symbol that denotes the shepherd service of MD, a
<mapped-device>."
   (symbol-append 'device-mapping-
-                 (string->symbol (mapped-device-target md))))
+                 (string->symbol (string-join
+                                  (let ((t (mapped-device-target md)))
+                                    (if (list? t) t (list t)))
+                                  "-"))))

 (define dependency->shepherd-service-name
   (match-lambda
diff --git a/gnu/system.scm b/gnu/system.scm
index 01baa248a2..75632c5e8a 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -390,9 +390,10 @@ marked as 'needed-for-boot'."
     (let ((device (file-system-device fs)))
       (if (string? device)                        ;title is 'device
           (filter (lambda (md)
-                    (string=? (string-append "/dev/mapper/"
-                                             (mapped-device-target md))
-                              device))
+                    (any (cut string=? device <>)
+                         (map (cut string-append "/dev/mapper" <>)
+                              (let ((t (mapped-device-target md)))
+                                (if (list? t) t (list t))))))
                   (operating-system-mapped-devices os))
           '())))

@@ -412,11 +413,13 @@ marked as 'needed-for-boot'."

 (define (mapped-device-users device file-systems)
   "Return the subset of FILE-SYSTEMS that use DEVICE."
-  (let ((target (string-append "/dev/mapper/" (mapped-device-target device))))
+  (let ((targets (map (cut string-append "/dev/mapper/" <>)
+                      (let ((t (mapped-device-target device)))
+                        (if (list? t) t (list t))))))
     (filter (lambda (fs)
               (or (member device (file-system-dependencies fs))
                   (and (string? (file-system-device fs))
-                       (string=? (file-system-device fs) target))))
+                       (any (cut string=? (file-system-device fs) <>)
targets))))
             file-systems)))

 (define (operating-system-user-mapped-devices os)
diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index 7c58f876a3..3339e509e0 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -72,7 +72,7 @@
   make-mapped-device
   mapped-device?
   (source    mapped-device-source)                ;string | list of strings
-  (target    mapped-device-target)                ;string
+  (target    mapped-device-target)                ;string | list of strings
   (type      mapped-device-type)                  ;<mapped-device-kind>
   (location  mapped-device-location
              (default (current-source-location)) (innate)))
-- 
2.26.2




Acknowledgement sent to tsmish <tsymsh@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#41143; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 16 May 2020 17:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.