From d57cab764122af69d52d8cc9c843456044e5d7bc Mon Sep 17 00:00:00 2001 From: Josselin Poiret Date: Thu, 27 Jul 2023 18:28:18 +0200 Subject: image: Add mbr-raw-image-type and use by default. * gnu/system/image.scm (mbr-disk-image, mbr-raw-image-type): New variables. (qcow2-image-type): Inherit mbr-disk-image. * guix/scripts/system.scm (%default-options): Use mbr-raw-image-type by default. * gnu/tests/install.scm (run-install): Use mbr-raw in the tests. * doc/guix-cookbook.texi (Guix System Image API): Update the list of image types. * doc/guix.texi (Invoking guix system, System Images, image-type Reference): Add mbr-raw and switch documented default to it. --- doc/guix-cookbook.texi | 12 +++++++++--- doc/guix.texi | 16 ++++++++++------ gnu/system/image.scm | 19 +++++++++++++++++-- gnu/tests/install.scm | 4 ++-- guix/scripts/system.scm | 2 +- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi index 87430b741a..e90d611171 100644 --- a/doc/guix-cookbook.texi +++ b/doc/guix-cookbook.texi @@ -2019,17 +2019,23 @@ One can run: mathieu@@cervin:~$ guix system --list-image-types The available image types are: + - unmatched-raw + - rock64-raw - pinebook-pro-raw - pine64-raw - novena-raw - hurd-raw - hurd-qcow2 - qcow2 + - iso9660 - uncompressed-iso9660 + - tarball - efi-raw - - arm64-raw - - arm32-raw - - iso9660 + - mbr-raw + - docker + - wsl2 + - raw-with-offset + - efi32-raw @end example and by writing an @code{operating-system} file based on diff --git a/doc/guix.texi b/doc/guix.texi index e8c67b0cd8..f03a88482e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40884,7 +40884,7 @@ QEMU monitor and the VM. @cindex image, creating disk images The @code{image} command can produce various image types. The image type can be selected using the @option{--image-type} option. It -defaults to @code{efi-raw}. When its value is @code{iso9660}, the +defaults to @code{mbr-raw}. When its value is @code{iso9660}, the @option{--label} option can be used to specify a volume ID with @code{image}. By default, the root file system of a disk image is mounted non-volatile; the @option{--volatile} option can be provided to @@ -40903,7 +40903,7 @@ qemu-system-x86_64 -enable-kvm -hda /tmp/my-image.qcow2 -m 1000 \ -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin @end example -When using the @code{efi-raw} image type, a raw disk image is produced; +When using the @code{mbr-raw} image type, a raw disk image is produced; it can be copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is the device corresponding to a USB stick, one can copy the image to it using the following command: @@ -41041,7 +41041,7 @@ of the image. For the @code{image} action, create an image with given @var{type}. When this option is omitted, @command{guix system} uses the -@code{efi-raw} image type. +@code{mbr-raw} image type. @cindex ISO-9660 format @cindex CD image format @@ -45193,7 +45193,7 @@ then directly boot from it, without any kind of installation procedure. The @command{guix system image} command is able to turn an operating system definition into a bootable image. This command supports -different image types, such as @code{efi-raw}, @code{iso9660} and +different image types, such as @code{mbr-raw}, @code{iso9660} and @code{docker}. Any modern @code{x86_64} machine will probably be able to boot from an @code{iso9660} image. However, there are a few machines out there that require specific image types. Those machines, in general @@ -45545,6 +45545,10 @@ record. There are several @code{image-type} records provided by the @code{(gnu system image)} and the @code{(gnu system images @dots{})} modules. +@defvar mbr-raw-image-type +Build an image based on the @code{mbr-disk-image} image. +@end defvar + @defvar efi-raw-image-type Build an image based on the @code{efi-disk-image} image. @end defvar @@ -45554,7 +45558,7 @@ Build an image based on the @code{efi32-disk-image} image. @end defvar @defvar qcow2-image-type -Build an image based on the @code{efi-disk-image} image but with the +Build an image based on the @code{mbr-disk-image} image but with the @code{compressed-qcow2} image format. @end defvar @@ -45625,7 +45629,7 @@ wsl -d Guix So, if we get back to the @code{guix system image} command taking an @code{operating-system} declaration as argument. By default, the -@code{efi-raw-image-type} is used to turn the provided +@code{mbr-raw-image-type} is used to turn the provided @code{operating-system} into an actual bootable image. To use a different @code{image-type}, the @code{--image-type} option can diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 841e7e0c7e..5b8da2f896 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -76,6 +76,7 @@ esp32-partition root-partition + mbr-disk-image efi-disk-image iso9660-image docker-image @@ -84,6 +85,7 @@ raw-with-offset-disk-image image-with-os + mbr-raw-image-type efi-raw-image-type efi32-raw-image-type qcow2-image-type @@ -145,6 +147,15 @@ parent image record." (flags '(boot)) (initializer (gexp initialize-root-partition)))) +(define mbr-disk-image + (image-without-os + (format 'disk-image) + (partition-table-type 'mbr) + (partitions + (list (partition + (inherit root-partition) + (offset root-offset)))))) + (define efi-disk-image (image-without-os (format 'disk-image) @@ -201,6 +212,11 @@ set to the given OS." (inherit base-image) (operating-system os))) +(define mbr-raw-image-type + (image-type + (name 'mbr-raw) + (constructor (cut image-with-os mbr-disk-image <>)))) + (define efi-raw-image-type (image-type (name 'efi-raw) @@ -216,8 +232,7 @@ set to the given OS." (name 'qcow2) (constructor (cut image-with-os (image - (inherit efi-disk-image) - (partition-table-type 'mbr) + (inherit mbr-disk-image) (name 'image.qcow2) (format 'compressed-qcow2)) <>)))) diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm index 0f4204d1a6..daa4647299 100644 --- a/gnu/tests/install.scm +++ b/gnu/tests/install.scm @@ -229,7 +229,7 @@ reboot\n") (gnu installer tests) (guix combinators)))) (uefi-support? #f) - (installation-image-type 'efi-raw) + (installation-image-type 'mbr-raw) (install-size 'guess) (target-size (* 2200 MiB)) (number-of-disks 1)) @@ -291,7 +291,7 @@ such as for RAID systems." '("-bios" #$uefi-firmware) '()) #$@(cond - ((eq? 'efi-raw installation-image-type) + ((eq? 'mbr-raw installation-image-type) #~("-drive" ,(string-append "file=" #$image ",if=virtio,readonly"))) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index acbe3dab2c..ec331809ef 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -1169,7 +1169,7 @@ Some ACTIONS support additional ARGS.\n")) (debug . 0) (verbosity . #f) ;default (validate-reconfigure . ,ensure-forward-reconfigure) - (image-type . efi-raw) + (image-type . mbr-raw) (image-size . guess) (install-bootloader? . #t) (label . #f) -- cgit v1.2.3