From unknown Wed Aug 20 00:02:44 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#51598] [PATCH 2/2] image: Support generating GPT images via `partition-table-type` Resent-From: Ryan Sundberg Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 04 Nov 2021 08:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51598 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51598@debbugs.gnu.org Cc: Ryan Sundberg X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.163601494327132 (code B ref -1); Thu, 04 Nov 2021 08:36:02 +0000 Received: (at submit) by debbugs.gnu.org; 4 Nov 2021 08:35:43 +0000 Received: from localhost ([127.0.0.1]:41965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1miYDn-00073X-G2 for submit@debbugs.gnu.org; Thu, 04 Nov 2021 04:35:43 -0400 Received: from lists.gnu.org ([209.51.188.17]:34464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1miYDl-00073J-81 for submit@debbugs.gnu.org; Thu, 04 Nov 2021 04:35:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1miYDl-0007pU-1U for guix-patches@gnu.org; Thu, 04 Nov 2021 04:35:41 -0400 Received: from mail.arctype.co ([138.68.9.245]:34821) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1miYDi-0008D8-QD for guix-patches@gnu.org; Thu, 04 Nov 2021 04:35:40 -0400 Received: from authenticated-user (mail.arctype.co [138.68.9.245]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mail.arctype.co (Postfix) with ESMTPSA id BB12A13B2C3; Thu, 4 Nov 2021 08:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=arctype.co; s=mail; t=1636014936; bh=y8vSCv5cSARs+crGZYQcuABaxFTaajtzRyI5NOSw0ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A5TnX29DcEeidieBrQ6qxr5EyUf5+qoRmAGU25QnaUhWf+VMfb2bVX8uw/wUd6ZRG 1s1/Pg3UngQATlwsIG8HD3h3gSZLTeG1g33NoxGNMZVCw/n/i6cHUcvBWgRCNHsOQ2 Fm+KXJu9OlcXCPfkDaEBHB0COxfj/2ikekKqc4p1VQY4wqhUKI8AMaa9ieE+zk6F97 y/SDBkjkNDtTMAH3SwRunj5TnCKsJsEYPPIVW6teWKe1JNiwwli4tEpkltwfgkdpVY FDywvE5YV4e8JJjCf8QLxe1iWLrHMF60dDXUtHk108P6f7RCH92zw84b+XYSpek+86 dvpVLZa44uVhw== From: Ryan Sundberg Date: Thu, 4 Nov 2021 01:35:11 -0700 Message-Id: <20211104083511.11852-2-ryan@arctype.co> In-Reply-To: <20211104083511.11852-1-ryan@arctype.co> References: <20211104083511.11852-1-ryan@arctype.co> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=138.68.9.245; envelope-from=ryan@arctype.co; helo=mail.arctype.co 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) 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: -2.4 (--) * gnu/image.scm: Add partition-table-type field to image * gnu/system/image.scm: Implement partition-table-type logic for genimage. --- gnu/image.scm | 3 +++ gnu/system/image.scm | 59 +++++++++++++++++++++++++++++++------------- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/gnu/image.scm b/gnu/image.scm index 75d489490d..b83c4275da 100644 --- a/gnu/image.scm +++ b/gnu/image.scm @@ -37,6 +37,7 @@ image-target image-size image-operating-system + image-partition-table-type image-partitions image-compression? image-volatile-root? @@ -84,6 +85,8 @@ (default 'guess)) (operating-system image-operating-system ; (default #f)) + (partition-table-type image-partition-table-type ; 'mbr or 'gpt + (default 'mbr)) (partitions image-partitions ;list of (default '())) (compression? image-compression? ;boolean diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 7a3a637e47..ed22484a62 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -309,6 +309,14 @@ used in the image." ((member 'esp flags) "0xEF") (else "0x83")))) + (define (partition->gpt-type partition) + ;; Return the genimage GPT partition type code corresponding to PARTITION. + ;; See https://github.com/pengutronix/genimage/blob/master/README.rst + (let ((flags (partition-flags partition))) + (cond + ((member 'esp flags) "U") + (else "L")))) + (define (partition-image partition) ;; Return as a file-like object, an image of the given PARTITION. A ;; directory, filled by calling the PARTITION initializer procedure, is @@ -358,26 +366,43 @@ used in the image." #:local-build? #f #:options `(#:references-graphs ,inputs)))) - (define (partition->config partition) + (define (gpt-image? image) + (eq? 'gpt (image-partition-table-type image))) + + (define (partition-type-values image partition) + (if (gpt-image? image) + (values "partition-type-uuid" (partition->gpt-type partition)) + (values "partition-type" (partition->dos-type partition)))) + + (define (partition->config image partition) ;; Return the genimage partition configuration for PARTITION. - (let ((label (partition-label partition)) - (dos-type (partition->dos-type partition)) - (image (partition-image partition)) - (offset (partition-offset partition))) - #~(format #f "~/partition ~a { -~/~/partition-type = ~a -~/~/image = \"~a\" -~/~/offset = \"~a\" -~/}" - #$label - #$dos-type - #$image - #$offset))) + (let-values (((partition-type-attribute partition-type-value) (partition-type-values image partition))) + (let ((label (partition-label partition)) + (image (partition-image partition)) + (offset (partition-offset partition))) + #~(format #f "~/partition ~a { + ~/~/~a = ~a + ~/~/image = \"~a\" + ~/~/offset = \"~a\" + ~/}" + #$label + #$partition-type-attribute + #$partition-type-value + #$image + #$offset)))) + + (define (genimage-type-options image-type image) + (cond + ((equal? image-type "hdimage") + (format #f "~%~/~/gpt = ~a~%~/" + (if (gpt-image? image) "true" "false"))) + (else ""))) (let* ((format (image-format image)) (image-type (format->image-type format)) + (image-type-options (genimage-type-options image-type image)) (partitions (image-partitions image)) - (partitions-config (map partition->config partitions)) + (partitions-config (map (cut partition->config image <>) partitions)) (builder #~(begin (let ((format (@ (ice-9 format) format))) @@ -386,9 +411,9 @@ used in the image." (format port "\ image ~a { -~/~a {} +~/~a {~a} ~{~a~^~%~} -}~%" #$genimage-name #$image-type (list #$@partitions-config)))))))) +}~%" #$genimage-name #$image-type #$image-type-options (list #$@partitions-config)))))))) (computed-file "genimage.cfg" builder))) (let* ((image-name (image-name image)) -- 2.31.1 From unknown Wed Aug 20 00:02:44 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Ryan Sundberg Subject: bug#51598: closed (Re: bug#51598: [PATCH 2/2] image: Support generating GPT images via `partition-table-type`) Message-ID: References: <87y25tcx6c.fsf_-_@gnu.org> <20211104083511.11852-2-ryan@arctype.co> X-Gnu-PR-Message: they-closed 51598 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 51598@debbugs.gnu.org Date: Fri, 12 Nov 2021 13:38:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1636724282-571-1" This is a multi-part message in MIME format... ------------=_1636724282-571-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #51598: [PATCH 2/2] image: Support generating GPT images via `partition-tab= le-type` which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 51598@debbugs.gnu.org. --=20 51598: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D51598 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1636724282-571-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 51598-done) by debbugs.gnu.org; 12 Nov 2021 13:37:26 +0000 Received: from localhost ([127.0.0.1]:43730 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlWkA-00008I-5p for submit@debbugs.gnu.org; Fri, 12 Nov 2021 08:37:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37380) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlWk6-000083-Rh for 51598-done@debbugs.gnu.org; Fri, 12 Nov 2021 08:37:24 -0500 Received: from [2001:470:142:3::e] (port=40276 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlWk1-00028W-JW; Fri, 12 Nov 2021 08:37:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=dfvvlG8LGEC/Cill4CDiuLM1xfgWtnuWegeezU+j4uw=; b=SDMc4XJfSZKr0cv6SGV1 YfT6veLfTDTxzGShTdyhEJpSzCK1pISjd1uiaWnOR7FY+M4UisflSvc2fIphbh2HP/w5L4zUV2Qxg llaWDQJI0SUgDlVcQzRrhW7FvBPPl9KeYevQXjly67levzb1kH5TzMlUQsCP2UV3Va+9VsOPDcb56 Z6jhZEC98XwBYf7YmIFGjQFOnztkHCuHuJ6ZdfCj8jc8Vo4Q5Y/7CLvvbj4repc/2Vnm4mYSGdiMo yVD4xAB9PQ4/OFduFS4luMyCmbuAuJYCW8xsRYdJylsZK6BSG1To2c9D+T5jniDwpA1DepcS3CS4S NDLYKeKS4aO0HA==; Received: from [2a01:e0a:19b:d9a0:b4a5:c7aa:fee0:cc15] (port=60372 helo=meije) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlWk0-0005Gk-Jt; Fri, 12 Nov 2021 08:37:17 -0500 From: Mathieu Othacehe To: Ryan Sundberg Subject: Re: bug#51598: [PATCH 2/2] image: Support generating GPT images via `partition-table-type` References: <20211104083511.11852-1-ryan@arctype.co> <20211104083511.11852-2-ryan@arctype.co> Date: Fri, 12 Nov 2021 13:37:15 +0000 In-Reply-To: <20211104083511.11852-2-ryan@arctype.co> (Ryan Sundberg's message of "Thu, 4 Nov 2021 01:35:11 -0700") Message-ID: <87y25tcx6c.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 51598-done Cc: 51598-done@debbugs.gnu.org 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 (---) Hello Ryan Nice one! I tried to generate a GPT image like so: --8<---------------cut here---------------start------------->8--- $ cat /tmp/my-img.scm (use-modules (gnu) (gnu image) (gnu system image)) (define my-os (primitive-load "/home/mathieu/guix/gnu/system/examples/lightweight-desktop.tmpl")) (image (inherit (os->image my-os #:type efi-raw-image-type)) (name 'raw-gpt) (partition-table-type 'gpt)) $ ./pre-inst-env guix system image /tmp/img.scm --8<---------------cut here---------------end--------------->8--- However, the resulting image was not bootable because Grub was lacking the part_gpt module. This is now fixed with fb3df2011692b2a6fea9f4fefd71dd788453fbae. I also noticed that trying to build a GPT image with a grub-bootloader (bare-bones.tmpl image for instance), failed at build time, probably because install-grub-disk-image is expecting an msdos partition. It would be great if you could have a look to this issue as a follow-up :). I pushed this patch anyway as 096a2bf8c59a955c634cc838e7f7111941c07b37. Thanks, Mathieu ------------=_1636724282-571-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 4 Nov 2021 08:35:43 +0000 Received: from localhost ([127.0.0.1]:41965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1miYDn-00073X-G2 for submit@debbugs.gnu.org; Thu, 04 Nov 2021 04:35:43 -0400 Received: from lists.gnu.org ([209.51.188.17]:34464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1miYDl-00073J-81 for submit@debbugs.gnu.org; Thu, 04 Nov 2021 04:35:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1miYDl-0007pU-1U for guix-patches@gnu.org; Thu, 04 Nov 2021 04:35:41 -0400 Received: from mail.arctype.co ([138.68.9.245]:34821) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1miYDi-0008D8-QD for guix-patches@gnu.org; Thu, 04 Nov 2021 04:35:40 -0400 Received: from authenticated-user (mail.arctype.co [138.68.9.245]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mail.arctype.co (Postfix) with ESMTPSA id BB12A13B2C3; Thu, 4 Nov 2021 08:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=arctype.co; s=mail; t=1636014936; bh=y8vSCv5cSARs+crGZYQcuABaxFTaajtzRyI5NOSw0ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A5TnX29DcEeidieBrQ6qxr5EyUf5+qoRmAGU25QnaUhWf+VMfb2bVX8uw/wUd6ZRG 1s1/Pg3UngQATlwsIG8HD3h3gSZLTeG1g33NoxGNMZVCw/n/i6cHUcvBWgRCNHsOQ2 Fm+KXJu9OlcXCPfkDaEBHB0COxfj/2ikekKqc4p1VQY4wqhUKI8AMaa9ieE+zk6F97 y/SDBkjkNDtTMAH3SwRunj5TnCKsJsEYPPIVW6teWKe1JNiwwli4tEpkltwfgkdpVY FDywvE5YV4e8JJjCf8QLxe1iWLrHMF60dDXUtHk108P6f7RCH92zw84b+XYSpek+86 dvpVLZa44uVhw== From: Ryan Sundberg To: guix-patches@gnu.org Subject: [PATCH 2/2] image: Support generating GPT images via `partition-table-type` Date: Thu, 4 Nov 2021 01:35:11 -0700 Message-Id: <20211104083511.11852-2-ryan@arctype.co> In-Reply-To: <20211104083511.11852-1-ryan@arctype.co> References: <20211104083511.11852-1-ryan@arctype.co> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=138.68.9.245; envelope-from=ryan@arctype.co; helo=mail.arctype.co 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: Ryan Sundberg 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: -2.4 (--) * gnu/image.scm: Add partition-table-type field to image * gnu/system/image.scm: Implement partition-table-type logic for genimage. --- gnu/image.scm | 3 +++ gnu/system/image.scm | 59 +++++++++++++++++++++++++++++++------------- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/gnu/image.scm b/gnu/image.scm index 75d489490d..b83c4275da 100644 --- a/gnu/image.scm +++ b/gnu/image.scm @@ -37,6 +37,7 @@ image-target image-size image-operating-system + image-partition-table-type image-partitions image-compression? image-volatile-root? @@ -84,6 +85,8 @@ (default 'guess)) (operating-system image-operating-system ; (default #f)) + (partition-table-type image-partition-table-type ; 'mbr or 'gpt + (default 'mbr)) (partitions image-partitions ;list of (default '())) (compression? image-compression? ;boolean diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 7a3a637e47..ed22484a62 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -309,6 +309,14 @@ used in the image." ((member 'esp flags) "0xEF") (else "0x83")))) + (define (partition->gpt-type partition) + ;; Return the genimage GPT partition type code corresponding to PARTITION. + ;; See https://github.com/pengutronix/genimage/blob/master/README.rst + (let ((flags (partition-flags partition))) + (cond + ((member 'esp flags) "U") + (else "L")))) + (define (partition-image partition) ;; Return as a file-like object, an image of the given PARTITION. A ;; directory, filled by calling the PARTITION initializer procedure, is @@ -358,26 +366,43 @@ used in the image." #:local-build? #f #:options `(#:references-graphs ,inputs)))) - (define (partition->config partition) + (define (gpt-image? image) + (eq? 'gpt (image-partition-table-type image))) + + (define (partition-type-values image partition) + (if (gpt-image? image) + (values "partition-type-uuid" (partition->gpt-type partition)) + (values "partition-type" (partition->dos-type partition)))) + + (define (partition->config image partition) ;; Return the genimage partition configuration for PARTITION. - (let ((label (partition-label partition)) - (dos-type (partition->dos-type partition)) - (image (partition-image partition)) - (offset (partition-offset partition))) - #~(format #f "~/partition ~a { -~/~/partition-type = ~a -~/~/image = \"~a\" -~/~/offset = \"~a\" -~/}" - #$label - #$dos-type - #$image - #$offset))) + (let-values (((partition-type-attribute partition-type-value) (partition-type-values image partition))) + (let ((label (partition-label partition)) + (image (partition-image partition)) + (offset (partition-offset partition))) + #~(format #f "~/partition ~a { + ~/~/~a = ~a + ~/~/image = \"~a\" + ~/~/offset = \"~a\" + ~/}" + #$label + #$partition-type-attribute + #$partition-type-value + #$image + #$offset)))) + + (define (genimage-type-options image-type image) + (cond + ((equal? image-type "hdimage") + (format #f "~%~/~/gpt = ~a~%~/" + (if (gpt-image? image) "true" "false"))) + (else ""))) (let* ((format (image-format image)) (image-type (format->image-type format)) + (image-type-options (genimage-type-options image-type image)) (partitions (image-partitions image)) - (partitions-config (map partition->config partitions)) + (partitions-config (map (cut partition->config image <>) partitions)) (builder #~(begin (let ((format (@ (ice-9 format) format))) @@ -386,9 +411,9 @@ used in the image." (format port "\ image ~a { -~/~a {} +~/~a {~a} ~{~a~^~%~} -}~%" #$genimage-name #$image-type (list #$@partitions-config)))))))) +}~%" #$genimage-name #$image-type #$image-type-options (list #$@partitions-config)))))))) (computed-file "genimage.cfg" builder))) (let* ((image-name (image-name image)) -- 2.31.1 ------------=_1636724282-571-1--