unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Sergey Trofimov <sarg@sarg.org.ru>
To: 62223@debbugs.gnu.org
Cc: Sergey Trofimov <sarg@sarg.org.ru>
Subject: [bug#62223] [PATCH] image: Prefer gpt partition table for efi disk images
Date: Thu, 16 Mar 2023 18:31:38 +0100	[thread overview]
Message-ID: <20230316173137.25074-1-sarg@sarg.org.ru> (raw)

Hi guix, I got curious, what the easiest way to migrate existing guix os to a
new machine could be, and I've came to a conclusion that `guix system image`
fits this scenario perfectly. So I've tried to run `guix system image
--image-type=efi-raw --persistent --save-provenance system.scm`, but the
resulting image contained MBR style partition table. Although MBR support is a
must for an UEFI implementor, a better choice would be to use GPT style table.

* gnu/system/image.scm (efi-disk-image): Use gpt partition-table-type.
(efi32-disk-image): Use gpt partition-table-type.
* gnu/tests/image.scm: Assert partition table type of efi-disk-image.
---
 gnu/system/image.scm |  2 ++
 gnu/tests/image.scm  | 23 ++++++++++++++++++-----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index afef79185f..5356ecd616 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -147,11 +147,13 @@ (define root-partition
 (define efi-disk-image
   (image-without-os
    (format 'disk-image)
+   (partition-table-type 'gpt)
    (partitions (list esp-partition root-partition))))
 
 (define efi32-disk-image
   (image-without-os
    (format 'disk-image)
+   (partition-table-type 'gpt)
    (partitions (list esp32-partition root-partition))))
 
 (define iso9660-image
diff --git a/gnu/tests/image.scm b/gnu/tests/image.scm
index 99d34b7670..be6852cae0 100644
--- a/gnu/tests/image.scm
+++ b/gnu/tests/image.scm
@@ -20,7 +20,7 @@ (define-module (gnu tests image)
   #:use-module (gnu)
   #:use-module (gnu image)
   #:use-module (gnu tests)
-  #:autoload   (gnu system image) (system-image root-offset)
+  #:autoload   (gnu system image) (system-image root-offset image-with-os efi-disk-image)
   #:use-module (gnu system uuid)
   #:use-module (gnu system vm)
   #:use-module (gnu packages guile)
@@ -153,6 +153,10 @@ (define i5
       (flags '(boot))
       (initializer dummy-initializer))))))
 
+;; A efi disk image with default partitions
+(define i6
+  (image-with-os efi-disk-image %simple-efi-os))
+
 (define (run-images-test)
   (define test
     (with-imported-modules '((srfi srfi-64)
@@ -202,10 +206,10 @@ (define d2-device
               (disk-get-primary-partition-count (disk-new d2-device)))
 
             (test-equal "test"
-                (let* ((disk (disk-new d2-device))
-                       (partitions (disk-partitions disk))
-                       (boot-partition (find normal-partition? partitions)))
-                  (partition-get-name boot-partition)))
+              (let* ((disk (disk-new d2-device))
+                     (partitions (disk-partitions disk))
+                     (boot-partition (find normal-partition? partitions)))
+                (partition-get-name boot-partition)))
 
             ;; Image i3.
             (define i3-image
@@ -259,6 +263,15 @@ (define (sector->byte sector)
                    (filter data-partition?
                            (disk-partitions (disk-new d5-device)))))
 
+            ;; Image i6.
+            (define i6-image
+              #$(system-image i6))
+            (define d6-device
+              (get-device i6-image))
+
+            (test-equal "gpt"
+              (disk-type-name (disk-probe d6-device)))
+
             (test-end)))))
 
   (gexp->derivation "images-test" test))
-- 
2.39.2





             reply	other threads:[~2023-03-16 17:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16 17:31 Sergey Trofimov [this message]
2023-03-21 21:41 ` [bug#62223] [PATCH] image: Prefer gpt partition table for efi disk images Josselin Poiret via Guix-patches via
2023-03-22 12:48   ` Sergey Trofimov
2023-03-22  8:14 ` [bug#62223] Tested locally Sergey Trofimov
2023-03-22 12:53 ` [bug#62223] [PATCH v2] image: Prefer gpt partition table for efi images Sergey Trofimov
2023-07-07 19:50   ` bug#62223: " Josselin Poiret via Guix-patches via

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=20230316173137.25074-1-sarg@sarg.org.ru \
    --to=sarg@sarg.org.ru \
    --cc=62223@debbugs.gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).