summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2023-09-09 17:57:25 +0200
committerMathieu Othacehe <othacehe@gnu.org>2023-09-20 09:38:36 +0200
commite5ed1712da049b1c3dcf01e0a7e02e48a8aff012 (patch)
treef03647099e8b3ad67267c180ecfb2edc602921bb
parent00a1ee15cdc046708d2df35d3854156da14fcbb9 (diff)
image: Introduce the mbr-hybrid-raw image type.
Until 209204e23b39af09e0ea92540b6fa00a60e6a0ae and d57cab764122af69d52d8cc9c843456044e5d7bc, the default image type used by "guix system image" was an MBR image with an ESP partition. Having both an MBR image and an ESP partition is handy because the image will boot on most x86 based systems using legacy BIOS and/or UEFI. We now have a distinction between MBR images and EFI images. Introduce a new MBR hybrid image type and default to it to restore the default behaviour. This also fixes the images section of (gnu ci) that was trying to install a BIOS bootloader on an EFI, GPT image and failing to do so. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
-rw-r--r--doc/guix.texi34
-rw-r--r--gnu/ci.scm2
-rw-r--r--gnu/system/image.scm14
-rw-r--r--guix/scripts/system.scm2
4 files changed, 43 insertions, 9 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 50c4984d718..617b8463e34 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -40982,8 +40982,8 @@ QEMU monitor and the VM.
40982@cindex image, creating disk images 40982@cindex image, creating disk images
40983The @code{image} command can produce various image types. The image 40983The @code{image} command can produce various image types. The image
40984type can be selected using the @option{--image-type} option. It 40984type can be selected using the @option{--image-type} option. It
40985defaults to @code{mbr-raw}. When its value is @code{iso9660}, the 40985defaults to @code{mbr-hybrid-raw}. When its value is @code{iso9660},
40986@option{--label} option can be used to specify a volume ID with 40986the @option{--label} option can be used to specify a volume ID with
40987@code{image}. By default, the root file system of a disk image is 40987@code{image}. By default, the root file system of a disk image is
40988mounted non-volatile; the @option{--volatile} option can be provided to 40988mounted non-volatile; the @option{--volatile} option can be provided to
40989make it volatile instead. When using @code{image}, the bootloader 40989make it volatile instead. When using @code{image}, the bootloader
@@ -41001,8 +41001,8 @@ qemu-system-x86_64 -enable-kvm -hda /tmp/my-image.qcow2 -m 1000 \
41001 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin 41001 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin
41002@end example 41002@end example
41003 41003
41004When using the @code{mbr-raw} image type, a raw disk image is produced; 41004When using the @code{mbr-hybrid-raw} image type, a raw disk image is
41005it can be copied as is to a USB stick, for instance. Assuming 41005produced; it can be copied as is to a USB stick, for instance. Assuming
41006@code{/dev/sdc} is the device corresponding to a USB stick, one can copy 41006@code{/dev/sdc} is the device corresponding to a USB stick, one can copy
41007the image to it using the following command: 41007the image to it using the following command:
41008 41008
@@ -41139,7 +41139,7 @@ of the image.
41139For the @code{image} action, create an image with given @var{type}. 41139For the @code{image} action, create an image with given @var{type}.
41140 41140
41141When this option is omitted, @command{guix system} uses the 41141When this option is omitted, @command{guix system} uses the
41142@code{mbr-raw} image type. 41142@code{mbr-hybrid-raw} image type.
41143 41143
41144@cindex ISO-9660 format 41144@cindex ISO-9660 format
41145@cindex CD image format 41145@cindex CD image format
@@ -45347,7 +45347,7 @@ then directly boot from it, without any kind of installation procedure.
45347 45347
45348The @command{guix system image} command is able to turn an operating 45348The @command{guix system image} command is able to turn an operating
45349system definition into a bootable image. This command supports 45349system definition into a bootable image. This command supports
45350different image types, such as @code{mbr-raw}, @code{iso9660} and 45350different image types, such as @code{mbr-hybrid-raw}, @code{iso9660} and
45351@code{docker}. Any modern @code{x86_64} machine will probably be able 45351@code{docker}. Any modern @code{x86_64} machine will probably be able
45352to boot from an @code{iso9660} image. However, there are a few machines 45352to boot from an @code{iso9660} image. However, there are a few machines
45353out there that require specific image types. Those machines, in general 45353out there that require specific image types. Those machines, in general
@@ -45611,8 +45611,24 @@ from them to simplify the @code{image} definition. The @code{(gnu
45611system image)} module provides the following @code{image} definition 45611system image)} module provides the following @code{image} definition
45612variables. 45612variables.
45613 45613
45614@defvar mbr-disk-image
45615An MBR disk-image composed of a single ROOT partition. The ROOT
45616partition starts at a 1@tie{}MiB offset so that the bootloader can
45617install itself in the post-MBR gap.
45618@end defvar
45619
45620@defvar mbr-hybrid-disk-image
45621An MBR disk-image composed of two partitions: a 64 bits ESP partition
45622and a ROOT boot partition. The ESP partition starts at a 1@tie{}MiB
45623offset so that a BIOS compatible bootloader can install itself in the
45624post-MBR gap. The image can be used by @code{x86_64} and @code{i686}
45625machines supporting only legacy BIOS booting. The ESP partition ensures
45626that it can also be used by newer machines relying on UEFI booting,
45627hence the @emph{hybrid} denomination.
45628@end defvar
45629
45614@defvar efi-disk-image 45630@defvar efi-disk-image
45615A MBR disk-image composed of two partitions: a 64 bits ESP partition and 45631A GPT disk-image composed of two partitions: a 64 bits ESP partition and
45616a ROOT boot partition. This image can be used on most @code{x86_64} and 45632a ROOT boot partition. This image can be used on most @code{x86_64} and
45617@code{i686} machines, supporting BIOS or UEFI booting. 45633@code{i686} machines, supporting BIOS or UEFI booting.
45618@end defvar 45634@end defvar
@@ -45703,6 +45719,10 @@ system image)} and the @code{(gnu system images @dots{})} modules.
45703Build an image based on the @code{mbr-disk-image} image. 45719Build an image based on the @code{mbr-disk-image} image.
45704@end defvar 45720@end defvar
45705 45721
45722@defvar mbr-hybrid-raw-image-type
45723Build an image based on the @code{mbr-hybrid-disk-image} image.
45724@end defvar
45725
45706@defvar efi-raw-image-type 45726@defvar efi-raw-image-type
45707Build an image based on the @code{efi-disk-image} image. 45727Build an image based on the @code{efi-disk-image} image.
45708@end defvar 45728@end defvar
diff --git a/gnu/ci.scm b/gnu/ci.scm
index 520ac281101..279dd4d9100 100644
--- a/gnu/ci.scm
+++ b/gnu/ci.scm
@@ -268,7 +268,7 @@ otherwise use the IMAGE name."
268 (if (member system %guix-system-supported-systems) 268 (if (member system %guix-system-supported-systems)
269 `(,(image->job store 269 `(,(image->job store
270 (image 270 (image
271 (inherit efi-disk-image) 271 (inherit mbr-hybrid-disk-image)
272 (operating-system installation-os)) 272 (operating-system installation-os))
273 #:name "usb-image" 273 #:name "usb-image"
274 #:system system) 274 #:system system)
diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index 5b8da2f8965..b1b928b222c 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -77,6 +77,7 @@
77 root-partition 77 root-partition
78 78
79 mbr-disk-image 79 mbr-disk-image
80 mbr-hybrid-disk-image
80 efi-disk-image 81 efi-disk-image
81 iso9660-image 82 iso9660-image
82 docker-image 83 docker-image
@@ -86,6 +87,7 @@
86 87
87 image-with-os 88 image-with-os
88 mbr-raw-image-type 89 mbr-raw-image-type
90 mbr-hybrid-raw-image-type
89 efi-raw-image-type 91 efi-raw-image-type
90 efi32-raw-image-type 92 efi32-raw-image-type
91 qcow2-image-type 93 qcow2-image-type
@@ -156,6 +158,13 @@ parent image record."
156 (inherit root-partition) 158 (inherit root-partition)
157 (offset root-offset)))))) 159 (offset root-offset))))))
158 160
161(define mbr-hybrid-disk-image
162 (image-without-os
163 (format 'disk-image)
164 (partition-table-type 'mbr)
165 (partitions
166 (list esp-partition root-partition))))
167
159(define efi-disk-image 168(define efi-disk-image
160 (image-without-os 169 (image-without-os
161 (format 'disk-image) 170 (format 'disk-image)
@@ -217,6 +226,11 @@ set to the given OS."
217 (name 'mbr-raw) 226 (name 'mbr-raw)
218 (constructor (cut image-with-os mbr-disk-image <>)))) 227 (constructor (cut image-with-os mbr-disk-image <>))))
219 228
229(define mbr-hybrid-raw-image-type
230 (image-type
231 (name 'mbr-hybrid-raw)
232 (constructor (cut image-with-os mbr-hybrid-disk-image <>))))
233
220(define efi-raw-image-type 234(define efi-raw-image-type
221 (image-type 235 (image-type
222 (name 'efi-raw) 236 (name 'efi-raw)
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index ec331809ef6..547387d5e14 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -1169,7 +1169,7 @@ Some ACTIONS support additional ARGS.\n"))
1169 (debug . 0) 1169 (debug . 0)
1170 (verbosity . #f) ;default 1170 (verbosity . #f) ;default
1171 (validate-reconfigure . ,ensure-forward-reconfigure) 1171 (validate-reconfigure . ,ensure-forward-reconfigure)
1172 (image-type . mbr-raw) 1172 (image-type . mbr-hybrid-raw)
1173 (image-size . guess) 1173 (image-size . guess)
1174 (install-bootloader? . #t) 1174 (install-bootloader? . #t)
1175 (label . #f) 1175 (label . #f)