From 6e71bd423937ba510ee85c123d1f42b174d53cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Cr=C3=A9gut?= Date: Sun, 26 Jul 2020 18:51:35 +0200 Subject: [PATCH] Makes EFI images bootable by bios For Bios and EFI compatibility, grub must be installed twice. This patch adds the bios version when EFI is selected. The GPT EFI block partitioning already adds the bios partition, but the bootloader only called grub once. Change-Id: Iee6c8b3b97b3cfff4562bcb30a50800f5ade894a Closes-Bug: #1889089 --- .../elements/bootloader/finalise.d/50-bootloader | 3 +++ diskimage_builder/elements/bootloader/pkg-map | 6 +++--- releasenotes/notes/efi-bios-images-052283eabba98b90.yaml | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/efi-bios-images-052283eabba98b90.yaml diff --git a/diskimage_builder/elements/bootloader/finalise.d/50-bootloader b/diskimage_builder/elements/bootloader/finalise.d/50-bootloader index 26b861b8..88de8d89 100755 --- a/diskimage_builder/elements/bootloader/finalise.d/50-bootloader +++ b/diskimage_builder/elements/bootloader/finalise.d/50-bootloader @@ -150,6 +150,9 @@ function install_grub2 { case $ARCH in "x86_64"|"amd64") GRUB_OPTS="--target=x86_64-efi" + # This call installs grub for BIOS compatability + # which makes portable EFI/BIOS images. + $GRUBNAME --modules="$modules" --target=i386-pc $BOOT_DEV ;; # At this point, we don't need to override the target # for any other architectures. diff --git a/diskimage_builder/elements/bootloader/pkg-map b/diskimage_builder/elements/bootloader/pkg-map index 5b34f155..e2e933d8 100644 --- a/diskimage_builder/elements/bootloader/pkg-map +++ b/diskimage_builder/elements/bootloader/pkg-map @@ -4,7 +4,7 @@ "8": { "extlinux": "syslinux-extlinux", "grub-pc": "grub2-tools grub2", - "grub-efi-amd64": "grub2-tools grub2-efi-x64 grub2-efi-x64-modules", + "grub-efi-amd64": "grub2-tools grub2-pc grub2-efi-x64 grub2-efi-x64-modules", "grub-efi-arm64": "grub2-tools grub2-efi-aa64 grub2-efi-aa64-modules", "grub-efi-aarch64": "grub2-tools grub2-efi-aa64 grub2-efi-aa64-modules", "grub-efi": "grub2-tools grub2-efi", @@ -29,7 +29,7 @@ "redhat": { "extlinux": "syslinux-extlinux", "grub-pc": "grub2-tools grub2", - "grub-efi-amd64": "grub2-tools grub2-efi-x64 grub2-efi-x64-modules", + "grub-efi-amd64": "grub2-tools grub2-pc grub2-efi-x64 grub2-efi-x64-modules", "grub-efi-arm64": "grub2-tools grub2-efi-aa64 grub2-efi-aa64-modules", "grub-efi-aarch64": "grub2-tools grub2-efi-aa64 grub2-efi-aa64-modules", "grub-efi": "grub2-tools grub2-efi", @@ -40,7 +40,7 @@ "dkms_package": "dkms", "extlinux": "extlinux", "grub-pc": "grub-pc", - "grub-efi-amd64": "grub-efi", + "grub-efi-amd64": "grub-efi grub-pc-bin", "grub-efi-arm64": "grub-efi-arm64", "grub-ppc64": "grub-ieee1275" } diff --git a/releasenotes/notes/efi-bios-images-052283eabba98b90.yaml b/releasenotes/notes/efi-bios-images-052283eabba98b90.yaml new file mode 100644 index 00000000..c1ac11bc --- /dev/null +++ b/releasenotes/notes/efi-bios-images-052283eabba98b90.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + The ``bootloader`` element now co-installs a BIOS bootloader for + x86-64 when ``DIB_BLOCK_DEVICE=efi`` is set. This makes images + that are EFI and BIOS cross-compatiable.