From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id iJWKFsz5215UdQAA0tVLHw (envelope-from ) for ; Sat, 06 Jun 2020 20:17:16 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 4I9pEsz5214KEwAAbx9fmQ (envelope-from ) for ; Sat, 06 Jun 2020 20:17:16 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C3B959404D3 for ; Sat, 6 Jun 2020 20:17:15 +0000 (UTC) Received: from localhost ([::1]:35326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhfFi-00085P-As for larch@yhetil.org; Sat, 06 Jun 2020 16:17:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhfFW-00085G-15 for guix-patches@gnu.org; Sat, 06 Jun 2020 16:17:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41008) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhfFV-0007s1-M3 for guix-patches@gnu.org; Sat, 06 Jun 2020 16:17:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jhfFV-0003bA-IL for guix-patches@gnu.org; Sat, 06 Jun 2020 16:17:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41143] [PATCH 1/2] mapped-devices: Allow target to be list of strings Resent-From: Mikhail Tsykalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 06 Jun 2020 20:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41143 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Lars-Dominik Braun Cc: 41143@debbugs.gnu.org Received: via spool by 41143-submit@debbugs.gnu.org id=B41143.159147459113787 (code B ref 41143); Sat, 06 Jun 2020 20:17:01 +0000 Received: (at 41143) by debbugs.gnu.org; 6 Jun 2020 20:16:31 +0000 Received: from localhost ([127.0.0.1]:52554 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhfF1-0003aJ-G6 for submit@debbugs.gnu.org; Sat, 06 Jun 2020 16:16:31 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:42981) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhfEl-0003Zo-UN for 41143@debbugs.gnu.org; Sat, 06 Jun 2020 16:16:31 -0400 Received: by mail-lj1-f196.google.com with SMTP id y11so14190981ljm.9 for <41143@debbugs.gnu.org>; Sat, 06 Jun 2020 13:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=/iKxUxy6sFcdI50uc7hmEkyl+Z37uZSxrK4oN5GpMx8=; b=ZT0N+7T4Y2HZWpPNqSr9vTR8Flc9XjjGYgTB6to6cZ0zPLKuVlz+wSOsVRc6J602/x izCEO7itfHayRLNzwr0Hhrea7Qy2n7lBJD0XLs4o6VgpmDYY/OG4rAfN6efhfshlOBCm TMBDTOagu0OjnUG7gkc7NkSSK8Z4uY5KNSW2i8t2YjB0OUraUxrTxIOrF/w3tQt96MC1 crhyBf7vH0/8jV8rAbwzgxyMpXgTtLk02lp3Cxi9wVAac/UYBq2W+i94oYETJEcgH7+H FxueNNWWDVL/1XdMm0q9c3Ib4fUqQFc7Tmb4NmiNrDUYJVNEwOLOaryW9DAKZMBuz5Cj Sllg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=/iKxUxy6sFcdI50uc7hmEkyl+Z37uZSxrK4oN5GpMx8=; b=T1Vecx75OxcWAmTMNvu97p2wLBu1jfICHXFSDOGDWm6eLh3fq2AyLJcXh5tyQx3dnO JBmaH1hzbvmghewBKvwFzfiYEmTUalqdZt5Nxpp3iQBKmmMnZlbS1Eca1v4D6zac+SxB gwT6rLfd9mZ/wngNqzPB8M9ipljQITdYCgYEufIizSn6HEqFnasQAH+ezF/IL3s7dJSd fDV2HkPge3Ui/Cxi5D3GkzgYTH5dNlQmJP1mNS947mvDoJMuVmCAM+Y4J2QUdE41M4E1 JaCZ4dR9k3NyNMnjNWIGcGHqvttDJrZRkaQaXB9SOFVUVp38JBp2WTY3qoRuXgw1pBqg UBzQ== X-Gm-Message-State: AOAM530y/JXCn67tQJuFTYPl6bmYEXg9XStZUhfSYvyK2L260jdrxglE Jz1oCm3F6IMSohMchRJg8zc4CI1MY8w= X-Google-Smtp-Source: ABdhPJyjjZ3VLUmYytZsaG/Iqv6wGcg9lbiwNKkKOV/8uZvzJ13/yNGyYkEGHL7Ry5peqN7vZyyfBA== X-Received: by 2002:a2e:975a:: with SMTP id f26mr7782982ljj.302.1591474569566; Sat, 06 Jun 2020 13:16:09 -0700 (PDT) Received: from [192.168.0.75] ([88.201.200.191]) by smtp.gmail.com with ESMTPSA id q126sm2180063ljb.41.2020.06.06.13.16.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Jun 2020 13:16:08 -0700 (PDT) References: <20200606134015.GA204960@noor.fritz.box> From: Mikhail Tsykalov Message-ID: <8c852805-38e6-92b2-15cf-43d47818782e@gmail.com> Date: Sat, 6 Jun 2020 23:16:07 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Icedove/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200606134015.GA204960@noor.fritz.box> Content-Type: multipart/mixed; boundary="------------1A97B72BAF4C52A821880B2A" Content-Language: en-US X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=ZT0N+7T4; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: T8K8RZv4SDiC This is a multi-part message in MIME format. --------------1A97B72BAF4C52A821880B2A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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 --------------1A97B72BAF4C52A821880B2A Content-Type: text/x-patch; charset=UTF-8; name="0002-mapped-devices-Add-lvm-device-mapping.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-mapped-devices-Add-lvm-device-mapping.patch" >From e9a2b441190fe18ebc4f5a8c73707edab3459d58 Mon Sep 17 00:00:00 2001 From: Mikhail Tsykalov 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 --------------1A97B72BAF4C52A821880B2A--