GNU bug report logs - #64259
[PATCH 0/2] Allow booting of degraded software RAID/MD arrays

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

Package: guix-patches; Reported by: Felix Lechner <felix.lechner@HIDDEN>; Keywords: patch; dated Sat, 24 Jun 2023 02:07:02 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

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


Received: (at 64259) by debbugs.gnu.org; 18 Jan 2024 16:51:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 18 11:51:22 2024
Received: from localhost ([127.0.0.1]:56582 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rQVbt-0001jQ-PT
	for submit <at> debbugs.gnu.org; Thu, 18 Jan 2024 11:51:21 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:54600)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <andreas@HIDDEN>) id 1rQVbt-0001j9-3v
 for 64259 <at> debbugs.gnu.org; Thu, 18 Jan 2024 11:51:21 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 912BBD24;
 Thu, 18 Jan 2024 17:51:13 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at hera.aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id rLLpwyTULL2s; Thu, 18 Jan 2024 17:51:13 +0100 (CET)
Received: from jurong (unknown [147.210.16.130])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 2030DA47;
 Thu, 18 Jan 2024 17:51:13 +0100 (CET)
Date: Thu, 18 Jan 2024 17:51:08 +0100
From: Andreas Enge <andreas@HIDDEN>
To: Felix Lechner <felix.lechner@HIDDEN>
Subject: Re: [bug#64259] [PATCH 2/2] Provide md-array-device-mapping to start
 MD arrays via UUID or name.
Message-ID: <ZalW_EEVK4G5xEuu@jurong>
References: <cover.1687571974.git.felix.lechner@HIDDEN>
 <4e7eab10caeacfb1f8a0736cdab7154c517b9e36.1687571974.git.felix.lechner@HIDDEN>
 <87bkctt0vh.fsf@HIDDEN> <87fs22pn6a.fsf@HIDDEN>
 <Zak4KDD1lrMPqt5r@jurong> <87zfx2zj1b.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <87zfx2zj1b.fsf@HIDDEN>
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 64259
Cc: 64259 <at> debbugs.gnu.org, Ludovic =?iso-8859-15?Q?Court=E8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Am Thu, Jan 18, 2024 at 08:46:24AM -0800 schrieb Felix Lechner:
> Either way, accepting this patch as is now will not break anything. We
> introduce a new mapping (md-device-mapping) that can be used to
> reconfigure Bayfront at the maintainer's leisure.
> It would be easy to react to a bug report later while Bayfront continues
> to use raid-device-mapping..

Okay, that is fine with me!

Andreas





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

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


Received: (at 64259) by debbugs.gnu.org; 18 Jan 2024 16:46:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 18 11:46:30 2024
Received: from localhost ([127.0.0.1]:56567 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rQVXC-00010o-CE
	for submit <at> debbugs.gnu.org; Thu, 18 Jan 2024 11:46:30 -0500
Received: from sail-ipv4.us-core.com ([208.82.101.137]:57200)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <felix.lechner@HIDDEN>) id 1rQVX9-0000xJ-HX
 for 64259 <at> debbugs.gnu.org; Thu, 18 Jan 2024 11:46:28 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=2017; bh=65Ok4SuyViauc9f
 fkdw3z97grlWR8VORE72KgDcdDIs=;
 h=date:references:in-reply-to:subject:
 cc:to:from; d=lease-up.com; b=gRjU29jRZy4J/PdUXXx/vuSZ3uwuibiwDi4SZBhs
 m6BVkx7z9e6xqtU+W9+fpSqW2oco8BcCgFSdknuY+HBJQ9M812CEDZUejhMFzeNysMCG7q
 a5iVs37mmo/fPo047rcwebneI/bALb71f6hrluIMNfqUUlb2u587RcZSUMzxg=
Received: by sail-ipv4.us-core.com (OpenSMTPD) with ESMTPSA id 3624cf96
 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); 
 Thu, 18 Jan 2024 16:46:24 +0000 (UTC)
