all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mikhail Tsykalov <tsymsh@gmail.com>
To: Lars-Dominik Braun <lars@6xq.net>
Cc: 41143@debbugs.gnu.org
Subject: [bug#41143] [PATCH 1/2] mapped-devices: Allow target to be list of strings
Date: Sat, 6 Jun 2020 23:16:07 +0300	[thread overview]
Message-ID: <8c852805-38e6-92b2-15cf-43d47818782e@gmail.com> (raw)
In-Reply-To: <20200606134015.GA204960@noor.fritz.box>

[-- Attachment #1: Type: text/plain, Size: 1722 bytes --]

Hi,

Thanks for the report, guess that's what I get by assuming instead of 
testing.

> I’ve tried the patches, but `guix system reconfigure` fails(?) with
>
> 	building /gnu/store/cy6d2a4b8bcqcjiaz8bm367j7vbdrslc-upgrade-shepherd-services.scm.drv...
> 	guix system: error: exception caught while executing 'start' on service 'device-mapping-disk3-data':
> 	error: <>: unbound variable

Can you test with the attached patch, it seems like `cut` macros is 
undefined while shepherd service is expanded(?). I fixed it by replacing 
it with a plain lambda. I managed to mount a flash disk with LVM using 
this patch, so I think it should be working now.

> I’m also curious why sources is a list of VG’s as opposed to a list of device
> nodes (i.e. /dev/sdX), like the other mappings. Does `pvscan --cache` not work
> here?

I always thought that it wasn't possible to mount LVM by PV's, but 
looking at man, `pvscan --cache -aay` seems to do the thing. Still, I 
think that using VG's instead of PV's is better, since you must `pvscan` 
all PV's in a VG in order to activate it, so you'll still need to think 
in terms of VG's. This also can be a source of errors, for example 
adding a device to a VG will result in entire VG not being activated 
until the configuration is changed and the system is reconfigured. Also 
I think that LVM doesn't put that much importance on individual PV's as 
it does on VG's as a place where LV's live.

All of this goes out of the window if you use LVM on only one PV, so it 
may be possible to have a heuristic that will check if source is a 
device node as opposed to a VG name and perform appropriate actions, but 
I'm not sure if the resulting complexity is worth it.

Mikhail


[-- Attachment #2: 0002-mapped-devices-Add-lvm-device-mapping.patch --]
[-- Type: text/x-patch, Size: 2188 bytes --]

From e9a2b441190fe18ebc4f5a8c73707edab3459d58 Mon Sep 17 00:00:00 2001
From: Mikhail Tsykalov <tsymsh@gmail.com>
Date: Sat, 9 May 2020 03:27:13 +0300
Subject: [PATCH 2/2] mapped-devices: Add 'lvm-device-mapping'

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

diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index 3339e509e0..641cddc146 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,26 @@ 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))
+       (and
+        (zero? (system* #$(file-append lvm2-static "/sbin/lvm")
+                        "vgchange" "--activate" "ay" #$source))
+        (zero? (system* #$(file-append lvm2-static "/sbin/lvm")
+                         "vgscan" "--mknodes")) ; make /dev/mapper nodes when in initrd
+        (every file-exists? (map (lambda (file) (string-append "/dev/mapper/" file))
+                                 (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


  reply	other threads:[~2020-06-06 20:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-09  1:12 [bug#41143] [PATCH 1/2] mapped-devices: Allow target to be list of strings tsmish
2020-05-09  1:22 ` [bug#41143] [PATCH 2/2] mapped-devices: Add 'lvm-device-mapping' tsmish
2020-09-09 20:48   ` Ludovic Courtès
2020-05-14 22:53 ` [bug#41143] Some clarification Mikhail Tsykalov
2020-05-15  1:17 ` [bug#41143] [PATCH] mapped-devices: Document lvm-mapping-device Mikhail Tsykalov
2020-06-06 13:40 ` [bug#41143] [PATCH 1/2] mapped-devices: Allow target to be list of strings Lars-Dominik Braun
2020-06-06 20:16   ` Mikhail Tsykalov [this message]
2020-06-07  6:48     ` Lars-Dominik Braun
2020-09-09 20:38 ` Ludovic Courtès
2020-09-24 16:09   ` Mikhail Tsykalov
2020-09-25  9:34     ` Ludovic Courtès
2020-09-25 13:36       ` Mikhail Tsykalov
2020-09-25 16:20         ` Ludovic Courtès
2020-10-01 22:48           ` [bug#41143] [PATCH v2 " Mikhail Tsykalov
2020-10-01 22:49             ` [bug#41143] [PATCH v2 2/2] mapped-devices: Add 'lvm-device-mapping' Mikhail Tsykalov
2020-10-04 10:34               ` Ludovic Courtès
2020-10-04 10:28             ` [bug#41143] [PATCH v2 1/2] mapped-devices: Allow target to be list of strings Ludovic Courtès
2020-11-05  9:48               ` Ludovic Courtès
2020-11-06  9:47                 ` [bug#41143] [PATCH v3 " Mikhail Tsykalov
2020-11-06  9:47                   ` [bug#41143] [PATCH v3 2/2] mapped-devices: Add 'lvm-device-mapping' Mikhail Tsykalov
2020-11-25 23:09                   ` bug#41143: [PATCH v3 1/2] mapped-devices: Allow target to be list of strings Ludovic Courtès
2020-10-01 23:15           ` [bug#41143] [PATCH " Mikhail Tsykalov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8c852805-38e6-92b2-15cf-43d47818782e@gmail.com \
    --to=tsymsh@gmail.com \
    --cc=41143@debbugs.gnu.org \
    --cc=lars@6xq.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.