diff options
| author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2025-10-13 02:19:26 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2025-11-24 23:22:52 +0100 |
| commit | 35770c78a2db5cced15f651fdf31ed9aae349899 (patch) | |
| tree | 0bc7cc1ca30bebbaa1e94d0550b593e056258b12 /gnu | |
| parent | 5e5ac81e9562c9f77910766f3a1c857b3da36472 (diff) | |
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>
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/build/image.scm | 19 | ||||
| -rw-r--r-- | gnu/system/image.scm | 4 |
2 files changed, 23 insertions, 0 deletions
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)) |
