x86/boot: modernize genimage script; hdimage+EFI support
H. Peter Anvin (Intel)
reviewerPATCH v3 1/1 x86/boot: modernize genimage script; hdimage+EFI support
The image generation scripts in arch/x86/boot are pretty out of date, except for the isoimage target. Update and clean up the genimage.sh script, and make it support an arbitrary number of initramfs files in the image.
Add a "hdimage" target, which can be booted by either BIOS or EFI (if the kernel is compiled with the EFI stub.) For EFI to be able to pass the command line to the kernel, we need the EFI shell, but the firmware builtin EFI shell, if it even exists, is pretty much always the last resort boot option, so search for OVMF or EDK2 and explicitly include a copy of the EFI shell.
To make this all work, use bash features in the script. Furthermore, this version of the script makes use of some mtools features, especially mpartition, that might not exist in very old version of mtools, but given all the other dependencies on this script this doesn't seem such a big deal.
Finally, put a volume label ("LINUX_BOOT") on all generated images.
---
Version 3:
* Add LINUX_BOOT label to generated images
* Do not bundle with modules.img generation (not x86 specific)
arch/x86/Makefile | 5 +- arch/x86/boot/.gitignore | 1 + arch/x86/boot/Makefile | 44 ++--- arch/x86/boot/genimage.sh | 303 +++++++++++++++++++++++++---------- arch/x86/boot/mtools.conf.in | 3 + 5 files changed, 252 insertions(+), 104 deletions(-)
arch/x86/Makefile +3 -2
@@ -247,7 +247,7 @@ drivers-$(CONFIG_FB) += arch/x86/video/ boot := arch/x86/boot -BOOT_TARGETS = bzdisk fdimage fdimage144 fdimage288 isoimage +BOOT_TARGETS = bzdisk fdimage fdimage144 fdimage288 hdimage isoimage PHONY += bzImage $(BOOT_TARGETS)
@@ -305,8 +305,9 @@ define archhelp echo ' fdimage - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)' echo ' fdimage144 - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)' echo ' fdimage288 - Create 2.8MB boot floppy image (arch/x86/boot/fdimage)' + echo ' hdimage - Create a BIOS/EFI hard disk image (arch/x86/boot/hdimage)' echo ' isoimage - Create a boot CD-ROM image (arch/x86/boot/image.iso)' - echo ' bzdisk/fdimage*/isoimage also accept:' + echo ' bzdisk/fdimage*/hdimage/isoimage also accept:' echo ' FDARGS="..." arguments for the booted kernel' echo ' FDINITRD=file initrd for the booted kernel' echo ''
arch/x86/boot/.gitignore +1 -0
@@ -11,3 +11,4 @@ setup.elf fdimage mtools.conf image.iso +hdimage
arch/x86/boot/Makefile +23 -21
77 lines not on this page · raw message
arch/x86/boot/genimage.sh +222 -81
346 lines not on this page · raw message
arch/x86/boot/mtools.conf.in +3 -0
@@ -14,4 +14,7 @@ drive v: drive w: file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=36 filter +# Hard disk +drive h: + file="@OBJ@/hdimage" partition=1 mformat_only
Signature · 1 line
2.31.1
[tip: x86/boot] x86/boot: Modernize genimage script; hdimage+EFI support
The following commit has been merged into the x86/boot branch of tip:
The following commit has been merged into the x86/boot branch of tip:
Commit-ID: f279b49f13bd2151bbe402a1d812c1e3646c4bbb Gitweb: https://git.kernel.org/tip/f279b49f13bd2151bbe402a1d812c1e3646c4bbb Author: H. Peter Anvin (Intel) <[email protected]> AuthorDate: Mon, 10 May 2021 01:28:40 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Mon, 10 May 2021 12:27:50 +02:00
x86/boot: Modernize genimage script; hdimage+EFI support
The image generation scripts in arch/x86/boot are pretty out of date, except for the isoimage target. Update and clean up the genimage.sh script, and make it support an arbitrary number of initramfs files in the image.
Add a "hdimage" target, which can be booted by either BIOS or EFI (if the kernel is compiled with the EFI stub.) For EFI to be able to pass the command line to the kernel, we need the EFI shell, but the firmware builtin EFI shell, if it even exists, is pretty much always the last resort boot option, so search for OVMF or EDK2 and explicitly include a copy of the EFI shell.
To make this all work, use bash features in the script. Furthermore, this version of the script makes use of some mtools features, especially mpartition, that might not exist in very old version of mtools, but given all the other dependencies on this script this doesn't seem such a big deal.
Finally, put a volume label ("LINUX_BOOT") on all generated images.
--- arch/x86/Makefile | 5 +- arch/x86/boot/.gitignore | 1 +- arch/x86/boot/Makefile | 44 ++--- arch/x86/boot/genimage.sh | 303 ++++++++++++++++++++++++---------- arch/x86/boot/mtools.conf.in | 3 +- 5 files changed, 252 insertions(+), 104 deletions(-)
arch/x86/Makefile +3 -2
@@ -256,7 +256,7 @@ drivers-$(CONFIG_FB) += arch/x86/video/ boot := arch/x86/boot -BOOT_TARGETS = bzdisk fdimage fdimage144 fdimage288 isoimage +BOOT_TARGETS = bzdisk fdimage fdimage144 fdimage288 hdimage isoimage PHONY += bzImage $(BOOT_TARGETS)
@@ -314,8 +314,9 @@ define archhelp echo ' fdimage - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)' echo ' fdimage144 - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)' echo ' fdimage288 - Create 2.8MB boot floppy image (arch/x86/boot/fdimage)' + echo ' hdimage - Create a BIOS/EFI hard disk image (arch/x86/boot/hdimage)' echo ' isoimage - Create a boot CD-ROM image (arch/x86/boot/image.iso)' - echo ' bzdisk/fdimage*/isoimage also accept:' + echo ' bzdisk/fdimage*/hdimage/isoimage also accept:' echo ' FDARGS="..." arguments for the booted kernel' echo ' FDINITRD=file initrd for the booted kernel' echo ''
arch/x86/boot/.gitignore +1 -0
@@ -11,3 +11,4 @@ setup.elf fdimage mtools.conf image.iso +hdimage
arch/x86/boot/Makefile +23 -21
77 lines not on this page · raw message
arch/x86/boot/genimage.sh +222 -81
346 lines not on this page · raw message
arch/x86/boot/mtools.conf.in +3 -0
@@ -14,4 +14,7 @@ drive v: drive w: file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=36 filter +# Hard disk +drive h: + file="@OBJ@/hdimage" partition=1 mformat_only