From: Felix Lechner <felix.lechner@HIDDEN>
To: Andreas Enge <andreas@HIDDEN>
Subject: Re: [bug#64259] [PATCH 2/2] Provide md-array-device-mapping to
 start MD arrays via UUID or name.
In-Reply-To: <Zak4KDD1lrMPqt5r@jurong>
References: <cover.1687571974.git.felix.lechner@HIDDEN>
 <4e7eab10caeacfb1f8a0736cdab7154c517b9e36.1687571974.git.felix.lechner@HIDDEN>
 <87bkctt0vh.fsf@HIDDEN> <87fs22pn6a.fsf@HIDDEN>
 <Zak4KDD1lrMPqt5r@jurong>
Date: Thu, 18 Jan 2024 08:46:24 -0800
Message-ID: <87zfx2zj1b.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 64259
Cc: 64259 <at> debbugs.gnu.org, Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Andreas,

On Thu, Jan 18 2024, Andreas Enge wrote:

> when I wrote the code for bayfront, we needed to wait a bit until the
> hard disks appeared.

How long ago? I never needed it on six pieces of equipment of varying
dimensions, including an SAS server (with reflashed Dell equipment, if
that's what Bayfront is using) and a VM with NVMe SSDs.

Either way, accepting this patch as is now will not break anything. We
introduce a new mapping (md-device-mapping) that can be used to
reconfigure Bayfront at the maintainer's leisure.

It would be easy to react to a bug report later while Bayfront continues
to use raid-device-mapping..

Kind regards
Felix




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

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


Received: (at 64259) by debbugs.gnu.org; 18 Jan 2024 14:39:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 18 09:39:53 2024
Received: from localhost ([127.0.0.1]:54615 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rQTYd-0007DC-Ig
	for submit <at> debbugs.gnu.org; Thu, 18 Jan 2024 09:39:53 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:43254)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <andreas@HIDDEN>) id 1rQTYZ-0007Cs-Bo
 for 64259 <at> debbugs.gnu.org; Thu, 18 Jan 2024 09:39:49 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id BD0F3E2A;
 Thu, 18 Jan 2024 15:39:39 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at hera.aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id R6PSCnMBOpVZ; Thu, 18 Jan 2024 15:39:39 +0100 (CET)
Received: from jurong (unknown [147.210.16.130])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 248B9D24;
 Thu, 18 Jan 2024 15:39:39 +0100 (CET)
Date: Thu, 18 Jan 2024 15:39:36 +0100
From: Andreas Enge <andreas@HIDDEN>
To: Felix Lechner <felix.lechner@HIDDEN>
Subject: Re: [bug#64259] [PATCH 2/2] Provide md-array-device-mapping to start
 MD arrays via UUID or name.
Message-ID: <Zak4KDD1lrMPqt5r@jurong>
References: <cover.1687571974.git.felix.lechner@HIDDEN>
 <4e7eab10caeacfb1f8a0736cdab7154c517b9e36.1687571974.git.felix.lechner@HIDDEN>
 <87bkctt0vh.fsf@HIDDEN> <87fs22pn6a.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <87fs22pn6a.fsf@HIDDEN>
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 64259
Cc: 64259 <at> debbugs.gnu.org, Ludovic =?iso-8859-15?Q?Court=E8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello,

Am Sun, Oct 22, 2023 at 10:44:13AM -0700 schrieb Felix Lechner:
> > Does the busy wait loop currently in ‘open-raid-device’ need to be
> > preserved?
> I personally do not believe so but I'll defer to Andreas Enge, whom I
> copied on this message. I believe Andreas wrote the original device
> mapping.

well, I do not know whether it is still needed. It appears that when
I wrote the code for bayfront, we needed to wait a bit until the hard
disks appeared. Are there reasons to believe that this has changed
in the meantime?

Andreas





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

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


Received: (at 64259) by debbugs.gnu.org; 23 Nov 2023 14:59:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 23 09:59:14 2023
Received: from localhost ([127.0.0.1]:34586 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6BAf-0007gv-Il
	for submit <at> debbugs.gnu.org; Thu, 23 Nov 2023 09:59:14 -0500
Received: from sail-ipv4.us-core.com ([208.82.101.137]:34494)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <felix.lechner@HIDDEN>) id 1r6BAd-0007gY-RE
 for 64259 <at> debbugs.gnu.org; Thu, 23 Nov 2023 09:59:12 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=2017; bh=xhxXrXJXWOOqNfw
 dKiRHiICfjw8Abf+iKozsMFeWXCM=;
 h=references:in-reply-to:date:subject:
 cc:to:from; d=lease-up.com; b=Cp9FF8rF/BQ35H6swBrQgKQfjmTmng9rAHcGVC2Z
 km7Nu90MKXz/eXiXsoK6QAsUfPJ6IMuYgq5h/fdrIX/NymdXjOilCB9P7b2z49KDP6z/aX
 zpQXCyf2G+ZTHYZ/7ByJyQ6cn/hKvdQe1tZO4gmQ7lJ0+h+eSkdOgFWHFfUlM=
Received: by sail-ipv4.us-core.com (OpenSMTPD) with ESMTPSA id e4d87c6b
 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); 
 Thu, 23 Nov 2023 14:59:06 +0000 (UTC)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id 216e76ac;
 Thu, 23 Nov 2023 14:59:06 +0000 (UTC)
From: Felix Lechner <felix.lechner@HIDDEN>
To: 64259 <at> debbugs.gnu.org
Subject: [PATCH v2 2/2] Provide md-array-device-mapping to start MD arrays via
 UUID or name.
Date: Thu, 23 Nov 2023 06:57:00 -0800
Message-ID: <c745ee04c873d62bf275923e748abee5637dca81.1700751420.git.felix.lechner@HIDDEN>
X-Mailer: git-send-email 2.41.0
In-Reply-To: <9b4c88707c00531fa2a43e5172d1fc0c4f4af3d9.1700751420.git.felix.lechner@HIDDEN>
References: <9b4c88707c00531fa2a43e5172d1fc0c4f4af3d9.1700751420.git.felix.lechner@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: 64259
Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>,
 Felix Lechner <felix.lechner@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.8 (/)

This commit cures the most precipitous danger for users of MD arrays in GNU
Guix, namely that their equipment may not boot after a drive failure. That
behavior likely contradicts their primary expectation for having such a disk
arrangments.

In order to facilitate a smooth transition from raid-device-mapping to
md-array-device-mapping, this commit introduces a new mapping rather than
repurpose the old one. The new mapping here is also incompatible with
raid-device-mapping in the sense that a plain string is now interpreted as the
array name from the MD superblock.

For details, please consult the mdadm manual page.

Personally, the author prefers UUIDs over array names when identifying array
components, but either will work. The system test uses the name.

The name for the new device mapping was chosen instead of the traditional RAID
to account for the fact that some modern technologies (like SSDs) and some
array configurations, such as striping, are neither redundant nor inexpensive.

Adjusts the documentation by erasing any mention of the obsolete
raid-device-mapping. No one should use that any longer. Ideally, users would
be a deprecation warning, but I was unable to adapt 'define-deprecated' to
this use case. Please feel free to make further changes.

This commit includes an updated system test for the root file system on
an-md-array.

More details for the motivation of these changes may be available here:

  https://lists.gnu.org/archive/html/guix-devel/2023-04/msg00010.html

The author of this commit used to maintain mdadm in Debian.

Please feel free to insert better changelog messages. I had some difficulty
meeting the likely expectations of any reviewer. Please also feel free to make
any other adjustments as needed without checking with me. Thanks!

* gnu/system/mapped-devices.scm: New variable md-array-device-mapping.
* doc/guix.texi: Mention md-array-device-mapping in the documentation..
* gnu/tests/install.scm: Adjust test for root-on-md-array.
---
Hi Ludo'

With this updated patch series, I hope to address all your questions
and concerns. Thanks!

Kind regards
Felix

doc/guix.texi                 | 28 ++++++------
 gnu/system/mapped-devices.scm | 36 +++++++++++++++
 gnu/tests/install.scm         | 84 +++++++++++++++++++++++++++++++++++
 3 files changed, 135 insertions(+), 13 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 94903fb5e2..7676a58d99 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17762,18 +17762,19 @@ the system boots up.
 
 @table @code
 @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.  In case of LVM this is a
-string specifying name of the volume group to be mapped.
+This is either a string specifying the name of the block device to be
+mapped, such as @code{"/dev/sda3"}.  For MD array devices it is either
+the UUID of the array or a string that is interpreted as the array name
+(see mdadm.conf(5) in the manual).  In case of LVM it 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},
 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.
+For MD array devices of type @code{md-array-device-mapping}, the full device
+name such as @code{"/dev/md18"} needs to be given.
 LVM logical volumes of type @code{lvm-device-mapping} need to
 be specified as @code{"VGNAME-LVNAME"}.
 
@@ -17793,11 +17794,12 @@ command from the package with the same name.  It relies on the
 @code{dm-crypt} Linux kernel module.
 @end defvar
 
-@defvar raid-device-mapping
+@defvar md-array-device-mapping
 This defines a RAID device, which is assembled using the @code{mdadm}
-command from the package with the same name.  It requires a Linux kernel
-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.
+command from the package with the same name.  It requires the Linux kernel
+module for the appropriate RAID level to be loaded, such as @code{raid1}
+for mirroring, @code{raid456} for the checksum-based RAID levels 4, 5 or 6,
+or @code{raid10} for RAID-10.
 @end defvar
 
 @cindex LVM, logical volume manager
@@ -17855,9 +17857,9 @@ may be declared as follows:
 
 @lisp
 (mapped-device
-  (source (list "/dev/sda1" "/dev/sdb1"))
-  (target "/dev/md0")
-  (type raid-device-mapping))
+  (source (uuid "33cf3e31:8e33d75b:517d64b9:0a8f7623" 'mdadm))
+  (target "/dev/md17")
+  (type md-array-device-mapping))
 @end lisp
 
 The @file{/dev/md0} device can then be used as the @code{device} of a
diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index e6b8970c12..e6635b531d 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -64,6 +64,7 @@ (define-module (gnu system mapped-devices)
             check-device-initrd-modules           ;XXX: needs a better place
 
             luks-device-mapping
+            md-array-device-mapping
             raid-device-mapping
             lvm-device-mapping))
 
@@ -276,6 +277,39 @@ (define luks-device-mapping
    (close close-luks-device)
    (check check-luks-device)))
 
