GNU bug report logs - #59823
[1.4.0rc1] Installer fails to identify installation device on Ventoy-made images

Previous Next

Package: guix;

Reported by: "So'n Typ im Internet" <sontypiminternet <at> gmail.com>

Date: Sun, 4 Dec 2022 20:25:02 UTC

Severity: normal

Done: Mathieu Othacehe <mathieu <at> meije.mail-host-address-is-not-set>

Bug is archived. No further changes may be made.

Full log


Message #25 received at 59823 <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <othacehe <at> gnu.org>
To: "So'n Typ im Internet" <sontypiminternet <at> gmail.com>
Cc: 59823 <at> debbugs.gnu.org, Josselin Poiret <dev <at> jpoiret.xyz>
Subject: Re: bug#59823: [1.4.0rc1] Installer fails to identify installation
 device on Ventoy-made images
Date: Thu, 08 Dec 2022 13:28:19 +0100
[Message part 1 (text/plain, inline)]
Hello,

The attached patch fixes it for me. We could maybe use libdevmapper
instead of the plain "dmsetup" call but that's not critical in my
opinion.

Thanks,

Mathieu
[0001-installer-Detect-mapped-installation-devices.patch (text/x-patch, inline)]
From 0afda5b3ed32e73bece9db96ab970d83f9f2e74b Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <othacehe <at> gnu.org>
Date: Thu, 8 Dec 2022 13:24:02 +0100
Subject: [PATCH 1/1] installer: Detect mapped installation devices.

Fixes: <https://issues.guix.gnu.org/59823>

* gnu/installer/parted.scm (mapped-device?,
mapped-device->parent-partition-path): New procedures.
(eligible-devices): Detect mapped installation devices using the new
procedures.
---
 gnu/installer/parted.scm | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm
index 82375d29e3..058f2a8dab 100644
--- a/gnu/installer/parted.scm
+++ b/gnu/installer/parted.scm
@@ -379,12 +379,45 @@ (define (installer-root-partition-path)
 (define %min-device-size
   (* 2 GIBIBYTE-SIZE)) ;2GiB
 
+(define (mapped-device? device)
+  "Return #true if DEVICE is a mapped device, false otherwise."
+  (string-prefix? "/dev/dm-" device))
+
+(define (mapped-device->parent-partition-path device)
+  "Return the parent partition path of the mapped DEVICE."
+  (let* ((command `("dmsetup" "deps" ,device "-o" "devname"))
+         (parent #f)
+         (handler
+          (lambda (input)
+            (let ((result
+                   (string-match "\\(([^\\)]+)\\)"
+                                 (get-string-all input))))
+              (and result
+                   (set! parent
+                         (format #f "/dev/~a"
+                                 (match:substring result 1))))))))
+    (run-external-command-with-handler handler command)
+    parent))
+
 (define (eligible-devices)
   "Return all the available devices except the install device and the devices
 which are smaller than %MIN-DEVICE-SIZE."
 
   (define the-installer-root-partition-path
-    (installer-root-partition-path))
+    (let ((root-path
+           (installer-root-partition-path)))
+      (cond
+       ((mapped-device? root-path)
+        ;; If the partition is a mapped device (/dev/dm-X), locate the parent
+        ;; partition.  It is the case when Ventoy is used to host the
+        ;; installation image.
+        (let ((parent-path
+               (mapped-device->parent-partition-path root-path)))
+          (installer-log-line "mapped device ~a -> ~a"
+                              parent-path root-path)
+          parent-path))
+       (else
+        root-path))))
 
   (define (small-device? device)
     (let ((length (device-length device))
-- 
2.38.1


This bug report was last modified 2 years and 164 days ago.

Previous Next


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