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 QCFoO8MHtl5pFQAA0tVLHw (envelope-from ) for ; Sat, 09 May 2020 01:30:43 +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 iAX0MtAHtl6meAAAbx9fmQ (envelope-from ) for ; Sat, 09 May 2020 01:30:56 +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 B0514940D66 for ; Sat, 9 May 2020 01:30:54 +0000 (UTC) Received: from localhost ([::1]:52216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXEKN-00039S-9Q for larch@yhetil.org; Fri, 08 May 2020 21:30:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXECk-0007OI-6W for guix-patches@gnu.org; Fri, 08 May 2020 21:23:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jXECj-0007PL-SZ for guix-patches@gnu.org; Fri, 08 May 2020 21:23:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jXECj-0007UY-Ot for guix-patches@gnu.org; Fri, 08 May 2020 21:23:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41143] [PATCH 2/2] mapped-devices: Add 'lvm-device-mapping' References: In-Reply-To: Resent-From: tsmish Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 09 May 2020 01:23: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: 41143@debbugs.gnu.org Received: via spool by 41143-submit@debbugs.gnu.org id=B41143.158898734428740 (code B ref 41143); Sat, 09 May 2020 01:23:01 +0000 Received: (at 41143) by debbugs.gnu.org; 9 May 2020 01:22:24 +0000 Received: from localhost ([127.0.0.1]:46517 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXEC8-0007TU-Hd for submit@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 ) id 1jXEC7-0007TI-E6 for 41143@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@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 Date: Sat, 9 May 2020 01:22:07 +0000 Message-ID: Content-Type: text/plain; charset="UTF-8" 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-Mailman-Approved-At: Fri, 08 May 2020 21:29:37 -0400 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 X-Spam-Score: 0.09 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=qJ1Wg+j7; 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-Scan-Result: default: False [0.09 / 13.00]; GENERIC_REPUTATION(0.00)[-0.54022583666808]; DWL_DNSWL_FAIL(0.00)[209.51.188.17:server fail]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; R_DKIM_REJECT(1.00)[gmail.com:s=20161025]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_NONE(0.00)[]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.09), country: US(-0.00), ip: 209.51.188.17(-0.54)]; DKIM_TRACE(0.00)[gmail.com:-]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_IN_DNSWL_FAIL(0.00)[209.51.188.17:server fail]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; TAGGED_FROM(0.00)[larch=yhetil.org]; FROM_NEQ_ENVFROM(0.00)[tsymsh@gmail.com,guix-patches-bounces@gnu.org]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[41143@debbugs.gnu.org]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.51.188.17:from]; RCVD_COUNT_SEVEN(0.00)[8]; FORGED_SENDER_MAILLIST(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : SPF not aligned (relaxed),none] X-TUID: /NrLTw2AJaSZ "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