+(define (open-md-array-device source targets)
+  "Return a gexp that assembles SOURCE to the MD device
+TARGET (e.g., \"/dev/md0\"), using 'mdadm'."
+  (let ((array-selector
+         (match source
+           ((? uuid?)
+            (string-append "--uuid=" (uuid->string source)))
+           ((? string?)
+            (string-append "--name=" source))))
+        (md-device
+         (match targets
+           ((target)
+            target))))
+    ;; Use 'mdadm-static' rather than 'mdadm' to avoid pulling its whole
+    ;; closure (80 MiB) in the initrd when an MD device is needed for boot.
+    #~(zero? (system* #$(file-append mdadm-static "/sbin/mdadm")
+                      "--assemble" #$md-device
+                      "--run"
+                      #$array-selector))))
+
+(define (close-md-array-device source targets)
+  "Return a gexp that stops the MD device TARGET."
+  (match targets
+    ((target)
+     #~(zero? (system* #$(file-append mdadm-static "/sbin/mdadm")
+                       "--stop" #$target)))))
+
+(define md-array-device-mapping
+  ;; The type of MD mapped device.
+  (mapped-device-kind
+   (open open-md-array-device)
+   (close close-md-array-device)))
+
 (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'."
@@ -317,6 +351,8 @@ (define raid-device-mapping
    (open open-raid-device)
    (close close-raid-device)))
 
+(define-deprecated raid-device-mapping md-array-device-mapping)
+
 (define (open-lvm-device source targets)
   #~(and
      (zero? (system* #$(file-append lvm2-static "/sbin/lvm")
diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm
index daa4647299..9e80b55f84 100644
--- a/gnu/tests/install.scm
+++ b/gnu/tests/install.scm
@@ -64,6 +64,7 @@ (define-module (gnu tests install)
             %test-iso-image-installer
             %test-separate-store-os
             %test-separate-home-os
+            %test-md-array-root-os
             %test-raid-root-os
             %test-encrypted-root-os
             %test-encrypted-home-os
@@ -610,6 +611,89 @@ (define %test-separate-store-os
                          (command (qemu-command* images)))
       (run-basic-test %separate-store-os command "separate-store-os")))))
 
+
+;;;
+;;; MD root device.
+;;;
+
+(define-os-with-source (%md-array-root-os %md-array-root-os-source)
+  ;; An OS whose root partition is a MD partition.
+  (use-modules (gnu) (gnu tests))
+
+  (operating-system
+    (host-name "raidified")
+    (timezone "Europe/Paris")
+    (locale "en_US.utf8")
+
+    (bootloader (bootloader-configuration
+                 (bootloader grub-bootloader)
+                 (targets (list "/dev/vdb"))))
+    (kernel-arguments '("console=ttyS0"))
+
+    ;; Add a kernel module for RAID-1 (aka. "mirror").
+    (initrd-modules (cons "raid1" %base-initrd-modules))
+
+    (mapped-devices (list (mapped-device
+                           (source "marionette:mirror0")
+                           (target "/dev/md0")
+                           (type md-array-device-mapping))))
+    (file-systems (cons (file-system
+                          (device (file-system-label "root-fs"))
+                          (mount-point "/")
+                          (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 %md-array-root-installation-script
+  ;; Installation with a separate /gnu partition.  See
+  ;; <https://raid.wiki.kernel.org/index.php/RAID_setup> for more on RAID and
+  ;; mdadm.
+  "\
+. /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 ext2 1.6G 3.2G \\
+  set 1 boot on \\
+  set 1 bios_grub on
+yes | mdadm --create /dev/md0 --verbose --homehost=marionette --name=mirror0 \\
+  --level=mirror --raid-devices=2 /dev/vdb2 /dev/vdb3
+mkfs.ext4 -L root-fs /dev/md0
+mount /dev/md0 /mnt
+df -h /mnt
+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-md-array-root-os
+  (system-test
+   (name "md-array-root-os")
+   (description
+    "Test functionality of an OS installed with a RAID root partition managed
+by 'mdadm'.")
+   (value
+    (mlet* %store-monad ((images (run-install %md-array-root-os
+                                              %md-array-root-os-source
+                                              #:script
+                                              %md-array-root-installation-script
+                                              #:target-size (* 3200 MiB)))
+                         (command (qemu-command* images)))
+      (run-basic-test %md-array-root-os
+                      `(,@command) "md-array-root-os")))))
+
 
 ;;;
 ;;; RAID root device.
-- 
2.41.0





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

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


Received: (at 64259) by debbugs.gnu.org; 23 Nov 2023 14:59:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 23 09:59:11 2023
Received: from localhost ([127.0.0.1]:34583 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6BAd-0007gh-1T
	for submit <at> debbugs.gnu.org; Thu, 23 Nov 2023 09:59:11 -0500
Received: from sail-ipv4.us-core.com ([208.82.101.137]:34494)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <felix.lechner@HIDDEN>) id 1r6BAa-0007gY-4G
 for 64259 <at> debbugs.gnu.org; Thu, 23 Nov 2023 09:59:09 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=2017; bh=eAdH9YAxLlQDx43
 nOb2mHRSAJ6iwa27eVqrldvINybo=; h=date:subject:cc:to:from;
 d=lease-up.com; b=lbrpZWlWWTk3Sp3GrLyOYpBuStDXrEEKmp/HAEL8B7ebT7pZmPY8
 JScvGnhPZn/dr6DIV7wrgyr3Xm/s8L1lYYPXttATv9rIasm3i7kn22X0LA1uT6sVEnLPrL
 jgDt+a4x1tJsoxQXTezsbng4WJJxTbt6XQ8wsm0jfDkM7gnPw=
Received: by sail-ipv4.us-core.com (OpenSMTPD) with ESMTPSA id a8ea84f7
 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); 
 Thu, 23 Nov 2023 14:59:02 +0000 (UTC)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id 16c8b611;
 Thu, 23 Nov 2023 14:59:02 +0000 (UTC)
From: Felix Lechner <felix.lechner@HIDDEN>
To: 64259 <at> debbugs.gnu.org
Subject: [PATCH v2 1/2] Offer an mdadm variant of uuids.
Date: Thu, 23 Nov 2023 06:56:59 -0800
Message-ID: <9b4c88707c00531fa2a43e5172d1fc0c4f4af3d9.1700751420.git.felix.lechner@HIDDEN>
X-Mailer: git-send-email 2.41.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: 64259
Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>,
 Felix Lechner <felix.lechner@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.8 (/)

---
 gnu/system/uuid.scm | 46 +++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/gnu/system/uuid.scm b/gnu/system/uuid.scm
index 8f967387ad..dc8bb3f7b7 100644
--- a/gnu/system/uuid.scm
+++ b/gnu/system/uuid.scm
@@ -82,8 +82,9 @@ (define-syntax %network-byte-order
   (identifier-syntax (endianness big)))
 
 (define (dce-uuid->string uuid)
-  "Convert UUID, a 16-byte bytevector, to its string representation, something
-like \"6b700d61-5550-48a1-874c-a3d86998990e\"."
+  "Convert UUID, a 16-byte bytevector, to its DCE string representation (see
+<https://tools.ietf.org/html/rfc4122>), which looks something like
+\"6b700d61-5550-48a1-874c-a3d86998990e\"."
   ;; See <https://tools.ietf.org/html/rfc4122>.
   (let ((time-low  (bytevector-uint-ref uuid 0 %network-byte-order 4))
         (time-mid  (bytevector-uint-ref uuid 4 %network-byte-order 2))
@@ -93,7 +94,7 @@ (define (dce-uuid->string uuid)
     (format #f "~8,'0x-~4,'0x-~4,'0x-~4,'0x-~12,'0x"
             time-low time-mid time-hi clock-seq node)))
 
-(define %uuid-rx
+(define %dce-uuid-rx
   ;; The regexp of a UUID.
   (make-regexp "^([[:xdigit:]]{8})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{12})$"))
 
@@ -101,7 +102,7 @@ (define (string->dce-uuid str)
   "Parse STR as a DCE UUID (see <https://tools.ietf.org/html/rfc4122>) and
 return its contents as a 16-byte bytevector.  Return #f if STR is not a valid
 UUID representation."
-  (and=> (regexp-exec %uuid-rx str)
+  (and=> (regexp-exec %dce-uuid-rx str)
          (lambda (match)
            (letrec-syntax ((hex->number
                             (syntax-rules ()
@@ -167,6 +168,41 @@ (define (digits->string bytes)
          (parts (list year month day hour minute second hundredths)))
     (string-append (string-join (map digits->string parts) "-"))))
 
+
+;;;
+;;; Mdadm.
+;;;
+
+(define (mdadm-uuid->string uuid)
+  "Convert UUID, a 16-byte bytevector, to its Mdadm string representation,
+which looks something like \"6b700d61:555048a1:874ca3d8:6998990e\"."
+  ;; See <https://tools.ietf.org/html/rfc4122>.
+  (format #f "~8,'0x:~8,'0x:~8,'0x:~8,'0x"
+          (bytevector-uint-ref uuid 0 %network-byte-order 4)
+          (bytevector-uint-ref uuid 4 %network-byte-order 4)
+          (bytevector-uint-ref uuid 8 %network-byte-order 4)
+          (bytevector-uint-ref uuid 12 %network-byte-order 4)))
+
+(define %mdadm-uuid-rx
+  (make-regexp "^([[:xdigit:]]{8}):([[:xdigit:]]{8}):([[:xdigit:]]{8}):([[:xdigit:]]{8})$"))
+
+(define (string->mdadm-uuid str)
+  "Parse STR, which is in Mdadm format, and return a bytevector or #f."
+  (match (regexp-exec %mdadm-uuid-rx str)
+    (#f
+     #f)
+    (rx-match
+     (uint-list->bytevector (list (string->number
+                                   (match:substring rx-match 1) 16)
+                                  (string->number
+                                   (match:substring rx-match 2) 16)
+                                  (string->number
+                                   (match:substring rx-match 3) 16)
+                                  (string->number
+                                   (match:substring rx-match 4) 16))
+                            %network-byte-order
+                            4))))
+
 
 ;;;
 ;;; FAT32/FAT16.
@@ -259,6 +295,7 @@ (define %uuid-parsers
    ('dce 'ext2 'ext3 'ext4 'bcachefs 'btrfs 'f2fs 'jfs 'xfs 'luks
          => string->dce-uuid)
    ('fat32 'fat16 'fat => string->fat-uuid)
+   ('mdadm => string->mdadm-uuid)
    ('ntfs => string->ntfs-uuid)
    ('iso9660 => string->iso9660-uuid)))
 
@@ -268,6 +305,7 @@ (define %uuid-printers
          => dce-uuid->string)
    ('iso9660 => iso9660-uuid->string)
    ('fat32 'fat16 'fat => fat-uuid->string)
+   ('mdadm => mdadm-uuid->string)
    ('ntfs => ntfs-uuid->string)))
 
 (define* (string->uuid str #:optional (type 'dce))

base-commit: 5283d24062be62f59ff9f14fa7095ebcfcb7a9a4
-- 
2.41.0





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

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


Received: (at 64259) by debbugs.gnu.org; 22 Oct 2023 17:44:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 22 13:44:49 2023
Received: from localhost ([127.0.0.1]:48030 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qucVN-0003GP-7A
	for submit <at> debbugs.gnu.org; Sun, 22 Oct 2023 13:44:49 -0400
Received: from sail-ipv4.us-core.com ([208.82.101.137]:54626)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <felix.lechner@HIDDEN>) id 1qucVH-0003Fw-FO
 for 64259 <at> debbugs.gnu.org; Sun, 22 Oct 2023 13:44:44 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=2017; bh=E5RnrQY+bLYN2vb
 bXhsht0uLlpV9Zp60Dw1YV7+AG2Y=;
 h=date:references:in-reply-to:subject:
 cc:to:from; d=lease-up.com; b=cd3LIDRE4njXvcMUFk8i5dhQTMqTJV88Byi7fWZa
 tkt5/+6Dc9q6GMmhCUL2yDuGMo9RH6z9EeyuAgVgKJKtmH37JH079mW/XKB2BlutcobVEr
 sc07RT2cQp3t29XUjhAEtJlzOArNqLPFMsdNZ6kIQNN4gzCD1bujaS7MdhY0k=
Received: by sail-ipv4.us-core.com (OpenSMTPD) with ESMTPSA id 3c5c0cd5
 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); 
 Sun, 22 Oct 2023 17:44:13 +0000 (UTC)
From: Felix Lechner <felix.lechner@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: [bug#64259] [PATCH 2/2] Provide md-array-device-mapping to
 start MD arrays via UUID or name.
In-Reply-To: <87bkctt0vh.fsf@HIDDEN>
References: <cover.1687571974.git.felix.lechner@HIDDEN>
 <4e7eab10caeacfb1f8a0736cdab7154c517b9e36.1687571974.git.felix.lechner@HIDDEN>
 <87bkctt0vh.fsf@HIDDEN>
Date: Sun, 22 Oct 2023 10:44:13 -0700
Message-ID: <87fs22pn6a.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 64259
Cc: 64259 <at> debbugs.gnu.org, Andreas Enge <andreas@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

Thanks for looking at my patch!

On Fri, Oct 20 2023, Ludovic Court=C3=A8s wrote:

> Could ... the device names specified in
> the =E2=80=98source=E2=80=99 field of the mapped device become invalid?

In RAID failures, the devices for defective components usually stop
functioning as intended or become unavailable altogether. Listing those
devices on the mdadm command line, however, requires them to be present
for the assembly of the array. For the fault-tolerant behavior people
expect, arrays should be started via the array name or the special UUID.

> try and use =E2=80=98define-deprecated=E2=80=99.

Yes, thank you! I will do so and deploy locally before I update the
patch herein.

> Instead of =E2=80=9Csee Mdadm documentation=E2=80=9D, could you add a lin=
k or a command
> to type to access said documentation?

Upon review, I am not sure that the mdadm documentation is actually very
helpful. I must have been thinking about third-party sites.

> Better yet, an example of what an
> mdadm device name or UUID is and how to obtain it would be welcome.

Yes, I will include examples on how to access both, and how to change
the "array name." The latter can be a chosen string that is optionally
prefaced by the local host name. The array name is not the same as the
device name, which looks like /dev/md12. I shall clarify all that in the
revised patch.

>> +    (if (and array-selector md-device)
>            ^
> This condition is always true.

Okay, I may not know Guile macros well enough.

> Instead of renaming and duplicating part of the logic, how about
> supporting those new =E2=80=98source=E2=80=99 specification right in =E2=
=80=98open-raid-device=E2=80=99?
> It would emit a deprecation warning when =E2=80=98source=E2=80=99 is a li=
st of strings.

It's an good idea, but many other file systems offer RAID-type
functionality. Do you think that a raid-device-mapping based on mdadm
occupies a fair share in the common name space?

> Does the busy wait loop currently in =E2=80=98open-raid-device=E2=80=99 n=
eed to be
> preserved?

I personally do not believe so but I'll defer to Andreas Enge, whom I
copied on this message. I believe Andreas wrote the original device
mapping.

Kind regards
Felix




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

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


Received: (at 64259) by debbugs.gnu.org; 20 Oct 2023 21:56:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 20 17:56:13 2023
Received: from localhost ([127.0.0.1]:41783 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qtxTZ-0007iA-23
	for submit <at> debbugs.gnu.org; Fri, 20 Oct 2023 17:56:13 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:51082)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1qtxTU-0007hu-8Q
 for 64259 <at> debbugs.gnu.org; Fri, 20 Oct 2023 17:56:10 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1qtxSw-00085q-HH; Fri, 20 Oct 2023 17:55:35 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=w6T4OhVqmRkExg50uSINUTxXWT66FUGBEMnWGNGh+DQ=; b=PLZqoTZI2HTUa+VKu2M/
 m7X/iEMrrjNuNt4j62C4KT9MKEM6Nm7LT5RWOXsLUk45zTn7AYo3LAwKF/6D9m8PatOGCzE0oZU2Z
 OK9roFzpZFDsGq3u5aHzdu1ODMSZekh9SEzt1AKJOLn09cLb3cjjq4HNJ+33RqIj1SGmMYk0IhY+j
 7P6zwPYebYgCqjz2a5YoBGrzwx7SmRmU34M630mic3c1jOMJoBBLqtaMz0Q3ak8m5YMg2lKtlnQ+L
 hCQCn8c/Es+KDA/c5k8yQ0haV1qLE4R6+g5otgkcaGZiUhEo2dNwCAurjGckOS68FzDtlwFWv0TKI
 NCOgVenYR1cuxQ==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Felix Lechner <felix.lechner@HIDDEN>
Subject: Re: [bug#64259] [PATCH 2/2] Provide md-array-device-mapping to
 start MD arrays via UUID or name.
In-Reply-To: <4e7eab10caeacfb1f8a0736cdab7154c517b9e36.1687571974.git.felix.lechner@HIDDEN>
 (Felix Lechner's message of "Fri, 23 Jun 2023 19:07:23 -0700")
References: <cover.1687571974.git.felix.lechner@HIDDEN>
 <4e7eab10caeacfb1f8a0736cdab7154c517b9e36.1687571974.git.felix.lechner@HIDDEN>
Date: Fri, 20 Oct 2023 23:55:30 +0200
Message-ID: <87bkctt0vh.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
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: 64259
Cc: 64259 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

Felix Lechner <felix.lechner@HIDDEN> skribis:

> This commit cures the most precipitous danger for users of MD arrays in G=
NU
> Guix, namely that their equipment may not boot after a drive failure.

Why would that happen?  Could be because the device names specified in
the =E2=80=98source=E2=80=99 field of the mapped device become invalid?

> Adjusts the documentation by erasing any mention of the obsolete
> raid-device-mapping. No one should use that any longer. Ideally, users wo=
uld
> be a deprecation warning, but I was unable to adapt 'define-deprecated' to
> this use case. Please feel free to make further changes.

If it has to be deprecated then yes, we try and use =E2=80=98define-depreca=
ted=E2=80=99.

> Please feel free to insert better changelog messages. I had some difficul=
ty
> meeting the likely expectations of any reviewer. Please also feel free to=
 make
> any other adjustments as needed without checking with me. Thanks!

The reviewer may feel free, sure=E2=80=A6  :-)

>  @item source
> -This is either a string specifying the name of the block device to be ma=
pped,
> -such as @code{"/dev/sda3"}, or a list of such strings when several devic=
es
> -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.
> +This is either a string specifying the name of the block device to be
> +mapped, such as @code{"/dev/sda3"}.  For MD array devices it is either
> +the UUID of the array or a string that is interpreted as the array name
> +(see Mdadm documentation).  In case of LVM it is a string specifying
> +name of the volume group to be mapped.

Instead of =E2=80=9Csee Mdadm documentation=E2=80=9D, could you add a link =
or a command
to type to access said documentation?  Better yet, an example of what an
mdadm device name or UUID is and how to obtain it would be welcome.

> +(define (open-md-array-device source targets)
> +  "Return a gexp that assembles SOURCE to the MD device
> +TARGET (e.g., \"/dev/md0\"), using 'mdadm'."
> +  (let ((array-selector
> +         (match source
> +           ((? uuid?)
> +            (string-append "--uuid=3D" (uuid->string source)))
> +           ((? string?)
> +            (string-append "--name=3D" source))))
> +        (md-device
> +         (match targets
> +           ((target)
> +            target))))
> +    (if (and array-selector md-device)
           ^
This condition is always true.

> +        ;; Use 'mdadm-static' rather than 'mdadm' to avoid pulling its w=
hole
> +        ;; closure (80 MiB) in the initrd when an MD device is needed fo=
r boot.
> +        #~(zero? (system* #$(file-append mdadm-static "/sbin/mdadm")
> +                          "--assemble" #$md-device
> +                          "--run"
> +                          #$array-selector))
> +        #f)))
> +
> +(define (close-md-array-device source targets)
> +  "Return a gexp that stops the MD device TARGET."
> +  (match targets
> +    ((target)
> +     #~(zero? (system* #$(file-append mdadm-static "/sbin/mdadm")
> +                       "--stop" #$target)))))
> +
> +(define md-array-device-mapping
> +  ;; The type of MD mapped device.
> +  (mapped-device-kind
> +   (open open-md-array-device)
> +   (close close-md-array-device)))

Instead of renaming and duplicating part of the logic, how about
supporting those new =E2=80=98source=E2=80=99 specification right in =E2=80=
=98open-raid-device=E2=80=99?
It would emit a deprecation warning when =E2=80=98source=E2=80=99 is a list=
 of strings.

Does the busy wait loop currently in =E2=80=98open-raid-device=E2=80=99 nee=
d to be
preserved?

Thanks,
Ludo=E2=80=99.




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

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


Received: (at 64259) by debbugs.gnu.org; 24 Jun 2023 02:07:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 23 22:07:32 2023
Received: from localhost ([127.0.0.1]:39729 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qCsgW-0002li-0x
	for submit <at> debbugs.gnu.org; Fri, 23 Jun 2023 22:07:32 -0400
Received: from sail-ipv4.us-core.com ([208.82.101.137]:40014)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <felix.lechner@HIDDEN>) id 1qCsgS-0002lK-Bj
 for 64259 <at> debbugs.gnu.org; Fri, 23 Jun 2023 22:07:29 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=2017; bh=KOtBn5jGD+v4lQ4
 avqQTJ9M2SOqc2YekIJ9XsZtcNu8=;
 h=references:in-reply-to:date:subject:
 cc:to:from; d=lease-up.com; b=a5VtM+pfFaMuez8BzP8MFF7f2OykEdM4YJcHtrzw
 O+GObCENEJEBEEC1hXqqDctQl1gfTZl7KHRIKmu0QCWMsbx3R6cKT/9VL1KfkXMm1ROUbS
 5LXMSuFqVZEmkmGjM3z5w38tPngeasxOonkL0dz3bFPqZROPNROE6WjYgb4fc=
Received: by sail-ipv4.us-core.com (OpenSMTPD) with ESMTPSA id 42987ceb
 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); 
 Sat, 24 Jun 2023 02:07:26 +0000 (UTC)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id 8cc111eb;
 Sat, 24 Jun 2023 02:07:25 +0000 (UTC)
From: Felix Lechner <felix.lechner@HIDDEN>
To: 64259 <at> debbugs.gnu.org
Subject: [PATCH 2/2] Provide md-array-device-mapping to start MD arrays via
 UUID or name.
Date: Fri, 23 Jun 2023 19:07:23 -0700
Message-Id: <4e7eab10caeacfb1f8a0736cdab7154c517b9e36.1687571974.git.felix.lechner@HIDDEN>
X-Mailer: git-send-email 2.40.1
In-Reply-To: <cover.1687571974.git.felix.lechner@HIDDEN>
References: <cover.1687571974.git.felix.lechner@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: 64259
Cc: Felix Lechner <felix.lechner@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.8 (/)

This commit cures the most precipitous danger for users of MD arrays in GNU
Guix, namely that their equipment may not boot after a drive failure. That
behavior likely contradicts their primary expectation for having such a disk
arrangments.

In order to facilitate a smooth transition from raid-device-mapping to
md-array-device-mapping, this commit introduces a new mapping rather than
repurpose the old one. The new mapping here is also incompatible with
raid-device-mapping in the sense that a plain string is now interpreted as the
array name from the MD superblock.

For details, please consult the mdadm manual page.

Personally, the author prefers UUIDs over array names when identifying array
components, but either will work. The system test uses the name.

The name for the new device mapping was chosen instead of the traditional RAID
to account for the fact that some modern technologies (like SSDs) and some
array configurations, such as striping, are neither redundant nor inexpensive.

Adjusts the documentation by erasing any mention of the obsolete
raid-device-mapping. No one should use that any longer. Ideally, users would
be a deprecation warning, but I was unable to adapt 'define-deprecated' to
this use case. Please feel free to make further changes.

This commit includes an updated system test for the root file system on
an-md-array.

More details for the motivation of these changes may be available here:

  https://lists.gnu.org/archive/html/guix-devel/2023-04/msg00010.html

The author of this commit used to maintain mdadm in Debian.

Please feel free to insert better changelog messages. I had some difficulty
meeting the likely expectations of any reviewer. Please also feel free to make
any other adjustments as needed without checking with me. Thanks!

* gnu/system/mapped-devices.scm: New variable md-array-device-mapping.
* doc/guix.texi: Mention md-array-device-mapping in the documentation..
* gnu/tests/install.scm: Adjust test for root-on-md-array.
---
 doc/guix.texi                 | 28 ++++++++++++++------------
 gnu/system/mapped-devices.scm | 38 ++++++++++++++++++++++++++++++++++-
 gnu/tests/install.scm         | 32 ++++++++++++++---------------
 3 files changed, 68 insertions(+), 30 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index c961f706ec..91125479b1 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17513,18 +17513,19 @@ the system boots up.
 
 @table @code
 @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.  In case of LVM this is a
-string specifying name of the volume group to be mapped.
+This is either a string specifying the name of the block device to be
+mapped, such as @code{"/dev/sda3"}.  For MD array devices it is either
+the UUID of the array or a string that is interpreted as the array name
+(see Mdadm documentation).  In case of LVM it 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},
 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.
+For MD array devices of type @code{md-array-device-mapping}, the full device
+name such as @code{"/dev/md18"} needs to be given.
 LVM logical volumes of type @code{lvm-device-mapping} need to
 be specified as @code{"VGNAME-LVNAME"}.
 
@@ -17544,11 +17545,12 @@ command from the package with the same name.  It relies on the
 @code{dm-crypt} Linux kernel module.
 @end defvar
 
-@defvar raid-device-mapping
+@defvar md-array-device-mapping
 This defines a RAID device, which is assembled using the @code{mdadm}
-command from the package with the same name.  It requires a Linux kernel
-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.
+command from the package with the same name.  It requires the Linux kernel
+module for the appropriate RAID level to be loaded, such as @code{raid1}
+for mirroring, @code{raid456} for the checksum-based RAID levels 4, 5 or 6,
+or @code{raid10} for RAID-10.
 @end defvar
 
 @cindex LVM, logical volume manager
@@ -17606,9 +17608,9 @@ may be declared as follows:
 
 @lisp
 (mapped-device
-  (source (list "/dev/sda1" "/dev/sdb1"))
-  (target "/dev/md0")
-  (type raid-device-mapping))
+  (source (uuid "33cf3e31:8e33d75b:517d64b9:0a8f7623" 'mdadm))
+  (target "/dev/md17")
+  (type md-array-device-mapping))
 @end lisp
 
 The @file{/dev/md0} device can then be used as the @code{device} of a
diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index e6b8970c12..ffe5bc00f4 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -64,6 +64,7 @@ (define-module (gnu system mapped-devices)
             check-device-initrd-modules           ;XXX: needs a better place
 
             luks-device-mapping
+            md-array-device-mapping
             raid-device-mapping
             lvm-device-mapping))
 
@@ -317,11 +318,46 @@ (define raid-device-mapping
    (open open-raid-device)
    (close close-raid-device)))
 
+(define (open-md-array-device source targets)
+  "Return a gexp that assembles SOURCE to the MD device
+TARGET (e.g., \"/dev/md0\"), using 'mdadm'."
+  (let ((array-selector
+         (match source
+           ((? uuid?)
+            (string-append "--uuid=" (uuid->string source)))
+           ((? string?)
+            (string-append "--name=" source))))
+        (md-device
+         (match targets
+           ((target)
+            target))))
+    (if (and array-selector md-device)
+        ;; Use 'mdadm-static' rather than 'mdadm' to avoid pulling its whole
+        ;; closure (80 MiB) in the initrd when an MD device is needed for boot.
+        #~(zero? (system* #$(file-append mdadm-static "/sbin/mdadm")
+                          "--assemble" #$md-device
+                          "--run"
+                          #$array-selector))
+        #f)))
+
+(define (close-md-array-device source targets)
+  "Return a gexp that stops the MD device TARGET."
+  (match targets
+    ((target)
+     #~(zero? (system* #$(file-append mdadm-static "/sbin/mdadm")
+                       "--stop" #$target)))))
+
+(define md-array-device-mapping
+  ;; The type of MD mapped device.
+  (mapped-device-kind
+   (open open-md-array-device)
+   (close close-md-array-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.
+                                        ; /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))
diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm
index 0f4204d1a6..061365fd87 100644
--- a/gnu/tests/install.scm
+++ b/gnu/tests/install.scm
@@ -64,7 +64,7 @@ (define-module (gnu tests install)
             %test-iso-image-installer
             %test-separate-store-os
             %test-separate-home-os
-            %test-raid-root-os
+            %test-md-array-root-os
             %test-encrypted-root-os
             %test-encrypted-home-os
             %test-encrypted-root-not-boot-os
@@ -612,11 +612,11 @@ (define %test-separate-store-os
 
 
 ;;;
-;;; RAID root device.
+;;; MD root device.
 ;;;
 
-(define-os-with-source (%raid-root-os %raid-root-os-source)
-  ;; An OS whose root partition is a RAID partition.
+(define-os-with-source (%md-array-root-os %md-array-root-os-source)
+  ;; An OS whose root partition is a MD partition.
   (use-modules (gnu) (gnu tests))
 
   (operating-system
@@ -633,9 +633,9 @@ (define-os-with-source (%raid-root-os %raid-root-os-source)
     (initrd-modules (cons "raid1" %base-initrd-modules))
 
     (mapped-devices (list (mapped-device
-                           (source (list "/dev/vda2" "/dev/vda3"))
+                           (source "marionette:mirror0")
                            (target "/dev/md0")
-                           (type raid-device-mapping))))
+                           (type md-array-device-mapping))))
     (file-systems (cons (file-system
                           (device (file-system-label "root-fs"))
                           (mount-point "/")
@@ -649,7 +649,7 @@ (define-os-with-source (%raid-root-os %raid-root-os-source)
                                                   (guix combinators)))))
                     %base-services))))
 
-(define %raid-root-installation-script
+(define %md-array-root-installation-script
   ;; Installation with a separate /gnu partition.  See
   ;; <https://raid.wiki.kernel.org/index.php/RAID_setup> for more on RAID and
   ;; mdadm.
@@ -665,8 +665,8 @@ (define %raid-root-installation-script
   mkpart primary ext2 1.6G 3.2G \\
   set 1 boot on \\
   set 1 bios_grub on
-yes | mdadm --create /dev/md0 --verbose --level=mirror --raid-devices=2 \\
-  /dev/vdb2 /dev/vdb3
+yes | mdadm --create /dev/md0 --verbose --homehost=marionette --name=mirror0 \\
+  --level=mirror --raid-devices=2 /dev/vdb2 /dev/vdb3
 mkfs.ext4 -L root-fs /dev/md0
 mount /dev/md0 /mnt
 df -h /mnt
@@ -677,21 +677,21 @@ (define %raid-root-installation-script
 sync
 reboot\n")
 
-(define %test-raid-root-os
+(define %test-md-array-root-os
   (system-test
-   (name "raid-root-os")
+   (name "md-array-root-os")
    (description
     "Test functionality of an OS installed with a RAID root partition managed
 by 'mdadm'.")
    (value
-    (mlet* %store-monad ((images (run-install %raid-root-os
-                                              %raid-root-os-source
+    (mlet* %store-monad ((images (run-install %md-array-root-os
+                                              %md-array-root-os-source
                                               #:script
-                                              %raid-root-installation-script
+                                              %md-array-root-installation-script
                                               #:target-size (* 3200 MiB)))
                          (command (qemu-command* images)))
-      (run-basic-test %raid-root-os
-                      `(,@command) "raid-root-os")))))
+      (run-basic-test %md-array-root-os
+                      `(,@command) "md-array-root-os")))))
 
 
 ;;;
-- 
2.40.1





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

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


Received: (at 64259) by debbugs.gnu.org; 24 Jun 2023 02:07:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 23 22:07:30 2023
Received: from localhost ([127.0.0.1]:39727 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qCsgT-0002lZ-I2
	for submit <at> debbugs.gnu.org; Fri, 23 Jun 2023 22:07:29 -0400
Received: from sail-ipv4.us-core.com ([208.82.101.137]:40014)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <felix.lechner@HIDDEN>) id 1qCsgQ-0002lK-OH
 for 64259 <at> debbugs.gnu.org; Fri, 23 Jun 2023 22:07:27 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=2017; bh=uy5rDqWgjexWPdw
 FzoVajMo/6sMUCCcljDA7Yy0bwf8=;
 h=references:in-reply-to:date:subject:
 cc:to:from; d=lease-up.com; b=rHvNoO8XIRgIuFNe4k7edm4NhN2iuIh/Kpg47dUi
 Osxb+E4L46Rx7K2NnSzpI/CHmaENIQJWXfwGwrnDbBs6/eJTjIImmTtdBgJM4APef0+0Fj
 71bs9sqfhDjz+UkRtRgVSjZIBCPm5tR00UIQER+f9dKteRlnUSHRkAWBy9sP8=
Received: by sail-ipv4.us-core.com (OpenSMTPD) with ESMTPSA id ae1dea98
 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); 
 Sat, 24 Jun 2023 02:07:25 +0000 (UTC)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id 48153a98;
 Sat, 24 Jun 2023 02:07:24 +0000 (UTC)
From: Felix Lechner <felix.lechner@HIDDEN>
To: 64259 <at> debbugs.gnu.org
Subject: [PATCH 1/2] Offer an mdadm variant of uuids.
Date: Fri, 23 Jun 2023 19:07:22 -0700
Message-Id: <a3f6db9b97ad87027ef74007c0782a535a553415.1687571974.git.felix.lechner@HIDDEN>
X-Mailer: git-send-email 2.40.1
In-Reply-To: <cover.1687571974.git.felix.lechner@HIDDEN>
References: <cover.1687571974.git.felix.lechner@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: 64259
Cc: Felix Lechner <felix.lechner@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.8 (/)

The main executable to set up and manage Linux MD arrays, mdadm, uses a UUID
format that is different from other standards. The variant is here provided
for the benefit of Guix users.

* gnu/system/uuid.scm: Offer an mdadm variant of uuids.
---
 gnu/system/uuid.scm | 46 +++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/gnu/system/uuid.scm b/gnu/system/uuid.scm
index 8f967387ad..dc8bb3f7b7 100644
--- a/gnu/system/uuid.scm
+++ b/gnu/system/uuid.scm
@@ -82,8 +82,9 @@ (define-syntax %network-byte-order
   (identifier-syntax (endianness big)))
 
 (define (dce-uuid->string uuid)
-  "Convert UUID, a 16-byte bytevector, to its string representation, something
-like \"6b700d61-5550-48a1-874c-a3d86998990e\"."
+  "Convert UUID, a 16-byte bytevector, to its DCE string representation (see
+<https://tools.ietf.org/html/rfc4122>), which looks something like
+\"6b700d61-5550-48a1-874c-a3d86998990e\"."
   ;; See <https://tools.ietf.org/html/rfc4122>.
   (let ((time-low  (bytevector-uint-ref uuid 0 %network-byte-order 4))
         (time-mid  (bytevector-uint-ref uuid 4 %network-byte-order 2))
@@ -93,7 +94,7 @@ (define (dce-uuid->string uuid)
     (format #f "~8,'0x-~4,'0x-~4,'0x-~4,'0x-~12,'0x"
             time-low time-mid time-hi clock-seq node)))
 
-(define %uuid-rx
+(define %dce-uuid-rx
   ;; The regexp of a UUID.
   (make-regexp "^([[:xdigit:]]{8})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{12})$"))
 
@@ -101,7 +102,7 @@ (define (string->dce-uuid str)
   "Parse STR as a DCE UUID (see <https://tools.ietf.org/html/rfc4122>) and
 return its contents as a 16-byte bytevector.  Return #f if STR is not a valid
 UUID representation."
-  (and=> (regexp-exec %uuid-rx str)
+  (and=> (regexp-exec %dce-uuid-rx str)
          (lambda (match)
            (letrec-syntax ((hex->number
                             (syntax-rules ()
@@ -167,6 +168,41 @@ (define (digits->string bytes)
          (parts (list year month day hour minute second hundredths)))
     (string-append (string-join (map digits->string parts) "-"))))
 
+
+;;;
+;;; Mdadm.
+;;;
+
+(define (mdadm-uuid->string uuid)
+  "Convert UUID, a 16-byte bytevector, to its Mdadm string representation,
+which looks something like \"6b700d61:555048a1:874ca3d8:6998990e\"."
+  ;; See <https://tools.ietf.org/html/rfc4122>.
+  (format #f "~8,'0x:~8,'0x:~8,'0x:~8,'0x"
+          (bytevector-uint-ref uuid 0 %network-byte-order 4)
+          (bytevector-uint-ref uuid 4 %network-byte-order 4)
+          (bytevector-uint-ref uuid 8 %network-byte-order 4)
+          (bytevector-uint-ref uuid 12 %network-byte-order 4)))
+
+(define %mdadm-uuid-rx
+  (make-regexp "^([[:xdigit:]]{8}):([[:xdigit:]]{8}):([[:xdigit:]]{8}):([[:xdigit:]]{8})$"))
+
+(define (string->mdadm-uuid str)
+  "Parse STR, which is in Mdadm format, and return a bytevector or #f."
+  (match (regexp-exec %mdadm-uuid-rx str)
+    (#f
+     #f)
+    (rx-match
+     (uint-list->bytevector (list (string->number
+                                   (match:substring rx-match 1) 16)
+                                  (string->number
+                                   (match:substring rx-match 2) 16)
+                                  (string->number
+                                   (match:substring rx-match 3) 16)
+                                  (string->number
+                                   (match:substring rx-match 4) 16))
+                            %network-byte-order
+                            4))))
+
 
 ;;;
 ;;; FAT32/FAT16.
@@ -259,6 +295,7 @@ (define %uuid-parsers
    ('dce 'ext2 'ext3 'ext4 'bcachefs 'btrfs 'f2fs 'jfs 'xfs 'luks
          => string->dce-uuid)
    ('fat32 'fat16 'fat => string->fat-uuid)
+   ('mdadm => string->mdadm-uuid)
    ('ntfs => string->ntfs-uuid)
    ('iso9660 => string->iso9660-uuid)))
 
@@ -268,6 +305,7 @@ (define %uuid-printers
          => dce-uuid->string)
    ('iso9660 => iso9660-uuid->string)
    ('fat32 'fat16 'fat => fat-uuid->string)
+   ('mdadm => mdadm-uuid->string)
    ('ntfs => ntfs-uuid->string)))
 
 (define* (string->uuid str #:optional (type 'dce))
-- 
2.40.1





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

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


Received: (at submit) by debbugs.gnu.org; 24 Jun 2023 02:06:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 23 22:06:11 2023
Received: from localhost ([127.0.0.1]:39721 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qCsf9-0002jG-IJ
	for submit <at> debbugs.gnu.org; Fri, 23 Jun 2023 22:06:11 -0400
Received: from lists.gnu.org ([209.51.188.17]:41472)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <felix.lechner@HIDDEN>) id 1qCsf4-0002j3-Et
 for submit <at> debbugs.gnu.org; Fri, 23 Jun 2023 22:06:06 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <felix.lechner@HIDDEN>)
 id 1qCsf4-0003uK-1T
 for guix-patches@HIDDEN; Fri, 23 Jun 2023 22:06:02 -0400
Received: from sail-ipv4.us-core.com ([208.82.101.137])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256)
 (Exim 4.90_1) (envelope-from <felix.lechner@HIDDEN>)
 id 1qCsex-0005CU-Hg
 for guix-patches@HIDDEN; Fri, 23 Jun 2023 22:06:01 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=2017; bh=+Q0fSFAc2n9Xwqz
 oDcd9xmTY+SCnzwnSbAfyGmuaThU=; h=date:subject:cc:to:from;
 d=lease-up.com; b=n4LZPxbxRP85d4yMzMEGuFKBM44SX1Vx0ZLXrwu73jO343t83xwJ
 E5bdMJGJqg3fsnUXMfI/rxU9XGlm2NusxgdomohLjqsv+NX3t5MJGeuQSiXMr4wdCXJuRi
 V+RkpNrgRReyl7lNl35MF3EDooimVoismwstJUUbYaQKTctrc=
Received: by sail-ipv4.us-core.com (OpenSMTPD) with ESMTPSA id 902e5a4a
 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); 
 Sat, 24 Jun 2023 02:05:49 +0000 (UTC)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id 25e225ad;
 Sat, 24 Jun 2023 02:05:48 +0000 (UTC)
From: Felix Lechner <felix.lechner@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH 0/2] Allow booting of degraded software RAID/MD arrays
Date: Fri, 23 Jun 2023 19:05:36 -0700
Message-Id: <cover.1687571974.git.felix.lechner@HIDDEN>
X-Mailer: git-send-email 2.40.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=208.82.101.137;
 envelope-from=felix.lechner@HIDDEN; helo=sail-ipv4.us-core.com
X-Spam_score_int: -17
X-Spam_score: -1.8
X-Spam_bar: -
X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01,
 UNPARSEABLE_RELAY=0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.1 (-)
X-Debbugs-Envelope-To: submit
Cc: Felix Lechner <felix.lechner@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.1 (--)

This commit series cures a dangerous condition for users of MD arrays in GNU
Guix. Such arrays are presently unlikely to boot after a drive
failure. Instead the user is dropped into an early boot Guile shell.

That behaviour contradicts the expectations of many users of such arrays.

These commits were tested over several months on two production machines. The
changes also includes a system test of the new facility.

Please feel free to make any edits to this series as needed, without checking
with the author. Thanks!

Felix Lechner (2):
  Offer an mdadm variant of uuids.
  Provide md-array-device-mapping to start MD arrays via UUID or name.

 doc/guix.texi                 | 28 +++++++++++----------
 gnu/system/mapped-devices.scm | 38 ++++++++++++++++++++++++++++-
 gnu/system/uuid.scm           | 46 ++++++++++++++++++++++++++++++++---
 gnu/tests/install.scm         | 32 ++++++++++++------------
 4 files changed, 110 insertions(+), 34 deletions(-)


base-commit: d6dc82e8cdb2d6114a12b06d449ce7f1150c7f70
-- 
2.40.1





Acknowledgement sent to Felix Lechner <felix.lechner@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#64259; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 20 Jan 2024 12:30:02 UTC

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