diff --git a/doc/guix.texi b/doc/guix.texi index 310700cd0cb..67156cbfa4f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -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. diff --git a/gnu/build/image.scm b/gnu/build/image.scm index c7cf72be91d..c99446f7382 100644 --- a/gnu/build/image.scm +++ b/gnu/build/image.scm @@ -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 diff --git a/gnu/system/image.scm b/gnu/system/image.scm index b89d3a67781..68a88bda0f2 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -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))