From debbugs-submit-bounces@debbugs.gnu.org Fri May 08 21:12:59 2020 Received: (at submit) by debbugs.gnu.org; 9 May 2020 01:12:59 +0000 Received: from localhost ([127.0.0.1]:46511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXE31-0007Dr-IP for submit@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 ) id 1jXE2z-0007Dg-8K for submit@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 ) id 1jXE2z-0003tF-3H for guix-patches@gnu.org; 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 ) id 1jXE2y-0003s6-13 for guix-patches@gnu.org; Fri, 08 May 2020 21:12:56 -0400 Received: by mail-qt1-x841.google.com with SMTP id v4so2187389qte.3 for ; 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 Date: Sat, 9 May 2020 01:12:43 +0000 Message-ID: Subject: [PATCH 1/2] mapped-devices: Allow target to be list of strings To: guix-patches@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::841; envelope-from=tsymsh@gmail.com; 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@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 ." (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) ; (location mapped-device-location (default (current-source-location)) (innate))) -- 2.26.2 From debbugs-submit-bounces@debbugs.gnu.org Fri May 08 21:22:24 2020 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: Subject: [PATCH 2/2] mapped-devices: Add 'lvm-device-mapping' To: 41143@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 41143 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From debbugs-submit-bounces@debbugs.gnu.org Thu May 14 18:53:40 2020 Received: (at 41143) by debbugs.gnu.org; 14 May 2020 22:53:40 +0000 Received: from localhost ([127.0.0.1]:35166 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZMjQ-0001dp-I5 for submit@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 ) id 1jZMjO-0001cz-AG for 41143@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@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@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@debbugs.gnu.org From: Mikhail Tsykalov Subject: Some clarification Message-ID: <7e96c284-c69c-965f-6bae-9546b1c711ad@gmail.com> 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@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From debbugs-submit-bounces@debbugs.gnu.org Thu May 14 21:17:50 2020 Received: (at 41143) by debbugs.gnu.org; 15 May 2020 01:17:50 +0000 Received: from localhost ([127.0.0.1]:35241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZOz0-0005td-FV for submit@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 ) id 1jZOyy-0005tN-Kh for 41143@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@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@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@debbugs.gnu.org From: Mikhail Tsykalov Subject: [PATCH] mapped-devices: Document lvm-mapping-device. Message-ID: 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@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From debbugs-submit-bounces@debbugs.gnu.org Sat May 16 13:38:20 2020 Received: (at control) by debbugs.gnu.org; 16 May 2020 17:38:20 +0000 Received: from localhost ([127.0.0.1]:41697 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ja0lQ-0007Zx-Hu for submit@debbugs.gnu.org; Sat, 16 May 2020 13:38:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43702) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ja0lP-0007Zc-1S for control@debbugs.gnu.org; Sat, 16 May 2020 13:38:19 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:45253) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ja0lJ-0005PU-OV for control@debbugs.gnu.org; Sat, 16 May 2020 13:38:13 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41672 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ja0lJ-0004lg-73 for control@debbugs.gnu.org; Sat, 16 May 2020 13:38:13 -0400 Date: Sat, 16 May 2020 19:38:11 +0200 Message-Id: <87pnb3pypo.fsf@gnu.org> To: control@debbugs.gnu.org From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Subject: control message for bug #41143 MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) retitle 41143 [PATCH 1/2] Add 'lvm-device-mapping' quit From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 06 09:40:30 2020 Received: (at submit) by debbugs.gnu.org; 6 Jun 2020 13:40:30 +0000 Received: from localhost ([127.0.0.1]:51086 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhZ3m-0006MS-M8 for submit@debbugs.gnu.org; Sat, 06 Jun 2020 09:40:30 -0400 Received: from lists.gnu.org ([209.51.188.17]:40440) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhZ3k-0006MK-Kg for submit@debbugs.gnu.org; Sat, 06 Jun 2020 09:40:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhZ3k-0001Bg-B6 for guix-patches@gnu.org; Sat, 06 Jun 2020 09:40:28 -0400 Received: from mout-y-209.mailbox.org ([2001:67c:2050:1::465:209]:30684) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1jhZ3i-0002u8-CR for guix-patches@gnu.org; Sat, 06 Jun 2020 09:40:27 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-y-209.mailbox.org (Postfix) with ESMTPS id 49fLHS4C7GzQlGx; Sat, 6 Jun 2020 15:40:20 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6xq.net; s=MBO0001; t=1591450818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mSVH3KvzsXWGpss3B8jQY3B2YYCjGRWZQdZR4dEqBrg=; b=fbQz0Ptz985uYB6Z2JUxx/jCrvWIWfElUyLsoWv8UXBUB/o3ccYOjhWU5yuw1vdLmuDlxF FL2Bwy7DOpHIkOonGEvr+Xn4DkXwRcJ2ulxx2mUhbnd3eYu/EQ9EfabgP6LjBlTRZE80oy T+XUoUnPFRt2+RJQiKNsRPRp/S0TBuFIT7BOr3cDETQrjuY9KP/1Lf5uGFllc8K+JGzQqC L0khonJRkEUzzhKMCkoobzOfxYFCLYZq3no4gZYEoOUrIw0Hm7l0dw3qu7ggNmhCAJmF12 MlG27NhVJqnzFg2GG8MbKX3rixInEDRkO3iuyxcvLWEUhmq7kKtqTDBpT3Gfog== Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id i4frZqK9b5WU; Sat, 6 Jun 2020 15:40:17 +0200 (CEST) Date: Sat, 6 Jun 2020 15:40:15 +0200 From: Lars-Dominik Braun To: tsmish Subject: Re: [PATCH 1/2] mapped-devices: Allow target to be list of strings Message-ID: <20200606134015.GA204960@noor.fritz.box> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: 674ED1815 X-Rspamd-Score: -3.70 / 15.00 / 15.00 Received-SPF: pass client-ip=2001:67c:2050:1::465:209; envelope-from=lars@6xq.net; helo=mout-y-209.mailbox.org 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, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit Cc: guix-patches@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) Hi, 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 Relevant part of my config.scm: (mapped-devices (list (mapped-device (source "disk3") (target "disk3-data") (type lvm-device-mapping)))) (file-systems (append (list … (file-system (device "/dev/mapper/disk3-data") (mount-point "/storage/disk3") (type "ext4") (dependencies mapped-devices)) ) …)) 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? Lars From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 06 16:16:31 2020 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) Subject: Re: [PATCH 1/2] mapped-devices: Allow target to be list of strings To: Lars-Dominik Braun 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-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 07 02:49:06 2020 Received: (at 41143) by debbugs.gnu.org; 7 Jun 2020 06:49:06 +0000 Received: from localhost ([127.0.0.1]:53232 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhp7B-0000PW-TU for submit@debbugs.gnu.org; Sun, 07 Jun 2020 02:49:06 -0400 Received: from mout-y-209.mailbox.org ([91.198.250.237]:36228) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhp79-0000Ow-DB for 41143@debbugs.gnu.org; Sun, 07 Jun 2020 02:49:04 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-y-209.mailbox.org (Postfix) with ESMTPS id 49fn6J6qb2zQlGw; Sun, 7 Jun 2020 08:48:56 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6xq.net; s=MBO0001; t=1591512535; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IkSOplMoRANfcWxJ6oL5oE4faGMWvNXQNkXv5BOI8GY=; b=p/kOpSoTblrvqv03MSsYiTulrWuNXU9F2OyVryAwMUxk8bzbaANZlcgvJc6Wsa6WAeVyZH ChqBcQ3Er6h3DFyb0bmKQVw4Ii6DI5t18SxBkDOa4VIzhDRLfY8g+cUP1IPDHkBYLU4o/P ugFzyLCwRhFuFV16QbrH5OZLcJc+hLoonxOd1ZKgrcYJiUy0wWGv1Y2wJyWEvKIpvGJy36 pCP6U+s1LaBPhsydiKafgjXJbU9v5tJ8Hcy/0LxYlfj93ouru3sT0InbsDbbH9ZKOnfJAD Q91wIKRaXH+gLsh6qlIppwPKtHQvfqIxFEBHDQxOh4fLvlv94s+S04R8jbxkMw== Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id F1F40gU3piYI; Sun, 7 Jun 2020 08:48:53 +0200 (CEST) Date: Sun, 7 Jun 2020 08:48:52 +0200 From: Lars-Dominik Braun To: Mikhail Tsykalov Subject: Re: [PATCH 1/2] mapped-devices: Allow target to be list of strings Message-ID: <20200607064852.GA1408@noor> References: <20200606134015.GA204960@noor.fritz.box> <8c852805-38e6-92b2-15cf-43d47818782e@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8c852805-38e6-92b2-15cf-43d47818782e@gmail.com> X-Rspamd-Queue-Id: 0358D180B X-Rspamd-Score: -2.44 / 15.00 / 15.00 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, > 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. yes, both `guix system reconfigure` and a reboot are working properly now. (This is a non-boot disk though.) Thanks! > 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. I agree, using device nodes would probably break guix’ rollback if you decide to change the VG. Lars From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 09 16:38:51 2020 Received: (at 41143) by debbugs.gnu.org; 9 Sep 2020 20:38:51 +0000 Received: from localhost ([127.0.0.1]:34875 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kG6ri-0007hN-UC for submit@debbugs.gnu.org; Wed, 09 Sep 2020 16:38:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44712) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kG6re-0007h7-Gu for 41143@debbugs.gnu.org; Wed, 09 Sep 2020 16:38:49 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:43550) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG6rZ-0005uu-73; Wed, 09 Sep 2020 16:38:41 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55676 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kG6rY-0000YA-Pr; Wed, 09 Sep 2020 16:38:41 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: tsmish Subject: Re: [bug#41143] [PATCH 1/2] mapped-devices: Allow target to be list of strings References: Date: Wed, 09 Sep 2020 22:38:34 +0200 In-Reply-To: (tsmish's message of "Sat, 9 May 2020 01:12:43 +0000") Message-ID: <874ko6n0s5.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Mikhail, Sorry for the very late reply! Vacations came by, and by now this entry is at the bottom of the patch tracker. :-) People repeatedly ask for LVM support, so I guess you=E2=80=99ll make them = all happy! Great you got it into shape. tsmish skribis: > (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(-) Side note: We=E2=80=99ll a commit log that follows our conventions=C2=B9 bu= t that=E2=80=99s something I can help with. =C2=B9 https://guix.gnu.org/manual/en/html_node/Submitting-Patches.html > 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 > ." > (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))) > + "-")))) To avoid duplicating the (if (list? t) =E2=80=A6) everywhere, I propose ins= tead the following approach: 1. Rename =E2=80=98target=E2=80=99 to =E2=80=98targets=E2=80=99 (plural) = and likewise for the accessor, and agree that it always contains a list; 2. Rename =E2=80=98mapped-device=E2=80=99 to =E2=80=98%mapped-device=E2= =80=99 and add a =E2=80=98mapped-device=E2=80=99 backward-compatibility macro that allo= ws for a =E2=80=98target=E2=80=99 (singular) field and automatically turns its = value into a list. See the =E2=80=98origin=E2=80=99 macro in (guix packages) for a= n example of how to do that (that macro allows users to specify =E2=80=98sha256=E2= =80=99 instead of =E2=80=98hash=E2=80=99). 3. Add a deprecated =E2=80=98mapped-device-target=E2=80=99 (singular) tha= t returns the first element returned by =E2=80=98mapped-device-targets=E2=80=99. We=E2=80=99ll need to adjust doc/guix.texi accordingly. How does that sound? Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 09 16:48:39 2020 Received: (at 41143) by debbugs.gnu.org; 9 Sep 2020 20:48:39 +0000 Received: from localhost ([127.0.0.1]:34900 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kG71D-0007ys-2P for submit@debbugs.gnu.org; Wed, 09 Sep 2020 16:48:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48050) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kG71A-0007yg-RM for 41143@debbugs.gnu.org; Wed, 09 Sep 2020 16:48:37 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:43739) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG714-0007Ld-3E; Wed, 09 Sep 2020 16:48:30 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55678 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kG712-0001Gb-LU; Wed, 09 Sep 2020 16:48:29 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: tsmish Subject: Re: [bug#41143] [PATCH 2/2] mapped-devices: Add 'lvm-device-mapping' References: Date: Wed, 09 Sep 2020 22:48:22 +0200 In-Reply-To: (tsmish's message of "Sat, 9 May 2020 01:22:07 +0000") Message-ID: <87sgbqllrd.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) tsmish skribis: > "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. Oh, I guess that=E2=80=99s fine. Could you place this as a comment above t= he =E2=80=9Cvgscan=E2=80=9D invocation? > 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. Uh, future work. :-) > +(define (open-lvm-device source target) > + #~(begin > + (use-modules > + (srfi srfi-1) > + (srfi srfi-26)) Since this gets spliced into the initrd expression (not at the top level), we cannot have =E2=80=98use-modules=E2=80=99 here (well, it may not= work as expected, as you found out with srfi-26 macros). I=E2=80=99d suggest adding (srfi srfi-1) to the =E2=80=98use-modules=E2=80= =99 form in =E2=80=98raw-initrd=E2=80=99, in (gnu system linux-initrd), so you can rely= on it (srfi-26 is already there). It would be great to have a system test for LVM support. We have tests for Btrfs, RAID with mdadm, etc., but these are system installation tests in (gnu tests install). Do you think we could have either an installation test or maybe a less expensive test for LVM? Thanks for your work! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 24 12:10:07 2020 Received: (at 41143) by debbugs.gnu.org; 24 Sep 2020 16:10:07 +0000 Received: from localhost ([127.0.0.1]:41443 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLTot-0000Zc-51 for submit@debbugs.gnu.org; Thu, 24 Sep 2020 12:10:07 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:37543) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLTor-0000Yt-29 for 41143@debbugs.gnu.org; Thu, 24 Sep 2020 12:10:06 -0400 Received: by mail-lf1-f67.google.com with SMTP id z19so4576361lfr.4 for <41143@debbugs.gnu.org>; Thu, 24 Sep 2020 09:10:05 -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-transfer-encoding:content-language; bh=a5iHukRJJLGvVs2UXoDekRWt++wRLcJjO0uQkKnVQ3w=; b=Cdtm+zYl8gS8b14B70w3vkhuPYnoGyJ2HXnVBXJYuE1hirs2160xofzOogo7hKAhSK Or+NwvsXr5mX+ZVQV6qW90A/apup9zhavvtmjK9ZvU2DALs+aSgTaZDAnLxfTT/GMgvX QP+fkSW3UKu1aQIIBxRUr5UdD+kxL91q6s6P+Z+k4NiSIfwOkFOu2kUTtckw+l9tyb9/ GZNPgtdnB3aoAXBFWcKUV70aGm0ToO8Sy0dwo2gfzlc+ORDCEDAVLEErzWMLtcsaonrD 0fj4VcJYMlZQr1Q6CNFnrDvpGZU4X0zxhOSDCFLl/jiWqTd+qP6wCoVj3l0IPEIJ4HSP HBmg== 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-transfer-encoding :content-language; bh=a5iHukRJJLGvVs2UXoDekRWt++wRLcJjO0uQkKnVQ3w=; b=GhD5ZADGv4iZvEAyCK907Yvnyu7Wg/jfUPSKXNhnkHTBp4qvxQZuuGfgRzQfIwuos6 D6YY8xsDxEPQERaovNYl6ce6DN+fueVzR1WR5oDP64aM6MkgbGxIte+wgFt/Rg5DsomI e89Usbp8k4CjE4bgWSYC8aTGRJVreRo9cU0n8PJPmkziYN7Sqh02+CdHDMZCunIUpw2z pkWq+evSCnnYrjQi5StLjZKM6fLFhar212wn+vT+3yYV+kWqJ8TajuSdi/tBNIYFeDre krWdIMytq54dLvfgrMRVAHB3raGxsJnBLZk21en+91Licyc/aQZ2mj7aC4xawUQaXpHu sRsA== X-Gm-Message-State: AOAM533Y75YscScc6mkXpcu9K9V6/5mu5QqSMMuRbBBLt13Mi9DhMCJl MQallqfbCXC6t34mk4MolBwhhQpgoPWH0Q== X-Google-Smtp-Source: ABdhPJxUFADdVgDg/DOy9XoNDH9G1c1QLMMrKlbbnz5e6LAUSfxNBIhYHNHdsNmlOAPU0Xue2ulbxw== X-Received: by 2002:ac2:4c9c:: with SMTP id d28mr62210lfl.93.1600963798681; Thu, 24 Sep 2020 09:09:58 -0700 (PDT) Received: from [192.168.0.143] ([88.201.200.148]) by smtp.gmail.com with ESMTPSA id j8sm2438084lfr.80.2020.09.24.09.09.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Sep 2020 09:09:58 -0700 (PDT) Subject: Re: [bug#41143] [PATCH 1/2] mapped-devices: Allow target to be list of strings To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= References: <874ko6n0s5.fsf@gnu.org> From: Mikhail Tsykalov Message-ID: <9ac560cc-8660-f034-c0d8-536b68d20f68@gmail.com> Date: Thu, 24 Sep 2020 19:09:57 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Icedove/68.12.0 MIME-Version: 1.0 In-Reply-To: <874ko6n0s5.fsf@gnu.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Score: -0.2 (/) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.2 (-) Hi Ludovic, On 09.09.2020 23:38, Ludovic Courtès wrote: >> 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 >> ." >> (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))) >> + "-")))) > To avoid duplicating the (if (list? t) …) everywhere, I propose instead > the following approach: > > 1. Rename ‘target’ to ‘targets’ (plural) and likewise for the > accessor, and agree that it always contains a list; > > 2. Rename ‘mapped-device’ to ‘%mapped-device’ and add a > ‘mapped-device’ backward-compatibility macro that allows for a > ‘target’ (singular) field and automatically turns its value into a > list. See the ‘origin’ macro in (guix packages) for an example of > how to do that (that macro allows users to specify ‘sha256’ instead > of ‘hash’). > > 3. Add a deprecated ‘mapped-device-target’ (singular) that returns the > first element returned by ‘mapped-device-targets’. While this looks like a good idea, doesn't this break code that implements mapped-device and assumes that target is a string. Suddenly passing a string to a mapped-device constructor results in a list passed to open/close. Also, what functions should do if they expect a string but get a list of them? Ignore everything but the first item? Implement mandatory check function? Doesn't this change push complexity out of mapped-device to implementations of it. Basically, this change will break all current implementations of mapped-devices, so I wanted to hear your thoughts on it before continuing. Mikhail From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 25 05:34:58 2020 Received: (at 41143) by debbugs.gnu.org; 25 Sep 2020 09:34:58 +0000 Received: from localhost ([127.0.0.1]:42659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLk81-0006pb-Ni for submit@debbugs.gnu.org; Fri, 25 Sep 2020 05:34:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54384) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLk80-0006pP-Pn for 41143@debbugs.gnu.org; Fri, 25 Sep 2020 05:34:57 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:52419) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLk7v-00028B-1r; Fri, 25 Sep 2020 05:34:51 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=60760 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kLk7u-0001kn-IV; Fri, 25 Sep 2020 05:34:50 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Mikhail Tsykalov Subject: Re: [bug#41143] [PATCH 1/2] mapped-devices: Allow target to be list of strings References: <874ko6n0s5.fsf@gnu.org> <9ac560cc-8660-f034-c0d8-536b68d20f68@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 4 =?utf-8?Q?Vend=C3=A9miaire?= an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Fri, 25 Sep 2020 11:34:49 +0200 In-Reply-To: <9ac560cc-8660-f034-c0d8-536b68d20f68@gmail.com> (Mikhail Tsykalov's message of "Thu, 24 Sep 2020 19:09:57 +0300") Message-ID: <87r1qq2o92.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Mikhail, Mikhail Tsykalov skribis: > On 09.09.2020 23:38, Ludovic Court=C3=A8s wrote: >>> 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 >>> ." >>> (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))) >>> + "-")))) >> To avoid duplicating the (if (list? t) =E2=80=A6) everywhere, I propose = instead >> the following approach: >> >> 1. Rename =E2=80=98target=E2=80=99 to =E2=80=98targets=E2=80=99 (plur= al) and likewise for the >> accessor, and agree that it always contains a list; >> >> 2. Rename =E2=80=98mapped-device=E2=80=99 to =E2=80=98%mapped-device= =E2=80=99 and add a >> =E2=80=98mapped-device=E2=80=99 backward-compatibility macro that = allows for a >> =E2=80=98target=E2=80=99 (singular) field and automatically turns = its value into a >> list. See the =E2=80=98origin=E2=80=99 macro in (guix packages) f= or an example of >> how to do that (that macro allows users to specify =E2=80=98sha256= =E2=80=99 instead >> of =E2=80=98hash=E2=80=99). >> >> 3. Add a deprecated =E2=80=98mapped-device-target=E2=80=99 (singular)= that returns the >> first element returned by =E2=80=98mapped-device-targets=E2=80=99. > > While this looks like a good idea, doesn't this break code that > implements mapped-device and assumes that target is a string. Suddenly=20 > passing a string to a mapped-device constructor results in a list > passed to open/close. Also, what functions should do if they expect a > string but get a list of them? Ignore everything but the first item? > Implement mandatory check function? Doesn't this change push > complexity out of mapped-device to implementations of it. The intent of what I propose above is (1) to not break existing code, and (2) to avoid duplicating checks and conversions at every call site. #1 is achieved by providing a deprecated =E2=80=98mapped-device-target=E2= =80=99 (singular) procedure, for example. Does that make sense? Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 25 09:36:21 2020 Received: (at 41143) by debbugs.gnu.org; 25 Sep 2020 13:36:21 +0000 Received: from localhost ([127.0.0.1]:43056 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLntd-0000eN-9M for submit@debbugs.gnu.org; Fri, 25 Sep 2020 09:36:21 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:37012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLntb-0000dt-0X for 41143@debbugs.gnu.org; Fri, 25 Sep 2020 09:36:19 -0400 Received: by mail-lj1-f195.google.com with SMTP id n25so2505391ljj.4 for <41143@debbugs.gnu.org>; Fri, 25 Sep 2020 06:36:18 -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-transfer-encoding:content-language; bh=aOCfoT3vgHE383oj6lE6jqqhjXe49/xiwTf5JyYIqZs=; b=Ht+VMvndcnAkAcDpa4dLsAr3Fr+GHVyCsKHYUa+Qk/OwtYh+UuA89gul00xjdxsgjd k4vL9rN344Tvhneu0zMwezYZivRySOLeqDRdnNMTDg/FIZYgfFkSWu56dznu1DVkucII vyLqmQitu1dx68oyMpraqMOXQdAcVmXv97sWk7jBs8q/+MgskOXWNx6BkFQFQYZif0wN v+X8EZp0lKHk9Vkd8nf8LmwBD/1y2faX1qxQcbDtLi4c+r0wQCJSw0GIe5YyvoxwDlvO /1HlaBPdD46FojBzJeYSRMGe6Z8p7r31Re6mqG3gPWoRcmn8O1GkKhwkohfhm2IWsg/y TmZg== 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-transfer-encoding :content-language; bh=aOCfoT3vgHE383oj6lE6jqqhjXe49/xiwTf5JyYIqZs=; b=OvWV0h507PsPMl76CQrlElh7f/3YYYuuM17+gax4zp6hM/IAaTtKVKQeFJbAeDgXi5 k68c4A6KSobTbVkau012kyEeRpWN0eBNBJ4ib2z8bR6hJn6/NtmJUVOwZ1g9vkJYoByc PeuKHbIq4E9O824eW8961I3KhfezwUDL1VbnKFgd+d1RRacReJYknPwjaPAA1C+oCUpO RZRXVCYN/QrBx15fFGpZgLe9F503ELw1MP5BCHGmSrmqHTpjCBYIAQBZ90ZNB5owtsXO trnCnt1rkTWEx2ISSLZyi7cm5Y4uPt19SRrbpXIGaoShcgqEfo0MTiVWg21HGqBsvfKs Q0dA== X-Gm-Message-State: AOAM5317JvFCi8Y0MOX9MQ3UKhDf6O+IGIIt7P810i4F/sUA7cswcB4+ Ui/3vIdc7zZ4TzrAEMFhozfwo8oG4QtPug== X-Google-Smtp-Source: ABdhPJzVEq3PyB7c0VBsjqIlsabrzPPJIEk+JVB5mEuW4UHVrsaAqYMgQu7ibs3p+wRR2SY3yMkOUg== X-Received: by 2002:a2e:8645:: with SMTP id i5mr1296027ljj.209.1601040972266; Fri, 25 Sep 2020 06:36:12 -0700 (PDT) Received: from [192.168.0.143] ([88.201.200.148]) by smtp.gmail.com with ESMTPSA id y26sm2255271lfy.163.2020.09.25.06.36.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 25 Sep 2020 06:36:11 -0700 (PDT) Subject: Re: [bug#41143] [PATCH 1/2] mapped-devices: Allow target to be list of strings To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= References: <874ko6n0s5.fsf@gnu.org> <9ac560cc-8660-f034-c0d8-536b68d20f68@gmail.com> <87r1qq2o92.fsf@gnu.org> From: Mikhail Tsykalov Message-ID: Date: Fri, 25 Sep 2020 16:36:11 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Icedove/68.12.0 MIME-Version: 1.0 In-Reply-To: <87r1qq2o92.fsf@gnu.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Score: -0.2 (/) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.2 (-) Hi, Ludovic On 25.09.2020 12:34, Ludovic Courtès wrote: > Hi Mikhail, > > Mikhail Tsykalov skribis: > >> On 09.09.2020 23:38, Ludovic Courtès wrote: >>>> 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 >>>> ." >>>> (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))) >>>> + "-")))) >>> To avoid duplicating the (if (list? t) …) everywhere, I propose instead >>> the following approach: >>> >>> 1. Rename ‘target’ to ‘targets’ (plural) and likewise for the >>> accessor, and agree that it always contains a list; >>> >>> 2. Rename ‘mapped-device’ to ‘%mapped-device’ and add a >>> ‘mapped-device’ backward-compatibility macro that allows for a >>> ‘target’ (singular) field and automatically turns its value into a >>> list. See the ‘origin’ macro in (guix packages) for an example of >>> how to do that (that macro allows users to specify ‘sha256’ instead >>> of ‘hash’). >>> >>> 3. Add a deprecated ‘mapped-device-target’ (singular) that returns the >>> first element returned by ‘mapped-device-targets’. >> While this looks like a good idea, doesn't this break code that >> implements mapped-device and assumes that target is a string. Suddenly >> passing a string to a mapped-device constructor results in a list >> passed to open/close. Also, what functions should do if they expect a >> string but get a list of them? Ignore everything but the first item? >> Implement mandatory check function? Doesn't this change push >> complexity out of mapped-device to implementations of it. > The intent of what I propose above is (1) to not break existing code, > and (2) to avoid duplicating checks and conversions at every call site. > > #1 is achieved by providing a deprecated ‘mapped-device-target’ > (singular) procedure, for example. > > Does that make sense? I'm sorry if I didn't make myself clear, but it doesn't seem like open/close functions even use any mapped-device-* procedures, they just get passed source and target field directly. What I meant was this change will require changes to luks-device-mapping, raid-device-mapping and all other device mappings that users may have implemented in their local trees/config. To be fair, after thinking about it for a bit, I think that this issue can be solved by renaming mapped-device-kind and providing compatibility macros similar to %mapped-device. Still question remains about what should we do if a list gets passed to a kind that doesn't expect it, but I think we can just raise an error in macro if that's the case. Does this sound fine to you? Thanks, Mikhail From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 25 12:21:01 2020 Received: (at 41143) by debbugs.gnu.org; 25 Sep 2020 16:21:01 +0000 Received: from localhost ([127.0.0.1]:45165 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLqSy-00036p-SJ for submit@debbugs.gnu.org; Fri, 25 Sep 2020 12:21:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40264) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLqSx-00036d-FM for 41143@debbugs.gnu.org; Fri, 25 Sep 2020 12:21:00 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39854) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLqSs-0006WC-5j; Fri, 25 Sep 2020 12:20:54 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=33164 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kLqSr-0005tR-G0; Fri, 25 Sep 2020 12:20:53 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Mikhail Tsykalov Subject: Re: [bug#41143] [PATCH 1/2] mapped-devices: Allow target to be list of strings References: <874ko6n0s5.fsf@gnu.org> <9ac560cc-8660-f034-c0d8-536b68d20f68@gmail.com> <87r1qq2o92.fsf@gnu.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 4 =?utf-8?Q?Vend=C3=A9miaire?= an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Fri, 25 Sep 2020 18:20:51 +0200 In-Reply-To: (Mikhail Tsykalov's message of "Fri, 25 Sep 2020 16:36:11 +0300") Message-ID: <87pn69j09o.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Mikhail Tsykalov skribis: [...] >>> While this looks like a good idea, doesn't this break code that >>> implements mapped-device and assumes that target is a string. Suddenly >>> passing a string to a mapped-device constructor results in a list >>> passed to open/close. Also, what functions should do if they expect a >>> string but get a list of them? Ignore everything but the first item? >>> Implement mandatory check function? Doesn't this change push >>> complexity out of mapped-device to implementations of it. >> The intent of what I propose above is (1) to not break existing code, >> and (2) to avoid duplicating checks and conversions at every call site. >> >> #1 is achieved by providing a deprecated =E2=80=98mapped-device-target= =E2=80=99 >> (singular) procedure, for example. >> >> Does that make sense? > > I'm sorry if I didn't make myself clear, but it doesn't seem like > open/close functions even use any mapped-device-* procedures, they > just get passed source and target field directly. What I meant was > this change will require changes to luks-device-mapping, > raid-device-mapping and all other device mappings that users may have > implemented in their local trees/config. Ah yes, got it. I tend to think it=E2=80=99s OK though, if we assume all the implementation= s are in-tree, which would be consistent with the fact that the internals (how to implement a mapped device type) are undocumented. WDYT? IOW, I think we must provide compatibility for users (people writing their OS config, including perhaps service definitions) while leaving us the ability to change internal interfaces. Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 01 18:55:16 2020 Received: (at 41143) by debbugs.gnu.org; 1 Oct 2020 22:55:16 +0000 Received: from localhost ([127.0.0.1]:38697 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO7To-0001s5-0f for submit@debbugs.gnu.org; Thu, 01 Oct 2020 18:55:16 -0400 Received: from mail-lf1-f41.google.com ([209.85.167.41]:34574) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO7Tm-0001rp-7O for 41143@debbugs.gnu.org; Thu, 01 Oct 2020 18:55:15 -0400 Received: by mail-lf1-f41.google.com with SMTP id u8so624794lff.1 for <41143@debbugs.gnu.org>; Thu, 01 Oct 2020 15:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IRizteFNwyomMsE5X0Zz9sFQi78xFaoBzN997H68J0o=; b=OwswxR23coBJBn3g0so76zg/eewaMqm7TAaeuWj/rRkJidnW6yCFitfo0aokP7N8N9 k1xKP9tgWkoPzHec4YoGiW9EYoGi8Xsa++ybGwFJDGT10InlCKH4CFcePDMMVmA/W6IN 49ivt2VKO+gN2NHQLvNCA/j8t2PwQYgLKT3ApNHVNMK4hrJuYuM/ZV1kBpI2fQChDxjH RuZQMs5iBxJgn1CaKYeKAbqQCBU5mzEC757Pt2LohT/S+Bd9WZeUWrEh8ADTfExB4ump G/Zp+YCUiJb4iL8Bvax5z5Y+eJ/bZdrC52MWDBKIRjgCNy9Kl1wGqGfZVECY1QmwuEPS FTPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IRizteFNwyomMsE5X0Zz9sFQi78xFaoBzN997H68J0o=; b=UL+m228YUrMcZNRApB6OPO1PnnmbXXn7ikH9i2RRuSzlP8TC7aodftMCC80gPMHeqQ JAB9BseipoN73RORfRh6MwCZomwpoF+TUym0E7e6yjdxE/qWYOMEYDXk69pZRNyV96yD 0B3KKvqm8c8MLoB++qAS0XsQeSpTcapdSJEX10QysYyKetdpfiQkmLUU4I92bE6AD/la WQKW7ds9T2K2ks5CtaPBgwVOEDj5/Z+y1aZndWsVD9UC8y6RPURHCjoxTDThLAUWTBOP JZB1b6py/iJalt1xtnBCv6c+VS5UY6mFVWWXtcFgHkSRdbW13W910N7LW0lm75BorLTa 6+Xw== X-Gm-Message-State: AOAM532mqOUPxai6WyeBwMLy+eiHJsEiiaOqnfqDZ1qGDpun62n/G+Xo CJ8ce0SPPMg3onGS0Zf2ng0= X-Google-Smtp-Source: ABdhPJx0xxfrekldK0mfdl+BkVtuaePdKn55O69SahJsFDW5C5ODcCvmgT6paXTqODcXjErfqnuaHA== X-Received: by 2002:a19:b55:: with SMTP id 82mr3252141lfl.43.1601592907994; Thu, 01 Oct 2020 15:55:07 -0700 (PDT) Received: from localhost.localdomain ([88.201.200.148]) by smtp.googlemail.com with ESMTPSA id 68sm748795lfe.27.2020.10.01.15.55.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 15:55:07 -0700 (PDT) From: Mikhail Tsykalov To: ludo@gnu.org Subject: [PATCH v2 1/2] mapped-devices: Allow target to be list of strings. Date: Fri, 2 Oct 2020 01:48:59 +0300 Message-Id: <20201001224900.28989-1-tsymsh@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <87pn69j09o.fsf@gnu.org> References: <87pn69j09o.fsf@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org, Mikhail Tsykalov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/system/mapped-devices.scm (): Rename constructor to %mapped-device. [target]: Remove field. [targets]: New field. Adjust users. (mapped-device-compatibility-helper, mapped-device): New macros. (mapped-device-target): New deprecated procedure. --- gnu/services/base.scm | 3 ++- gnu/system.scm | 11 +++++----- gnu/system/linux-initrd.scm | 2 +- gnu/system/mapped-devices.scm | 40 ++++++++++++++++++++++++++++------- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 04bc991356..4aa14ebf99 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -291,7 +291,8 @@ FILE-SYSTEM." (define (mapped-device->shepherd-service-name md) "Return the symbol that denotes the shepherd service of MD, a ." (symbol-append 'device-mapping- - (string->symbol (mapped-device-target md)))) + (string->symbol (string-join + (mapped-device-targets md) "-")))) (define dependency->shepherd-service-name (match-lambda diff --git a/gnu/system.scm b/gnu/system.scm index bdb696fe2e..1bb812256f 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -444,9 +444,9 @@ 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" <>) + (mapped-device-targets md)))) (operating-system-mapped-devices os)) '()))) @@ -466,11 +466,12 @@ 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/" <>) + (mapped-device-targets device)))) (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/linux-initrd.scm b/gnu/system/linux-initrd.scm index b8a30c0abc..db02059a26 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -196,7 +196,7 @@ upon error." ;; List of gexps to open the mapped devices. (map (lambda (md) (let* ((source (mapped-device-source md)) - (target (mapped-device-target md)) + (target (mapped-device-targets md)) (type (mapped-device-type md)) (open (mapped-device-kind-open type))) (open source target))) diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index 31c50c4e40..8622418fcf 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -28,6 +28,7 @@ formatted-message &fix-hint &error-location)) + #:use-module (guix deprecation) #:use-module (gnu services) #:use-module (gnu services shepherd) #:use-module (gnu system uuid) @@ -42,10 +43,12 @@ #:use-module (srfi srfi-35) #:use-module (ice-9 match) #:use-module (ice-9 format) - #:export (mapped-device + #:export (%mapped-device + mapped-device mapped-device? mapped-device-source mapped-device-target + mapped-device-targets mapped-device-type mapped-device-location @@ -70,15 +73,36 @@ ;;; ;;; Code: -(define-record-type* mapped-device +(define-record-type* %mapped-device make-mapped-device mapped-device? (source mapped-device-source) ;string | list of strings - (target mapped-device-target) ;string + (targets mapped-device-targets) ;list of strings (type mapped-device-type) ; (location mapped-device-location (default (current-source-location)) (innate))) +(define-syntax mapped-device-compatibility-helper + (syntax-rules (target) + ((_ () (fields ...)) + (%mapped-device fields ...)) + ((_ ((target exp) rest ...) (others ...)) + (%mapped-device others ... + (targets (list exp)) + rest ...)) + ((_ (field rest ...) (others ...)) + (mapped-device-compatibility-helper (rest ...) + (others ... field))))) + +(define-syntax-rule (mapped-device fields ...) + "Build an record, automatically converting 'target' field +specifications to 'targets'." + (mapped-device-compatibility-helper (fields ...) ())) + +(define-deprecated (mapped-device-target md) + mapped-device-targets + (car (mapped-device-targets md))) + (define-record-type* mapped-device-kind make-mapped-device-kind mapped-device-kind? @@ -100,7 +124,7 @@ (($ source target ($ open close)) (shepherd-service - (provision (list (symbol-append 'device-mapping- (string->symbol target)))) + (provision (list (symbol-append 'device-mapping- (string->symbol (string-join target "-"))))) (requirement '(udev)) (documentation "Map a device node using Linux's device mapper.") (start #~(lambda () #$(open source target))) @@ -198,12 +222,12 @@ option of @command{guix system}.\n") (error "LUKS partition not found" source)) source) - #$target))))) + #$(car target)))))) (define (close-luks-device source target) "Return a gexp that closes TARGET, a LUKS device." #~(zero? (system* #$(file-append cryptsetup-static "/sbin/cryptsetup") - "close" #$target))) + "close" #$(car target)))) (define* (check-luks-device md #:key needed-for-boot? @@ -259,12 +283,12 @@ TARGET (e.g., \"/dev/md0\"), using 'mdadm'." ;; Use 'mdadm-static' rather than 'mdadm' to avoid pulling its whole ;; closure (80 MiB) in the initrd when a RAID device is needed for boot. (zero? (apply system* #$(file-append mdadm-static "/sbin/mdadm") - "--assemble" #$target sources)))) + "--assemble" #$(car target) sources)))) (define (close-raid-device sources target) "Return a gexp that stops the RAID device TARGET." #~(zero? (system* #$(file-append mdadm-static "/sbin/mdadm") - "--stop" #$target))) + "--stop" #$(car target)))) (define raid-device-mapping ;; The type of RAID mapped devices. -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 01 18:55:21 2020 Received: (at 41143) by debbugs.gnu.org; 1 Oct 2020 22:55:21 +0000 Received: from localhost ([127.0.0.1]:38700 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO7Tt-0001sO-Cl for submit@debbugs.gnu.org; Thu, 01 Oct 2020 18:55:21 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:37106) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO7Tr-0001rx-Ha for 41143@debbugs.gnu.org; Thu, 01 Oct 2020 18:55:20 -0400 Received: by mail-lj1-f196.google.com with SMTP id n25so244226ljj.4 for <41143@debbugs.gnu.org>; Thu, 01 Oct 2020 15:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EzzJoW38mrHAJcbDTO+pguDrvkrr2cfTztT1WG67MdY=; b=VV5upk4QG0caFQlCyzNT2WKjxg1PSxH9PjYlRm3z82PjclMc9tKlcDJ6muI3qBNxQs Oh6/8o1HoVbQ3uCIoY5FlUo61AOiZW6zijkFMFmPTFlxZtNSkKNYAHtVjpy/x42s++P5 9kZRk6EgoL71S4sei8lwlhLdrTp7wrTmMpAqBN/eJRZEhrNfBtTCp2R+IO1wJAyq8OvQ lAKOe3rL24QCti7LhLvSD7QY6iVpnSrOKaiggyj4CV5E9xRm2gAFc+PRyt07zqUMX4vc Ex+9rzhtCgl5oztRE4kNWPP3+OPqWX+Ktz6HldUxXN1EnxGecPxkEa77srC0iULr3c/g 9IAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EzzJoW38mrHAJcbDTO+pguDrvkrr2cfTztT1WG67MdY=; b=cVeeb44sAAgjb5B/7/PgUwfVFHrBL8yZNUg1rOnA5DliJMQxqi8rwfW4locvwd1ljy 3D2B9LoJ6YicDV+z6eSftWRE1M9n5jBtXcCsl260rOhE1UWCUMOj4bTWUAnIhSFo8iv8 +vuY/hrivKOVx0dpCKA6XcRXPTe0ZupVq2yIKIT/5n4bw+fsLfIbeaWTeUI4z3i6sTSJ 01tksEwHoAGGNeI+RA9nfft4YX9PeuOPugY/MYfQ5bAeAWDqsRXMMZ8ylC765VqQUY2Q ESccoXnljrhbY5w6R/A52Fja7FhAkanND6d8yVljNfok4DpzrFTcnJSYNgxugc9n6jer pZgw== X-Gm-Message-State: AOAM530PHGaaLmIltC2drjnzhJs6xzT19N8tKvClfWfZ5BIkuvl4Tks0 NNX86+U4UFlcstqVGIb4Bjo= X-Google-Smtp-Source: ABdhPJyEBd+JEjxKK8B1iWjbqCxrcU1dYGcHpHEjm19OIOC2zvY+cGqe8tmty+XeImVJoGmZp2uyjQ== X-Received: by 2002:a2e:8e30:: with SMTP id r16mr3276478ljk.304.1601592913489; Thu, 01 Oct 2020 15:55:13 -0700 (PDT) Received: from localhost.localdomain ([88.201.200.148]) by smtp.googlemail.com with ESMTPSA id 68sm748795lfe.27.2020.10.01.15.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 15:55:13 -0700 (PDT) From: Mikhail Tsykalov To: ludo@gnu.org Subject: [PATCH v2 2/2] mapped-devices: Add 'lvm-device-mapping'. Date: Fri, 2 Oct 2020 01:49:00 +0300 Message-Id: <20201001224900.28989-2-tsymsh@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001224900.28989-1-tsymsh@gmail.com> References: <87pn69j09o.fsf@gnu.org> <20201001224900.28989-1-tsymsh@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org, Mikhail Tsykalov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/system/mapped-devices.scm (lvm-device-mapping, open-lvm-device, close-lvm-device): New variables. * gnu/tests/install.scm (%lvm-separate-home-os, %lvm-separate-home-os-source, %lvm-separate-home-installation-script, %test-lvm-separate-home-os): New variables. * gnu/system/linux-initrd.scm (raw-initrd): Add (srfi srfi-1) to initrd expression. --- gnu/system/linux-initrd.scm | 1 + gnu/system/mapped-devices.scm | 25 +++++++++- gnu/tests/install.scm | 87 +++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 2 deletions(-) diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index db02059a26..41cbe28c3c 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -217,6 +217,7 @@ upon error." (gnu system file-systems) ((guix build utils) #:hide (delete)) (guix build bournish) ;add the 'bournish' meta-command + (srfi srfi-1) (srfi srfi-26) ;; FIXME: The following modules are for diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index 8622418fcf..8088bd99a3 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -36,7 +36,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) @@ -64,7 +64,8 @@ check-device-initrd-modules ;XXX: needs a better place luks-device-mapping - raid-device-mapping)) + raid-device-mapping + lvm-device-mapping)) ;;; Commentary: ;;; @@ -296,4 +297,24 @@ TARGET (e.g., \"/dev/md0\"), using 'mdadm'." (open open-raid-device) (close close-raid-device))) +(define (open-lvm-device source targets) + #~(and + (zero? (system* #$(file-append lvm2-static "/sbin/lvm") + "vgchange" "--activate" "ay" #$source)) + ; /dev/mapper nodes are usually created by udev, but udev may be unavailable at the time we run this. So we create them here. + (zero? (system* #$(file-append lvm2-static "/sbin/lvm") + "vgscan" "--mknodes")) + (every file-exists? (map (lambda (file) (string-append "/dev/mapper/" file)) + '#$targets)))) + + +(define (close-lvm-device source targets) + #~(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 diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm index dee2b870e8..84fe8bda78 100644 --- a/gnu/tests/install.scm +++ b/gnu/tests/install.scm @@ -65,6 +65,7 @@ %test-btrfs-root-on-subvolume-os %test-jfs-root-os %test-f2fs-root-os + %test-lvm-separate-home-os %test-gui-installed-os %test-gui-installed-os-encrypted @@ -794,6 +795,92 @@ build (current-guix) and then store a couple of full system images.") (run-basic-test %encrypted-root-os command "encrypted-root-os" #:initialization enter-luks-passphrase))))) + +;;; +;;; Separate /home on LVM +;;; + +; Since LVM support in guix currently doesn't allow root-on-LVM we use /home on LVM +(define-os-with-source (%lvm-separate-home-os %lvm-separate-home-os-source) + (use-modules (gnu) (gnu tests)) + + (operating-system + (host-name "separate-home-on-lvm") + (timezone "Europe/Paris") + (locale "en_US.utf8") + + (bootloader (bootloader-configuration + (bootloader grub-bootloader) + (target "/dev/vdb"))) + (kernel-arguments '("console=ttyS0")) + + (mapped-devices (list (mapped-device + (source "vg0") + (target "vg0-home") + (type lvm-device-mapping)))) + (file-systems (cons* (file-system + (device (file-system-label "root-fs")) + (mount-point "/") + (type "ext4")) + (file-system + (device "/dev/mapper/vg0-home") + (mount-point "/home") + (type "ext4") + (dependencies mapped-devices)) + %base-file-systems)) + (users %base-user-accounts) + (services (cons (service marionette-service-type + (marionette-configuration + (imported-modules '((gnu services herd) + (guix combinators))))) + %base-services)))) + +(define %lvm-separate-home-installation-script + "\ +. /etc/profile +set -e -x +guix --version + +export GUIX_BUILD_OPTIONS=--no-grafts +parted --script /dev/vdb mklabel gpt \\ + mkpart primary ext2 1M 3M \\ + mkpart primary ext2 3M 1.6G \\ + mkpart primary 1.6G 3.2G \\ + set 1 boot on \\ + set 1 bios_grub on +pvcreate /dev/vdb3 +vgcreate vg0 /dev/vdb3 +lvcreate -L 1.6G -n home vg0 +vgchange -ay +mkfs.ext4 -L root-fs /dev/vdb2 +mkfs.ext4 /dev/mapper/vg0-home +mount /dev/vdb2 /mnt +mkdir /mnt/home +mount /dev/mapper/vg0-home /mnt/home +df -h /mnt /mnt/home +herd start cow-store /mnt +mkdir /mnt/etc +cp /etc/target-config.scm /mnt/etc/config.scm +guix system init /mnt/etc/config.scm /mnt --no-substitutes +sync +reboot\n") + +(define %test-lvm-separate-home-os + (system-test + (name "lvm-separate-home-os") + (description + "Test functionality of an OS installed with a LVM /home partition") + (value + (mlet* %store-monad ((image (run-install %lvm-separate-home-os + %lvm-separate-home-os-source + #:script + %lvm-separate-home-installation-script + #:packages (list lvm2-static) + #:target-size (* 3200 MiB))) + (command (qemu-command/writable-image image))) + (run-basic-test %lvm-separate-home-os + `(,@command) "lvm-separate-home-os"))))) + ;;; ;;; Btrfs root file system. -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 01 19:15:49 2020 Received: (at 41143) by debbugs.gnu.org; 1 Oct 2020 23:15:49 +0000 Received: from localhost ([127.0.0.1]:38714 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO7nh-0002MB-Gg for submit@debbugs.gnu.org; Thu, 01 Oct 2020 19:15:49 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35885) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO7nd-0002Lt-GF for 41143@debbugs.gnu.org; Thu, 01 Oct 2020 19:15:48 -0400 Received: by mail-lj1-f194.google.com with SMTP id r24so280776ljm.3 for <41143@debbugs.gnu.org>; Thu, 01 Oct 2020 16:15:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=nHWnxfRZaIgoAg68PBwUBN5seyBc72VJQhK8SWKmawo=; b=XIjqv4/265od6YmHW1vzeHCEizUvBTnIP3mnj+/5Czy4xFDGMBfGgwmmqgHPw/EBYK vhFCTqpqpQ4F4MBGYZmlweDaQ4bq90yT7WbL6nb5jFk0JowtoDYiumaFge6u0wO6Gs6e FSMG8ScU422PembHPY8ls78qPgEIbS+zSiLXoAH9oIc+iXupFOKUaRuOLFQ+NiV0pUWn QQ9M+tsiM9s9gtrtBLfJnaVdi/sEUeLYBrwvrSU0lwR/pXPP2UImeIj4UqQ6Hrzp641Q Opmlz1ZuAMkK725kWoDZb3A2FvIHRBbmH4tTMe76lm/+kQGQns1d6Z8JONUPyxE4UQqk zl8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=nHWnxfRZaIgoAg68PBwUBN5seyBc72VJQhK8SWKmawo=; b=rKWIcK3IofEzD4umargw+VRv/eM/Wyn6CO2L/Qj8SeUAIQPB4DewL1RolStS46XOgw tzSI1WuMx9bfhfrvRJbom3s939JzvHNr9SNszBxuadluAw3lN+lk8yhEpILi2dCT6IGQ siranbMUHVdYcmsudaGf/4Fxecr1Q193N+WV/KZ0x3s1N76Z1oHkFa2mdaQUyz+VFmbk mD8Ejhl0mpmd5oVkPmHrRaA3inpJyJjZjfrbsToDRV7chOyM1rpetULRe3Dv5PCL+Vry +5gSO+lUcKCQJ7sSlaTQlZiU9floMO0s0LzQCqsvhed+3gilTFYyKhx5AgwyMo1hgAkz Vp5w== X-Gm-Message-State: AOAM530iYSpOHJ41u/fSZPDwabwo4SE2BLkTzOdUbY3sxJDFdiZW0Pse JXXkTx2kxnv9rt9ts9bgOtLkCuV51iQFWA== X-Google-Smtp-Source: ABdhPJzf22eYw1cis4kTOAexSxfMriZy0Xolk30MrUE0Ry1T1+Hzz0vzagZ/GBL4i7P9XoJjA6KTaw== X-Received: by 2002:a2e:920f:: with SMTP id k15mr3205263ljg.353.1601594138990; Thu, 01 Oct 2020 16:15:38 -0700 (PDT) Received: from [192.168.0.143] ([88.201.200.148]) by smtp.gmail.com with ESMTPSA id t25sm596093ljk.71.2020.10.01.16.15.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Oct 2020 16:15:38 -0700 (PDT) Subject: Re: [bug#41143] [PATCH 1/2] mapped-devices: Allow target to be list of strings To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= References: <874ko6n0s5.fsf@gnu.org> <9ac560cc-8660-f034-c0d8-536b68d20f68@gmail.com> <87r1qq2o92.fsf@gnu.org> <87pn69j09o.fsf@gnu.org> From: Mikhail Tsykalov Message-ID: <02538eb3-f3cf-2783-b99a-15d77e2be546@gmail.com> Date: Fri, 2 Oct 2020 02:15:37 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Icedove/68.12.0 MIME-Version: 1.0 In-Reply-To: <87pn69j09o.fsf@gnu.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Spam-Score: -0.3 (/) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) Hi, Hoping I didn't mess up too much with patches. System tests seem to be somewhat unstable and really long, but I think raid-root-os and encrypted-root-os pass. Somewhat unsure about adding "(srfi srfi-1)" to raw-initrd since current implementation shouldn't ever end up in initrd, but this would be helpful if we actually implement booting from LVM and I think I saw request to add it there in open-raid-device. I also tend not to answer to things I agree with and was a bit busy with work recently, so I hope you understand me taking so long to answer. Thanks, Mikhail From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 04 06:28:45 2020 Received: (at 41143) by debbugs.gnu.org; 4 Oct 2020 10:28:45 +0000 Received: from localhost ([127.0.0.1]:45000 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kP1G1-0005ZT-5L for submit@debbugs.gnu.org; Sun, 04 Oct 2020 06:28:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36660) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kP1Fx-0005ZC-QZ for 41143@debbugs.gnu.org; Sun, 04 Oct 2020 06:28:43 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39718) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kP1Fs-0008CY-I9; Sun, 04 Oct 2020 06:28:36 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=46166 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kP1Fq-0002bU-Dt; Sun, 04 Oct 2020 06:28:34 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Mikhail Tsykalov Subject: Re: [PATCH v2 1/2] mapped-devices: Allow target to be list of strings. References: <87pn69j09o.fsf@gnu.org> <20201001224900.28989-1-tsymsh@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 13 =?utf-8?Q?Vend=C3=A9miaire?= an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Sun, 04 Oct 2020 12:28:32 +0200 In-Reply-To: <20201001224900.28989-1-tsymsh@gmail.com> (Mikhail Tsykalov's message of "Fri, 2 Oct 2020 01:48:59 +0300") Message-ID: <874knaffov.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Mikhail, Mikhail Tsykalov skribis: > * gnu/system/mapped-devices.scm (): Rename constructor to > %mapped-device. > [target]: Remove field. > [targets]: New field. Adjust users. > (mapped-device-compatibility-helper, mapped-device): New macros. > (mapped-device-target): New deprecated procedure. Thanks for following up. I think we=E2=80=99re almost done, some comments below: > --- a/gnu/system/linux-initrd.scm > +++ b/gnu/system/linux-initrd.scm > @@ -196,7 +196,7 @@ upon error." > ;; List of gexps to open the mapped devices. > (map (lambda (md) > (let* ((source (mapped-device-source md)) > - (target (mapped-device-target md)) > + (target (mapped-device-targets md)) I think we should write =E2=80=98targets=E2=80=99 (plural) everywhere. Tha= t can help avoid confusion IMO. > - #$target))))) > + #$(car target)))))) >=20=20 > (define (close-luks-device source target) > "Return a gexp that closes TARGET, a LUKS device." > #~(zero? (system* #$(file-append cryptsetup-static "/sbin/cryptsetup") > - "close" #$target))) > + "close" #$(car target)))) As per our coding convention (info "(guix) Data Types and Pattern Matching"), I=E2=80=99d recommend using =E2=80=98match=E2=80=99 (define (close-luks-device source targets) (match targets ((target) #~(zero? (system* =E2=80=A6 #$target))))) That has the added benefit that it errors out if TARGETS is not exactly a one-element list. > (define (close-raid-device sources target) > "Return a gexp that stops the RAID device TARGET." > #~(zero? (system* #$(file-append mdadm-static "/sbin/mdadm") > - "--stop" #$target))) > + "--stop" #$(car target)))) Same here. Could you also update =E2=80=9CMapped Devices=E2=80=9D in doc/guix.texi to = mention the new =E2=80=98targets=E2=80=99 field? Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 04 06:34:57 2020 Received: (at 41143) by debbugs.gnu.org; 4 Oct 2020 10:34:57 +0000 Received: from localhost ([127.0.0.1]:45007 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kP1M0-0005jJ-S6 for submit@debbugs.gnu.org; Sun, 04 Oct 2020 06:34:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37432) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kP1Lz-0005j7-Je for 41143@debbugs.gnu.org; Sun, 04 Oct 2020 06:34:56 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39882) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kP1Lu-0000Ls-BF; Sun, 04 Oct 2020 06:34:50 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=46170 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kP1Ls-0000Yn-UZ; Sun, 04 Oct 2020 06:34:49 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Mikhail Tsykalov Subject: Re: [PATCH v2 2/2] mapped-devices: Add 'lvm-device-mapping'. References: <87pn69j09o.fsf@gnu.org> <20201001224900.28989-1-tsymsh@gmail.com> <20201001224900.28989-2-tsymsh@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 13 =?utf-8?Q?Vend=C3=A9miaire?= an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Sun, 04 Oct 2020 12:34:47 +0200 In-Reply-To: <20201001224900.28989-2-tsymsh@gmail.com> (Mikhail Tsykalov's message of "Fri, 2 Oct 2020 01:49:00 +0300") Message-ID: <87y2kme0u0.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Mikhail Tsykalov skribis: > * gnu/system/mapped-devices.scm (lvm-device-mapping, open-lvm-device, > close-lvm-device): New variables. > > * gnu/tests/install.scm (%lvm-separate-home-os, > %lvm-separate-home-os-source, %lvm-separate-home-installation-script, > %test-lvm-separate-home-os): New variables. > > * gnu/system/linux-initrd.scm (raw-initrd): Add (srfi srfi-1) to initrd e= xpression. Nice! > +++ b/gnu/system/linux-initrd.scm > @@ -217,6 +217,7 @@ upon error." > (gnu system file-systems) > ((guix build utils) #:hide (delete)) > (guix build bournish) ;add the 'bournish' meta-c= ommand > + (srfi srfi-1) Maybe add a comment saying this is for =E2=80=98lvm-device-mapping=E2=80=99. > +(define %test-lvm-separate-home-os > + (system-test > + (name "lvm-separate-home-os") > + (description > + "Test functionality of an OS installed with a LVM /home partition") Great. Do you know what it would take to have a LVM on root? (As future work, of course.) Could you document =E2=80=98lvm-device-mapping=E2=80=99 under =E2=80=9CMapp= ed Devices=E2=80=9D in doc/guix.texi? Essentially adding a @defvr for =E2=80=98lvm-device-mapping= =E2=80=99 and a paragraph with an example. There=E2=80=99s also a sentence somewhere in guix.texi that says LVM is not supported, we can probably remove it. :-) Last: you can add an entry in etc/news.scm to mention LVM support since that=E2=80=99s a long awaited feature! Thanks! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 05 04:48:50 2020 Received: (at 41143) by debbugs.gnu.org; 5 Nov 2020 09:48:50 +0000 Received: from localhost ([127.0.0.1]:51717 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kabsw-0005de-5E for submit@debbugs.gnu.org; Thu, 05 Nov 2020 04:48:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42646) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kabst-0005dQ-9M for 41143@debbugs.gnu.org; Thu, 05 Nov 2020 04:48:49 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54073) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kabsn-0006Ax-Vh; Thu, 05 Nov 2020 04:48:41 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=34600 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kabsn-0007d0-E9; Thu, 05 Nov 2020 04:48:41 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Mikhail Tsykalov Subject: Re: [bug#41143] [PATCH v2 1/2] mapped-devices: Allow target to be list of strings. References: <87pn69j09o.fsf@gnu.org> <20201001224900.28989-1-tsymsh@gmail.com> <874knaffov.fsf@gnu.org> Date: Thu, 05 Nov 2020 10:48:39 +0100 In-Reply-To: <874knaffov.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Sun, 04 Oct 2020 12:28:32 +0200") Message-ID: <87o8kc5e2w.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Mikhail, Did you have a chance to look into the proposed changes? https://issues.guix.gnu.org/41143 Would be nice to have LVM support integrated! TIA, Ludo=E2=80=99. Ludovic Court=C3=A8s skribis: > Hi Mikhail, > > Mikhail Tsykalov skribis: > >> * gnu/system/mapped-devices.scm (): Rename constructor to >> %mapped-device. >> [target]: Remove field. >> [targets]: New field. Adjust users. >> (mapped-device-compatibility-helper, mapped-device): New macros. >> (mapped-device-target): New deprecated procedure. > > Thanks for following up. I think we=E2=80=99re almost done, some comments > below: > >> --- a/gnu/system/linux-initrd.scm >> +++ b/gnu/system/linux-initrd.scm >> @@ -196,7 +196,7 @@ upon error." >> ;; List of gexps to open the mapped devices. >> (map (lambda (md) >> (let* ((source (mapped-device-source md)) >> - (target (mapped-device-target md)) >> + (target (mapped-device-targets md)) > > I think we should write =E2=80=98targets=E2=80=99 (plural) everywhere. T= hat can help > avoid confusion IMO. > >> - #$target))))) >> + #$(car target)))))) >>=20=20 >> (define (close-luks-device source target) >> "Return a gexp that closes TARGET, a LUKS device." >> #~(zero? (system* #$(file-append cryptsetup-static "/sbin/cryptsetup") >> - "close" #$target))) >> + "close" #$(car target)))) > > As per our coding convention (info "(guix) Data Types and Pattern > Matching"), I=E2=80=99d recommend using =E2=80=98match=E2=80=99 > > (define (close-luks-device source targets) > (match targets > ((target) > #~(zero? (system* =E2=80=A6 #$target))))) > > That has the added benefit that it errors out if TARGETS is not exactly > a one-element list. > >> (define (close-raid-device sources target) >> "Return a gexp that stops the RAID device TARGET." >> #~(zero? (system* #$(file-append mdadm-static "/sbin/mdadm") >> - "--stop" #$target))) >> + "--stop" #$(car target)))) > > Same here. > > Could you also update =E2=80=9CMapped Devices=E2=80=9D in doc/guix.texi t= o mention the > new =E2=80=98targets=E2=80=99 field? > > Thanks, > Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 06 04:47:49 2020 Received: (at 41143) by debbugs.gnu.org; 6 Nov 2020 09:47:49 +0000 Received: from localhost ([127.0.0.1]:55132 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kayLV-0002KT-9d for submit@debbugs.gnu.org; Fri, 06 Nov 2020 04:47:49 -0500 Received: from mail-lj1-f174.google.com ([209.85.208.174]:35774) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kayLS-0002KA-PU for 41143@debbugs.gnu.org; Fri, 06 Nov 2020 04:47:47 -0500 Received: by mail-lj1-f174.google.com with SMTP id 11so730877ljf.2 for <41143@debbugs.gnu.org>; Fri, 06 Nov 2020 01:47:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=maxqnBOxb+eyJTUPUEz7CfiQdAxY0gIvpmOMXnfgrT0=; b=RBRhyAKIdmqDaIexnj7qphzb/8DendwqDe9BO9vu0z4g8rqBzDUM3311mqDAQps8GX M/1BA18UeRLbOsv3NrRvXzDsRUGbvcDXOJMmiV6Q3DqGD5wiM1JsNO5N55CY9Iqhl6Or W+XaRdImYOSqzbgKBI2ec0521SkWDR4avtmcFp8sKMQP9rgdvPy3oIdbZmF5KJDmx4uk KSesDtyCJPFhI+WRvDAz9hL1oZDXeC6M4GoUN/s7OLf76aAaaD+umopdOcCSFg4yEihU 6ZuaiLqDRB+YUuBcCOq/ZWNeCRI1XQ/haSjfgHYqUlKp9ctQtTjB5yuM5inC8Md4EwDh wdAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=maxqnBOxb+eyJTUPUEz7CfiQdAxY0gIvpmOMXnfgrT0=; b=S2OsjnrSbE3yAWBTZYkhpcLByZNXa2/JLtCVM1sLM/s7J08BscdhfgrRTUZL3HP3ov 9A6VBAdu9G17B/HlCx7mHLDkvUyrIhybCqYX6M+kncEheVN5K22LJM0wN/v4xLT5g2Yx Z4TsgeBo+m3Z3GO2uKeji7BPs2eye8GIQHqmUBFPGWhWLJoVinxdbLu1mmKaKKXLFmvN JZHkhK+QvPm6T7l5QA7yDJIkOsGLzFLpn2X/ng/wUXbUOAWn+Pqo6R9ZQxBgYXkmnKLd HGDbWRPJFkuPH8jBhFdy9HY5ta2KSEE9Awt55XMRm+hymtaqb1BwTvIeGwPNAUcLWsiP 633g== X-Gm-Message-State: AOAM5317NmZfbu5XzG+G0GfhvDQu1rWTTlR2OS2MbAWcRgy9OvP4RbfU MFXDjYH/C/dXC2FFYtk5c2g= X-Google-Smtp-Source: ABdhPJwz7E3gOs3W09UQI/p9sQBM1boD/aOmgfCbo75u5wcvKwOx7jr0b+LFWz60wxy9sgy+1pCs5A== X-Received: by 2002:a2e:b04e:: with SMTP id d14mr432765ljl.38.1604656060967; Fri, 06 Nov 2020 01:47:40 -0800 (PST) Received: from akiha.sknt.ru ([88.201.200.148]) by smtp.googlemail.com with ESMTPSA id f9sm88496ljg.53.2020.11.06.01.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 01:47:40 -0800 (PST) From: Mikhail Tsykalov To: ludo@gnu.org Subject: [PATCH v3 2/2] mapped-devices: Add 'lvm-device-mapping'. Date: Fri, 6 Nov 2020 12:47:38 +0300 Message-Id: <20201106094738.132011-2-tsymsh@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201106094738.132011-1-tsymsh@gmail.com> References: <87o8kc5e2w.fsf@gnu.org> <20201106094738.132011-1-tsymsh@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org, Mikhail Tsykalov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/system/mapped-devices.scm (lvm-device-mapping, open-lvm-device, close-lvm-device): New variables. * gnu/tests/install.scm (%lvm-separate-home-os, %lvm-separate-home-os-source, %lvm-separate-home-installation-script, %test-lvm-separate-home-os): New variables. * gnu/system/linux-initrd.scm (raw-initrd): Add (srfi srfi-1) to initrd expression. --- doc/guix.texi | 25 +++++++++- gnu/system/linux-initrd.scm | 1 + gnu/system/mapped-devices.scm | 25 +++++++++- gnu/tests/install.scm | 87 +++++++++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+), 4 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 02b92a9b69..acb6453165 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12713,7 +12713,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. @@ -12726,7 +12725,8 @@ 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 @@ -12735,6 +12735,9 @@ 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 targets This list of strings specifies names of the resulting mapped devices in case there are several. The format is identical to @var{target}. @@ -12758,6 +12761,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 @@ -12815,6 +12823,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 diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index 3e2f1282cc..85e493fecb 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -217,6 +217,7 @@ upon error." (gnu system file-systems) ((guix build utils) #:hide (delete)) (guix build bournish) ;add the 'bournish' meta-command + (srfi srfi-1) ;for lvm-device-mapping (srfi srfi-26) ;; FIXME: The following modules are for diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index 8b5aec983d..559c27bb28 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -36,7 +36,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) @@ -64,7 +64,8 @@ check-device-initrd-modules ;XXX: needs a better place luks-device-mapping - raid-device-mapping)) + raid-device-mapping + lvm-device-mapping)) ;;; Commentary: ;;; @@ -304,4 +305,24 @@ TARGET (e.g., \"/dev/md0\"), using 'mdadm'." (open open-raid-device) (close close-raid-device))) +(define (open-lvm-device source targets) + #~(and + (zero? (system* #$(file-append lvm2-static "/sbin/lvm") + "vgchange" "--activate" "ay" #$source)) + ; /dev/mapper nodes are usually created by udev, but udev may be unavailable at the time we run this. So we create them here. + (zero? (system* #$(file-append lvm2-static "/sbin/lvm") + "vgscan" "--mknodes")) + (every file-exists? (map (lambda (file) (string-append "/dev/mapper/" file)) + '#$targets)))) + + +(define (close-lvm-device source targets) + #~(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 diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm index dee2b870e8..2d99638ecc 100644 --- a/gnu/tests/install.scm +++ b/gnu/tests/install.scm @@ -65,6 +65,7 @@ %test-btrfs-root-on-subvolume-os %test-jfs-root-os %test-f2fs-root-os + %test-lvm-separate-home-os %test-gui-installed-os %test-gui-installed-os-encrypted @@ -795,6 +796,92 @@ build (current-guix) and then store a couple of full system images.") #:initialization enter-luks-passphrase))))) +;;; +;;; Separate /home on LVM +;;; + +;; Since LVM support in guix currently doesn't allow root-on-LVM we use /home on LVM +(define-os-with-source (%lvm-separate-home-os %lvm-separate-home-os-source) + (use-modules (gnu) (gnu tests)) + + (operating-system + (host-name "separate-home-on-lvm") + (timezone "Europe/Paris") + (locale "en_US.utf8") + + (bootloader (bootloader-configuration + (bootloader grub-bootloader) + (target "/dev/vdb"))) + (kernel-arguments '("console=ttyS0")) + + (mapped-devices (list (mapped-device + (source "vg0") + (target "vg0-home") + (type lvm-device-mapping)))) + (file-systems (cons* (file-system + (device (file-system-label "root-fs")) + (mount-point "/") + (type "ext4")) + (file-system + (device "/dev/mapper/vg0-home") + (mount-point "/home") + (type "ext4") + (dependencies mapped-devices)) + %base-file-systems)) + (users %base-user-accounts) + (services (cons (service marionette-service-type + (marionette-configuration + (imported-modules '((gnu services herd) + (guix combinators))))) + %base-services)))) + +(define %lvm-separate-home-installation-script + "\ +. /etc/profile +set -e -x +guix --version + +export GUIX_BUILD_OPTIONS=--no-grafts +parted --script /dev/vdb mklabel gpt \\ + mkpart primary ext2 1M 3M \\ + mkpart primary ext2 3M 1.6G \\ + mkpart primary 1.6G 3.2G \\ + set 1 boot on \\ + set 1 bios_grub on +pvcreate /dev/vdb3 +vgcreate vg0 /dev/vdb3 +lvcreate -L 1.6G -n home vg0 +vgchange -ay +mkfs.ext4 -L root-fs /dev/vdb2 +mkfs.ext4 /dev/mapper/vg0-home +mount /dev/vdb2 /mnt +mkdir /mnt/home +mount /dev/mapper/vg0-home /mnt/home +df -h /mnt /mnt/home +herd start cow-store /mnt +mkdir /mnt/etc +cp /etc/target-config.scm /mnt/etc/config.scm +guix system init /mnt/etc/config.scm /mnt --no-substitutes +sync +reboot\n") + +(define %test-lvm-separate-home-os + (system-test + (name "lvm-separate-home-os") + (description + "Test functionality of an OS installed with a LVM /home partition") + (value + (mlet* %store-monad ((image (run-install %lvm-separate-home-os + %lvm-separate-home-os-source + #:script + %lvm-separate-home-installation-script + #:packages (list lvm2-static) + #:target-size (* 3200 MiB))) + (command (qemu-command/writable-image image))) + (run-basic-test %lvm-separate-home-os + `(,@command) "lvm-separate-home-os"))))) + + ;;; ;;; Btrfs root file system. ;;; -- 2.20.1 From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 06 04:47:50 2020 Received: (at 41143) by debbugs.gnu.org; 6 Nov 2020 09:47:50 +0000 Received: from localhost ([127.0.0.1]:55134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kayLV-0002KV-PZ for submit@debbugs.gnu.org; Fri, 06 Nov 2020 04:47:50 -0500 Received: from mail-lf1-f45.google.com ([209.85.167.45]:39435) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kayLS-0002K9-Lz for 41143@debbugs.gnu.org; Fri, 06 Nov 2020 04:47:47 -0500 Received: by mail-lf1-f45.google.com with SMTP id 184so1048277lfd.6 for <41143@debbugs.gnu.org>; Fri, 06 Nov 2020 01:47:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xm0Kj1RatIR0SRekR+dxHaH2y5bX+eLdjhSOdsHMLJ4=; b=YLItB5ZKVIFY4PEMM3QKXXkdegeQ9m+3fXZeQYqeQXHQSJM/y44t336urFe5X70hX5 SI0uwEDlDuZLpkzIfTmB13a727UPcgepi0QNSWYlEO3zIvqXxOVhpMOvypvQXxI/vpUv xdv9tr1CDRT3TqrppxKnHjZzUb1XA2kuIYDZ7NkOl4UcMa4QCs3FgeCC1sw5JTh/sQ5h FGnOA/WE3wqrqVZiUEyy5tpOEynVXY/hSRrL3ijgdDBOElGvnUFWzAxJCcaSU84WIlE5 3dmyuOvmRdt9u7Ge7XQKcLkYxpWwDgYc2Rmz1tg8E/r/IjmDd14BzNp5WM4XfR3aIR6f qLSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xm0Kj1RatIR0SRekR+dxHaH2y5bX+eLdjhSOdsHMLJ4=; b=QI/HDyy4/0Vklk3SgrnZfdbpnAmkfvplYOnEnxYK31wnuMW1dMkg8VQDtKgAD90XW1 1EbLROfTuQlxPRAXuRQeG7ERzZbis22AjaF9mFdFEjaf3Td6fN5q+f8V3Q3BuaW6Tb6v hRy/mJQ+UGfCYy7PyKBiAPZYJXMQg2N2Uo65Q+qI7Wsw6WN/m6ZFJROhf2Nen5ZTm8FW F2jm9C7WcMVcl9Ke3KX9RpmybtzqvMMBfMy1aNfkKWy19RogEUN/sMJKPT0XDGRwpax6 3Onm63oFsoitS2URxl2cppb6n2ECaqmoW7EAFUqWJKQNeebMxDFaOkNIy2Wwh4/jtgkX ImuA== X-Gm-Message-State: AOAM533qZH+xRZCGbddkD523l2/6kMlITqmuE6/G9vxm4K+TfxAMHtIA +0GOybjt4yQHO054JZXroZg= X-Google-Smtp-Source: ABdhPJxxXgit0zgOKHobnQZQfZoTurmQIPNV/ch+kuzoaLZbJcUMot3c37bn2lrXMCmJueFc+wCkiQ== X-Received: by 2002:a19:34b:: with SMTP id 72mr610759lfd.120.1604656060426; Fri, 06 Nov 2020 01:47:40 -0800 (PST) Received: from akiha.sknt.ru ([88.201.200.148]) by smtp.googlemail.com with ESMTPSA id f9sm88496ljg.53.2020.11.06.01.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 01:47:39 -0800 (PST) From: Mikhail Tsykalov To: ludo@gnu.org Subject: [PATCH v3 1/2] mapped-devices: Allow target to be list of strings. Date: Fri, 6 Nov 2020 12:47:37 +0300 Message-Id: <20201106094738.132011-1-tsymsh@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <87o8kc5e2w.fsf@gnu.org> References: <87o8kc5e2w.fsf@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org, Mikhail Tsykalov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/system/mapped-devices.scm (): Rename constructor to %mapped-device. [target]: Remove field. [targets]: New field. Adjust users. (mapped-device-compatibility-helper, mapped-device): New macros. (mapped-device-target): New deprecated procedure. --- doc/guix.texi | 3 + gnu/services/base.scm | 3 +- gnu/system.scm | 11 ++- gnu/system/linux-initrd.scm | 10 +- gnu/system/mapped-devices.scm | 174 ++++++++++++++++++++-------------- 5 files changed, 119 insertions(+), 82 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 79c79b6a96..02b92a9b69 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12735,6 +12735,9 @@ 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. +@item targets +This list of strings specifies names of the resulting mapped devices in case +there are several. The format is identical to @var{target}. @item type This must be a @code{mapped-device-kind} object, which specifies how diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 04bc991356..4aa14ebf99 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -291,7 +291,8 @@ FILE-SYSTEM." (define (mapped-device->shepherd-service-name md) "Return the symbol that denotes the shepherd service of MD, a ." (symbol-append 'device-mapping- - (string->symbol (mapped-device-target md)))) + (string->symbol (string-join + (mapped-device-targets md) "-")))) (define dependency->shepherd-service-name (match-lambda diff --git a/gnu/system.scm b/gnu/system.scm index bdb696fe2e..1bb812256f 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -444,9 +444,9 @@ 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" <>) + (mapped-device-targets md)))) (operating-system-mapped-devices os)) '()))) @@ -466,11 +466,12 @@ 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/" <>) + (mapped-device-targets device)))) (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/linux-initrd.scm b/gnu/system/linux-initrd.scm index b8a30c0abc..3e2f1282cc 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -195,11 +195,11 @@ upon error." (define device-mapping-commands ;; List of gexps to open the mapped devices. (map (lambda (md) - (let* ((source (mapped-device-source md)) - (target (mapped-device-target md)) - (type (mapped-device-type md)) - (open (mapped-device-kind-open type))) - (open source target))) + (let* ((source (mapped-device-source md)) + (targets (mapped-device-targets md)) + (type (mapped-device-type md)) + (open (mapped-device-kind-open type))) + (open source targets))) mapped-devices)) (define kodir diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index 31c50c4e40..8b5aec983d 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -28,6 +28,7 @@ formatted-message &fix-hint &error-location)) + #:use-module (guix deprecation) #:use-module (gnu services) #:use-module (gnu services shepherd) #:use-module (gnu system uuid) @@ -42,10 +43,12 @@ #:use-module (srfi srfi-35) #:use-module (ice-9 match) #:use-module (ice-9 format) - #:export (mapped-device + #:export (%mapped-device + mapped-device mapped-device? mapped-device-source mapped-device-target + mapped-device-targets mapped-device-type mapped-device-location @@ -70,15 +73,36 @@ ;;; ;;; Code: -(define-record-type* mapped-device +(define-record-type* %mapped-device make-mapped-device mapped-device? (source mapped-device-source) ;string | list of strings - (target mapped-device-target) ;string + (targets mapped-device-targets) ;list of strings (type mapped-device-type) ; (location mapped-device-location (default (current-source-location)) (innate))) +(define-syntax mapped-device-compatibility-helper + (syntax-rules (target) + ((_ () (fields ...)) + (%mapped-device fields ...)) + ((_ ((target exp) rest ...) (others ...)) + (%mapped-device others ... + (targets (list exp)) + rest ...)) + ((_ (field rest ...) (others ...)) + (mapped-device-compatibility-helper (rest ...) + (others ... field))))) + +(define-syntax-rule (mapped-device fields ...) + "Build an record, automatically converting 'target' field +specifications to 'targets'." + (mapped-device-compatibility-helper (fields ...) ())) + +(define-deprecated (mapped-device-target md) + mapped-device-targets + (car (mapped-device-targets md))) + (define-record-type* mapped-device-kind make-mapped-device-kind mapped-device-kind? @@ -97,14 +121,14 @@ (shepherd-service-type 'device-mapping (match-lambda - (($ source target + (($ source targets ($ open close)) (shepherd-service - (provision (list (symbol-append 'device-mapping- (string->symbol target)))) + (provision (list (symbol-append 'device-mapping- (string->symbol (string-join targets "-"))))) (requirement '(udev)) (documentation "Map a device node using Linux's device mapper.") - (start #~(lambda () #$(open source target))) - (stop #~(lambda _ (not #$(close source target)))) + (start #~(lambda () #$(open source targets))) + (stop #~(lambda _ (not #$(close source targets)))) (respawn? #f)))))) (define (device-mapping-service mapped-device) @@ -162,48 +186,52 @@ option of @command{guix system}.\n") ;;; Common device mappings. ;;; -(define (open-luks-device source target) +(define (open-luks-device source targets) "Return a gexp that maps SOURCE to TARGET as a LUKS device, using 'cryptsetup'." (with-imported-modules (source-module-closure '((gnu build file-systems))) - #~(let ((source #$(if (uuid? source) - (uuid-bytevector source) - source))) - ;; XXX: 'use-modules' should be at the top level. - (use-modules (rnrs bytevectors) ;bytevector? - ((gnu build file-systems) - #:select (find-partition-by-luks-uuid))) - - ;; Use 'cryptsetup-static', not 'cryptsetup', to avoid pulling the - ;; whole world inside the initrd (for when we're in an initrd). - (zero? (system* #$(file-append cryptsetup-static "/sbin/cryptsetup") - "open" "--type" "luks" - - ;; Note: We cannot use the "UUID=source" syntax here - ;; because 'cryptsetup' implements it by searching the - ;; udev-populated /dev/disk/by-id directory but udev may - ;; be unavailable at the time we run this. - (if (bytevector? source) - (or (let loop ((tries-left 10)) - (and (positive? tries-left) - (or (find-partition-by-luks-uuid source) - ;; If the underlying partition is - ;; not found, try again after - ;; waiting a second, up to ten - ;; times. FIXME: This should be - ;; dealt with in a more robust way. - (begin (sleep 1) - (loop (- tries-left 1)))))) - (error "LUKS partition not found" source)) - source) - - #$target))))) - -(define (close-luks-device source target) + (match targets + ((target) + #~(let ((source #$(if (uuid? source) + (uuid-bytevector source) + source))) + ;; XXX: 'use-modules' should be at the top level. + (use-modules (rnrs bytevectors) ;bytevector? + ((gnu build file-systems) + #:select (find-partition-by-luks-uuid))) + + ;; Use 'cryptsetup-static', not 'cryptsetup', to avoid pulling the + ;; whole world inside the initrd (for when we're in an initrd). + (zero? (system* #$(file-append cryptsetup-static "/sbin/cryptsetup") + "open" "--type" "luks" + + ;; Note: We cannot use the "UUID=source" syntax here + ;; because 'cryptsetup' implements it by searching the + ;; udev-populated /dev/disk/by-id directory but udev may + ;; be unavailable at the time we run this. + (if (bytevector? source) + (or (let loop ((tries-left 10)) + (and (positive? tries-left) + (or (find-partition-by-luks-uuid source) + ;; If the underlying partition is + ;; not found, try again after + ;; waiting a second, up to ten + ;; times. FIXME: This should be + ;; dealt with in a more robust way. + (begin (sleep 1) + (loop (- tries-left 1)))))) + (error "LUKS partition not found" source)) + source) + + #$target))))))) + +(define (close-luks-device source targets) "Return a gexp that closes TARGET, a LUKS device." - #~(zero? (system* #$(file-append cryptsetup-static "/sbin/cryptsetup") - "close" #$target))) + (match targets + ((target) + #~(zero? (system* #$(file-append cryptsetup-static "/sbin/cryptsetup") + "close" #$target))))) (define* (check-luks-device md #:key needed-for-boot? @@ -235,36 +263,40 @@ option of @command{guix system}.\n") (close close-luks-device) (check check-luks-device))) -(define (open-raid-device sources target) +(define (open-raid-device sources targets) "Return a gexp that assembles SOURCES (a list of devices) to the RAID device TARGET (e.g., \"/dev/md0\"), using 'mdadm'." - #~(let ((sources '#$sources) - - ;; XXX: We're not at the top level here. We could use a - ;; non-top-level 'use-modules' form but that doesn't work when the - ;; code is eval'd, like the Shepherd does. - (every (@ (srfi srfi-1) every)) - (format (@ (ice-9 format) format))) - (let loop ((attempts 0)) - (unless (every file-exists? sources) - (when (> attempts 20) - (error "RAID devices did not show up; bailing out" - sources)) - - (format #t "waiting for RAID source devices~{ ~a~}...~%" - sources) - (sleep 1) - (loop (+ 1 attempts)))) - - ;; Use 'mdadm-static' rather than 'mdadm' to avoid pulling its whole - ;; closure (80 MiB) in the initrd when a RAID device is needed for boot. - (zero? (apply system* #$(file-append mdadm-static "/sbin/mdadm") - "--assemble" #$target sources)))) - -(define (close-raid-device sources target) + (match targets + ((target) + #~(let ((sources '#$sources) + + ;; XXX: We're not at the top level here. We could use a + ;; non-top-level 'use-modules' form but that doesn't work when the + ;; code is eval'd, like the Shepherd does. + (every (@ (srfi srfi-1) every)) + (format (@ (ice-9 format) format))) + (let loop ((attempts 0)) + (unless (every file-exists? sources) + (when (> attempts 20) + (error "RAID devices did not show up; bailing out" + sources)) + + (format #t "waiting for RAID source devices~{ ~a~}...~%" + sources) + (sleep 1) + (loop (+ 1 attempts)))) + + ;; Use 'mdadm-static' rather than 'mdadm' to avoid pulling its whole + ;; closure (80 MiB) in the initrd when a RAID device is needed for boot. + (zero? (apply system* #$(file-append mdadm-static "/sbin/mdadm") + "--assemble" #$target sources)))))) + +(define (close-raid-device sources targets) "Return a gexp that stops the RAID device TARGET." - #~(zero? (system* #$(file-append mdadm-static "/sbin/mdadm") - "--stop" #$target))) + (match targets + ((target) + #~(zero? (system* #$(file-append mdadm-static "/sbin/mdadm") + "--stop" #$target))))) (define raid-device-mapping ;; The type of RAID mapped devices. -- 2.20.1 From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 25 18:09:42 2020 Received: (at 41143-done) by debbugs.gnu.org; 25 Nov 2020 23:09:42 +0000 Received: from localhost ([127.0.0.1]:37433 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ki3uw-0005zW-Ds for submit@debbugs.gnu.org; Wed, 25 Nov 2020 18:09:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38316) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ki3uv-0005zL-JZ for 41143-done@debbugs.gnu.org; Wed, 25 Nov 2020 18:09:41 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55673) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ki3uq-0001QO-Ec; Wed, 25 Nov 2020 18:09:36 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41412 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ki3uo-0003Ev-Je; Wed, 25 Nov 2020 18:09:35 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Mikhail Tsykalov Subject: Re: [PATCH v3 1/2] mapped-devices: Allow target to be list of strings. References: <87o8kc5e2w.fsf@gnu.org> <20201106094738.132011-1-tsymsh@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 6 Frimaire an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Thu, 26 Nov 2020 00:09:32 +0100 In-Reply-To: <20201106094738.132011-1-tsymsh@gmail.com> (Mikhail Tsykalov's message of "Fri, 6 Nov 2020 12:47:37 +0300") Message-ID: <87o8jlc9ub.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41143-done Cc: 41143-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Mikhail, Mikhail Tsykalov skribis: > * gnu/system/mapped-devices.scm (): Rename constructor to > %mapped-device. > [target]: Remove field. > [targets]: New field. Adjust users. > (mapped-device-compatibility-helper, mapped-device): New macros. > (mapped-device-target): New deprecated procedure. [...] > * gnu/system/mapped-devices.scm (lvm-device-mapping, open-lvm-device, > close-lvm-device): New variables. > > * gnu/tests/install.scm (%lvm-separate-home-os, > %lvm-separate-home-os-source, %lvm-separate-home-installation-script, > %test-lvm-separate-home-os): New variables. > > * gnu/system/linux-initrd.scm (raw-initrd): Add (srfi srfi-1) to initrd e= xpression. Pushed as a9a2fdaabcc78e7a54d9a6bcfa4ee3de308e9a90! Sorry for the delay, the release process took longer than one could hope for. :-) I added a news entry so users will learn about it upon =E2=80=98guix pull= =E2=80=99. Thank you! Ludo=E2=80=99. From unknown Sat Jun 21 12:26:08 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 24 Dec 2020 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator