Add grub2 BIOS boot support

This adds support for BIOS booting using grub2. The bios config file and
grub2 modules are under /boot/grub2/

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
This commit is contained in:
Brian C. Lane 2022-06-16 16:52:00 -04:00 committed by Stephen Gallagher
parent d554033dc9
commit 12c0368018
No known key found for this signature in database
GPG Key ID: 45DB85A568286D11
7 changed files with 84 additions and 41 deletions

View File

@ -1,13 +0,0 @@
#debug --graphics
default=0
splashimage=@SPLASHPATH@
timeout 5
hiddenmenu
title Install @PRODUCT@ @VERSION@
findiso
kernel @KERNELPATH@ @ROOT@ quiet
initrd @INITRDPATH@
title Test this media & install @PRODUCT@ @VERSION@
findiso
kernel @KERNELPATH@ @ROOT@ rd.live.check quiet
initrd @INITRDPATH@

View File

@ -1,13 +0,0 @@
#debug --graphics
default=1
splashimage=@SPLASHPATH@
timeout 60
hiddenmenu
title Install @PRODUCT@ @VERSION@
findiso
kernel @KERNELPATH@ @ROOT@ quiet
initrd @INITRDPATH@
title Test this media & install @PRODUCT@ @VERSION@
findiso
kernel @KERNELPATH@ @ROOT@ rd.live.check quiet
initrd @INITRDPATH@

View File

@ -0,0 +1,36 @@
set default="1"
function load_video {
insmod all_video
}
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set timeout=60
### END /etc/grub.d/00_header ###
search --no-floppy --set=root -l '@ISOLABEL@'
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Install @PRODUCT@ @VERSION@' --class fedora --class gnu-linux --class gnu --class os {
linux @KERNELPATH@ @ROOT@ quiet
initrd @INITRDPATH@
}
menuentry 'Test this media & install @PRODUCT@ @VERSION@' --class fedora --class gnu-linux --class gnu --class os {
linux @KERNELPATH@ @ROOT@ rd.live.check quiet
initrd @INITRDPATH@
}
submenu 'Troubleshooting -->' {
menuentry 'Install @PRODUCT@ @VERSION@ in basic graphics mode' --class fedora --class gnu-linux --class gnu --class os {
linux @KERNELPATH@ @ROOT@ nomodeset quiet
initrd @INITRDPATH@
}
menuentry 'Rescue a @PRODUCT@ system' --class fedora --class gnu-linux --class gnu --class os {
linux @KERNELPATH@ @ROOT@ inst.rescue quiet
initrd @INITRDPATH@
}
}

View File

@ -1,13 +0,0 @@
#debug --graphics
default=1
splashimage=@SPLASHPATH@
timeout 60
hiddenmenu
title Start @PRODUCT@ @VERSION@
findiso
kernel @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image quiet
initrd @INITRDPATH@
title Test this media & start @PRODUCT@ @VERSION@
findiso
kernel @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image rd.live.check quiet
initrd @INITRDPATH@

View File

@ -19,6 +19,7 @@
%if basearch in ("i386", "x86_64"):
installpkg biosdevname memtest86+
installpkg grub2-tools grub2-tools-minimal grub2-tools-extra
installpkg grub2-pc-modules
%endif
%if basearch in ("ppc64le"):
installpkg powerpc-utils

View File

@ -50,6 +50,7 @@ installpkg glibc-all-langpacks
%if basearch in ("i386", "x86_64"):
installpkg biosdevname memtest86+
installpkg grub2-tools grub2-tools-minimal grub2-tools-extra
installpkg grub2-pc-modules
%endif
%if basearch in ("ppc", "ppc64", "ppc64le"):
installpkg powerpc-utils lsvpd ppc64-diag

View File

@ -4,6 +4,7 @@ configdir="tmp/config_files/x86"
SYSLINUXDIR="usr/share/syslinux"
PXEBOOTDIR="images/pxeboot"
STAGE2IMG="images/install.img"
GRUB2DIR="boot/grub2"
BOOTDIR="isolinux"
KERNELDIR=PXEBOOTDIR
LORAXDIR="usr/share/lorax/"
@ -25,10 +26,27 @@ else:
isoargs = ""
%>
## configure grub2
mkdir ${GRUB2DIR}
install ${configdir}/grub2-bios.cfg ${GRUB2DIR}/grub.cfg
replace @VERSION@ ${product.version} ${GRUB2DIR}/grub.cfg
replace @PRODUCT@ '${product.name}' ${GRUB2DIR}/grub.cfg
replace @KERNELPATH@ /${KERNELDIR}/vmlinuz ${GRUB2DIR}/grub.cfg
replace @INITRDPATH@ /${KERNELDIR}/initrd.img ${GRUB2DIR}/grub.cfg
replace @ROOT@ 'inst.stage2=hd:LABEL=${isolabel|udev}' ${GRUB2DIR}/grub.cfg
mkdir images
install ${runtime_img} ${STAGE2IMG}
treeinfo stage2 mainimage images/${runtime_base}
## BIOS setup
<%
biosgraft = "boot=${outroot}/boot"
biosgraft += " ${GRUB2DIR}/i386-pc=${inroot}/usr/lib/grub/i386-pc"
biosgraft += " images/eltorito.img=${outroot}/images/eltorito.img"
%>
treeinfo images-${basearch} eltorito.img images/eltorito.img
## install kernels
mkdir ${KERNELDIR}
%for kernel in kernels:
@ -48,6 +66,16 @@ mkdir ${KERNELDIR}
treeinfo images-xen initrd ${KERNELDIR}/initrd.img
%endif
## BIOS setup
<%
biosgraft = "boot=${outroot}/boot"
biosgraft += " ${GRUB2DIR}/i386-pc=${inroot}/usr/lib/grub/i386-pc"
biosgraft += " images/eltorito.img=${outroot}/images/eltorito.img"
%>
treeinfo images-${basearch} eltorito.img images/eltorito.img
## WHeeeeeeee, EFI.
<% efiargs=""; efigraft=""; efiarch32=None; efiarch64=None %>
%if exists("boot/efi/EFI/*/gcdia32.efi"):
@ -100,12 +128,28 @@ mkdir ${KERNELDIR}
<% filegraft += " {0}={1}/{0}".format(basename(f), outroot) %>
%endfor
+## Make images/eltoritio.img
runcmd grub2-mkimage -O i386-pc-eltorito -d ${inroot}/usr/lib/grub/i386-pc \
-o ${outroot}/images/eltorito.img \
-p /${GRUB2DIR} \
iso9660 biosdisk
## make boot.iso
runcmd xorrisofs ${isoargs} -o ${outroot}/images/boot.iso \
${efiargs} -R -J -V '${isolabel}' \
-R -J -V '${isolabel}' \
--grub2-mbr ${inroot}/usr/lib/grub/i386-pc/boot_hybrid.img \
-partition_offset 16 \
-appended_part_as_gpt \
-append_partition 2 C12A7328-F81F-11D2-BA4B-00A0C93EC93B ${outroot}/images/efiboot.img \
-iso_mbr_part_type EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 \
-c boot.cat --boot-catalog-hide \
-b images/eltorito.img \
-no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info \
-eltorito-alt-boot \
-e '--interval:appended_partition_2:all::' -no-emul-boot \
-graft-points \
.discinfo=${outroot}/.discinfo \
${STAGE2IMG}=${outroot}/${STAGE2IMG} \
${KERNELDIR}=${outroot}/${KERNELDIR} \
${efigraft} ${filegraft}
${biosgraft} ${efigraft} ${filegraft}
treeinfo images-${basearch} boot.iso images/boot.iso