~ruther/guix-local

35770c78a2db5cced15f651fdf31ed9aae349899 — Denis 'GNUtoo' Carikli 11 months ago 5e5ac81
image: Add support for swap.

* gnu/build/image.scm (make-swap-image): New variable.
  (make-partition-image): Support swap.
* gnu/system/image.scm (system-disk-image): Support swap.
* doc/guix.texi: (partition Reference): Support swap.

Change-Id: I1c201e6aa5dd207d53e5732617910860ee894990
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
3 files changed, 24 insertions(+), 1 deletions(-)

M doc/guix.texi
M gnu/build/image.scm
M gnu/system/image.scm
M doc/guix.texi => doc/guix.texi +1 -1
@@ 54288,7 54288,7 @@ there is no offset applied.
The partition file system as a string, defaulting to @code{"ext4"}.

The supported values are @code{"btrfs"}, @code{"ext4"}, @code{"fat16"},
@code{"fat32"}, and @code{"vfat"}.
@code{"f2fs"}, @code{"fat32"}, @code{"vfat"}, and @code{"swap"}.

@code{"vfat"}, @code{"fat16"}, and @code{"fat32"} partitions without the
@code{'esp} flag are by default LBA compatible.

M gnu/build/image.scm => gnu/build/image.scm +19 -0
@@ 175,6 175,23 @@ turn doesn't take any constant overhead into account, force a 1-MiB minimum."
                          (string-append "::" file))))
              (scandir root))))

(define* (make-swap-image partition target)
  "Make a swap partition of a certain size."
  (let ((size (partition-size partition))
        (label (partition-label partition))
        (uuid (partition-uuid partition))
        (fs-options (partition-file-system-options partition)))
    (apply invoke "fakeroot" "mkswap"
           "--pagesize" "4096"
           "--endianness" "little"
           "-L" label
           "--file" target
           "--size" (number->string size)
           `(,@(if uuid
                   `("-U" ,(uuid->string uuid))
                   '())
             ,@fs-options))))

(define* (make-unformatted-image partition target)
  "Make an unformatted partition of a certain size."
  (let ((size (partition-size partition)))


@@ 199,6 216,8 @@ ROOT directory to populate the image."
      (make-vfat-image partition target root 16))
     ((string=? type "fat32")
      (make-vfat-image partition target root 32))
     ((string=? "swap" type)
      (make-swap-image partition target))
     ((string=? type "unformatted")
      (make-unformatted-image partition target))
     (else

M gnu/system/image.scm => gnu/system/image.scm +4 -0
@@ 403,6 403,7 @@ used in the image."
            (file-system (partition-file-system partition)))
        (cond
         ((member 'esp flags) "0xEF")
         ((string=? file-system "swap") "0x82")
         ((or (string=? file-system "btrfs")
              (string-prefix? "ext" file-system)
              (string=? file-system "f2fs")) "0x83")


@@ 430,6 431,7 @@ used in the image."
         ((or (string=? file-system "vfat")
              (string=? file-system "fat16")
              (string=? file-system "fat32")) "F")
         ((string=? file-system "swap") "S")
         ((and (string=? file-system "unformatted")
               (partition-uuid partition))
          (uuid->string (partition-uuid partition)))


@@ 464,6 466,8 @@ used in the image."
                                   (list e2fsprogs fakeroot))
                                  ((string=? type "f2fs")
                                   (list f2fs-tools fakeroot))
                                  ((string=? type "swap")
                                   (list fakeroot util-linux))
                                  ((or (string=? type "vfat")
                                       (string-prefix? "fat" type))
                                   (list dosfstools fakeroot mtools))