all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mathieu Othacehe <othacehe@gnu.org>
To: "So'n Typ im Internet" <sontypiminternet@gmail.com>
Cc: 59823@debbugs.gnu.org, Josselin Poiret <dev@jpoiret.xyz>
Subject: bug#59823: [1.4.0rc1] Installer fails to identify installation device on Ventoy-made images
Date: Thu, 08 Dec 2022 13:28:19 +0100	[thread overview]
Message-ID: <877cz213mk.fsf_-_@gnu.org> (raw)
In-Reply-To: <87y1rj6xb0.fsf@gnu.org> (Mathieu Othacehe's message of "Wed, 07 Dec 2022 16:36:03 +0100")

[-- Attachment #1: Type: text/plain, Size: 170 bytes --]


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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-installer-Detect-mapped-installation-devices.patch --]
[-- Type: text/x-patch, Size: 2511 bytes --]

From 0afda5b3ed32e73bece9db96ab970d83f9f2e74b Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <othacehe@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


  reply	other threads:[~2022-12-08 12:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-04  9:57 bug#59823: an installer dump was sent So'n Typ im Internet
2022-12-05  8:18 ` Mathieu Othacehe
2022-12-05  8:33   ` So'n Typ im Internet
2022-12-07  9:31     ` Mathieu Othacehe
2022-12-07  9:48       ` So'n Typ im Internet
2022-12-07 15:36         ` Mathieu Othacehe
2022-12-08 12:28           ` Mathieu Othacehe [this message]
2022-12-09 22:16             ` bug#59823: [1.4.0rc1] Installer fails to identify installation device on Ventoy-made images Ludovic Courtès
2022-12-10 10:26               ` Mathieu Othacehe
2022-12-10 11:01                 ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877cz213mk.fsf_-_@gnu.org \
    --to=othacehe@gnu.org \
    --cc=59823@debbugs.gnu.org \
    --cc=dev@jpoiret.xyz \
    --cc=sontypiminternet@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.