From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 16 13:38:30 2023 Received: (at submit) by debbugs.gnu.org; 16 Mar 2023 17:38:31 +0000 Received: from localhost ([127.0.0.1]:42870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcrYc-00079h-Fe for submit@debbugs.gnu.org; Thu, 16 Mar 2023 13:38:30 -0400 Received: from lists.gnu.org ([209.51.188.17]:44462) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcrYb-00079a-Mm for submit@debbugs.gnu.org; Thu, 16 Mar 2023 13:38:30 -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 ) id 1pcrYb-0000ph-3C for guix-patches@gnu.org; Thu, 16 Mar 2023 13:38:29 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pcrYY-0005Fh-Ju for guix-patches@gnu.org; Thu, 16 Mar 2023 13:38:28 -0400 Received: by mail-ed1-x52a.google.com with SMTP id y4so10760439edo.2 for ; Thu, 16 Mar 2023 10:38:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1678988302; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xnMcbFMdUZNNgUHJ2BxbWhgdbglB0dv0kxjl2M14eVA=; b=dFuwDgNG4kp4gv17u2VTvv4DY673JwuKEAvDA8M1GRVg1Xz+K2v+sU/x+DWMFfimVs WqwpwCXCSsgaxdjptkkIq86ZaEx9LidlV2fx7v7rH0/kKeBugOrL7tOGXSBreBPKWLhi ZMzy9aF/E/5oibo8bajdIirlE3YIMxVEAZOTo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678988302; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xnMcbFMdUZNNgUHJ2BxbWhgdbglB0dv0kxjl2M14eVA=; b=paqG3XvzlXTsbYsiZkW7vDOGUxJdJP1hZ5oFUip+I7/2GxUi9oV9h8Q66yulKNeV0l Y63ZPC++mEs1B3ZP7OEtWsKOKEIaTcdGLsXItmhgFr+eusFd2MHpMTGYCnwjdRQYey1v Beaa5+WWHd0vaVND4pUTbHLkqMuXfCUoCjDwyGTM9eUWB5J9ZbhbsNJDKP5BYIRQrlzH 9m+wi6xbR2BeXMDea8vbq+/ws51zXj5aF7OetamOAvCpGAkv0uucHFsvQ74ToJVBwZmp gzjDZvHHvH2ERRUQhFAKilWuJWqdxM5PHK0Yw9vi1G92z7MqhnJIFZ4nNVw5Px3ZkuDe hSJA== X-Gm-Message-State: AO0yUKX2VR1hcG6avd3zmcSwGSLWsldr24r0ddiGF2//4ty9oHlOmbCL FmWRIOga/EDuzpUNNPYGby6PTX7qyBPDx4+6T7U= X-Google-Smtp-Source: AK7set947OKIQwRHx4shKegf8KlKP1N/kTCwbmh1n43WBuS+V6IH4hp2NgZ9vZXHwzkCl1HQkiR+LQ== X-Received: by 2002:a17:907:7baa:b0:931:3a85:d0bf with SMTP id ne42-20020a1709077baa00b009313a85d0bfmr1433704ejc.17.1678988302515; Thu, 16 Mar 2023 10:38:22 -0700 (PDT) Received: from localhost ([95.168.147.255]) by smtp.gmail.com with ESMTPSA id jp19-20020a170906f75300b009231714b3d4sm4034655ejb.151.2023.03.16.10.38.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 10:38:22 -0700 (PDT) From: Sergey Trofimov To: guix-patches@gnu.org Subject: [PATCH] image: Prefer gpt partition table for efi disk images Date: Thu, 16 Mar 2023 18:31:38 +0100 Message-Id: <20230316173137.25074-1-sarg@sarg.org.ru> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: none client-ip=2a00:1450:4864:20::52a; envelope-from=sarg@sarg.org.ru; helo=mail-ed1-x52a.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: Sergey Trofimov 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 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