From cd55aa98011c42b8e97561f4eea024be751bcceb Mon Sep 17 00:00:00 2001 From: Efraim Flashner Date: Sun, 28 May 2023 11:03:17 +0300 Subject: gnu: image: Add support for unformatted partitions. * gnu/build/image.scm (make-unformatted-image): New procedure. (make-partition-image): Add support for unformatted partition. * gnu/system/image.scm (system-disk-image)[partition->gpt-type]: Add case for using unformatted partition uuid. --- gnu/build/image.scm | 11 +++++++++++ gnu/system/image.scm | 4 ++++ 2 files changed, 15 insertions(+) (limited to 'gnu') diff --git a/gnu/build/image.scm b/gnu/build/image.scm index 65a0373980..49dc01c0d1 100644 --- a/gnu/build/image.scm +++ b/gnu/build/image.scm @@ -7,6 +7,7 @@ ;;; Copyright © 2020 Mathieu Othacehe ;;; Copyright © 2022 Pavel Shlyak ;;; Copyright © 2022 Denis 'GNUtoo' Carikli +;;; Copyright © 2023 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -122,6 +123,14 @@ (define* (make-vfat-image partition target root fs-bits) (string-append "::" file)))) (scandir root)))) +(define* (make-unformatted-image partition target) + "Make an unformatted partition of a certain size." + (let ((size (partition-size partition))) + ;; Create the file and then truncate it to the desired size. + (with-output-to-file target + (lambda _ (display ""))) + (truncate-file target size))) + (define* (make-partition-image partition-sexp target root) "Create and return the image of PARTITION-SEXP as TARGET. Use the given ROOT directory to populate the image." @@ -134,6 +143,8 @@ (define* (make-partition-image partition-sexp target root) (make-vfat-image partition target root 16)) ((string=? type "fat32") (make-vfat-image partition target root 32)) + ((string=? type "unformatted") + (make-unformatted-image partition target)) (else (raise (condition (&message diff --git a/gnu/system/image.scm b/gnu/system/image.scm index afef79185f..958ba5cbb2 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2022 Pavel Shlyak ;;; Copyright © 2022 Denis 'GNUtoo' Carikli ;;; Copyright © 2022 Alex Griffin +;;; Copyright © 2023 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -390,6 +391,9 @@ (define (partition->gpt-type partition) ((or (string=? file-system "vfat") (string=? file-system "fat16") (string=? file-system "fat32")) "F") + ((and (string=? file-system "unformatted") + (partition-uuid partition)) + (uuid->string (partition-uuid partition))) (else (raise (condition (&message -- cgit v1.2.3