From 2e676d129355259b2400e09abf68ff907613a21a Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 14 Apr 2022 10:32:39 -0700 Subject: [PATCH] Add grub2 BIOS boot support to live iso template --- 80-rhel/live/config_files/x86/boot.msg | 5 - 80-rhel/live/config_files/x86/grub2-bios.cfg | 32 ++++++ 80-rhel/live/config_files/x86/isolinux.cfg | 100 ------------------- 80-rhel/live/efi.tmpl | 4 - 80-rhel/live/x86.tmpl | 50 +++++++--- 5 files changed, 67 insertions(+), 124 deletions(-) delete mode 100644 80-rhel/live/config_files/x86/boot.msg create mode 100644 80-rhel/live/config_files/x86/grub2-bios.cfg delete mode 100644 80-rhel/live/config_files/x86/isolinux.cfg diff --git a/80-rhel/live/config_files/x86/boot.msg b/80-rhel/live/config_files/x86/boot.msg deleted file mode 100644 index ff54899..0000000 --- a/80-rhel/live/config_files/x86/boot.msg +++ /dev/null @@ -1,5 +0,0 @@ - -splash.lss - - - Press the 0107 key to begin the installation process. - diff --git a/80-rhel/live/config_files/x86/grub2-bios.cfg b/80-rhel/live/config_files/x86/grub2-bios.cfg new file mode 100644 index 0000000..b1337c3 --- /dev/null +++ b/80-rhel/live/config_files/x86/grub2-bios.cfg @@ -0,0 +1,32 @@ +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 'Start @PRODUCT@ @VERSION@' --class fedora --class gnu-linux --class gnu --class os { + linux @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image quiet rhgb + initrd @INITRDPATH@ +} +menuentry 'Test this media & start @PRODUCT@ @VERSION@' --class fedora --class gnu-linux --class gnu --class os { + linux @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image rd.live.check quiet + initrd @INITRDPATH@ +} +submenu 'Troubleshooting -->' { + menuentry 'Start @PRODUCT@ @VERSION@ in basic graphics mode' --class fedora --class gnu-linux --class gnu --class os { + linux @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image nomodeset quiet rhgb + initrd @INITRDPATH@ + } +} diff --git a/80-rhel/live/config_files/x86/isolinux.cfg b/80-rhel/live/config_files/x86/isolinux.cfg deleted file mode 100644 index 324008a..0000000 --- a/80-rhel/live/config_files/x86/isolinux.cfg +++ /dev/null @@ -1,100 +0,0 @@ -default vesamenu.c32 -timeout 600 - -display boot.msg - -# Clear the screen when exiting the menu, instead of leaving the menu displayed. -# For vesamenu, this means the graphical background is still displayed without -# the menu itself for as long as the screen remains in graphics mode. -menu clear -menu background splash.png -menu title @PRODUCT@ @VERSION@ -menu vshift 8 -menu rows 18 -menu margin 8 -#menu hidden -menu helpmsgrow 15 -menu tabmsgrow 13 - -# Border Area -menu color border * #00000000 #00000000 none - -# Selected item -menu color sel 0 #ffffffff #00000000 none - -# Title bar -menu color title 0 #ff7ba3d0 #00000000 none - -# Press [Tab] message -menu color tabmsg 0 #ff3a6496 #00000000 none - -# Unselected menu item -menu color unsel 0 #84b8ffff #00000000 none - -# Selected hotkey -menu color hotsel 0 #84b8ffff #00000000 none - -# Unselected hotkey -menu color hotkey 0 #ffffffff #00000000 none - -# Help text -menu color help 0 #ffffffff #00000000 none - -# A scrollbar of some type? Not sure. -menu color scrollbar 0 #ffffffff #ff355594 none - -# Timeout msg -menu color timeout 0 #ffffffff #00000000 none -menu color timeout_msg 0 #ffffffff #00000000 none - -# Command prompt text -menu color cmdmark 0 #84b8ffff #00000000 none -menu color cmdline 0 #ffffffff #00000000 none - -# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message. - -menu tabmsg Press Tab for full configuration options on menu items. - -menu separator # insert an empty line -menu separator # insert an empty line - -label linux - menu label ^Start @PRODUCT@ @VERSION@ - kernel vmlinuz - append initrd=initrd.img @ROOT@ @EXTRA@ rd.live.image quiet - -label check - menu label Test this ^media & start @PRODUCT@ @VERSION@ - menu default - kernel vmlinuz - append initrd=initrd.img @ROOT@ @EXTRA@ rd.live.image rd.live.check quiet - -menu separator # insert an empty line - -# utilities submenu -menu begin ^Troubleshooting - menu title Troubleshooting - -label memtest - menu label Run a ^memory test - text help - If your system is having issues, a problem with your - system's memory may be the cause. Use this utility to - see if the memory is working correctly. - endtext - kernel memtest - -menu separator # insert an empty line - -label local - menu label Boot from ^local drive - localboot 0xffff - -menu separator # insert an empty line -menu separator # insert an empty line - -label returntomain - menu label Return to ^main menu - menu exit - -menu end diff --git a/80-rhel/live/efi.tmpl b/80-rhel/live/efi.tmpl index 42d18f4..8324c1d 100644 --- a/80-rhel/live/efi.tmpl +++ b/80-rhel/live/efi.tmpl @@ -21,9 +21,6 @@ install boot/grub2/fonts/unicode.pf2 ${EFIBOOTDIR}/fonts/ ## actually make the EFI images ${make_efiboot("images/efiboot.img")} -%if domacboot: - ${make_efiboot("images/macboot.img", imgtype="apple")} -%endif ## This is kinda gross, but then... so's EFI. <%def name="make_efiboot(img, include_kernel=False, disk=False, imgtype='default')"> @@ -32,7 +29,6 @@ ${make_efiboot("images/efiboot.img")} eficonf = "%s/grub.cfg" % (EFIBOOTDIR, ) args = "--label=ANACONDA" if disk: args += " --disk" - if imgtype == "apple": args += ' --apple --icon=%s --diskname=%s --product="%s %s"' % (APPLE_EFI_ICON, APPLE_EFI_DISKNAME, product.name, product.version) %> %if include_kernel: copy ${KERNELDIR}/vmlinuz ${EFIBOOTDIR} diff --git a/80-rhel/live/x86.tmpl b/80-rhel/live/x86.tmpl index 75d9aa9..84cd1e6 100644 --- a/80-rhel/live/x86.tmpl +++ b/80-rhel/live/x86.tmpl @@ -3,6 +3,7 @@ configdir="tmp/config_files/x86" PXEBOOTDIR="images/pxeboot" KERNELDIR=PXEBOOTDIR +GRUB2DIR="boot/grub2" LIVEDIR="LiveOS" LORAXDIR="usr/share/lorax/" @@ -44,6 +45,17 @@ mkdir ${KERNELDIR} treeinfo images-xen initrd ${KERNELDIR}/initrd.img %endif +## configure grub2 config file +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@ 'root=live:CDLABEL=${isolabel|udev}' ${GRUB2DIR}/grub.cfg +replace @EXTRA@ '${extra_boot_args}' ${GRUB2DIR}/grub.cfg + + ## WHeeeeeeee, EFI. <% efiargs=""; efigraft=""; efiarch32=None; efiarch64=None %> %if exists("boot/efi/EFI/*/gcdia32.efi"): @@ -53,19 +65,6 @@ mkdir ${KERNELDIR} <% efiarch64 = 'X64' %> %endif %if (efiarch32 or efiarch64) and basearch != 'i386': - <% - efigraft="EFI/BOOT={0}/EFI/BOOT".format(outroot) - images = [("images/efiboot.img", "-isohybrid-gpt-basdat")] - if domacboot: - images.append(("images/macboot.img", "-isohybrid-gpt-hfsplus")) - %> - %for img, hybrid in images: - <% - efiargs += " --efi-boot {0} {1}".format(img, hybrid) - efigraft += " {0}={1}/{0}".format(img,outroot) - %> - treeinfo images-${basearch} ${img|basename} ${img} - %endfor <%include file="efi.tmpl" args="configdir=configdir, KERNELDIR=KERNELDIR, efiarch32=efiarch32, efiarch64=efiarch64, isolabel=isolabel, extra_boot_args=extra_boot_args"/> %endif @@ -95,11 +94,32 @@ mkdir ${KERNELDIR} install ${f} ${LIVEDIR}/${f|basename} %endif +## 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 +treeinfo images-${basearch} eltorito.img images/eltorito.img + ## 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 \ ${KERNELDIR}=${outroot}/${KERNELDIR} \ ${LIVEDIR}=${outroot}/${LIVEDIR} \ - ${efigraft} ${filegraft} + ${filegraft} \ + ${GRUB2DIR}=${outroot}/${GRUB2DIR} \ + ${GRUB2DIR}/i386-pc=${inroot}/usr/lib/grub/i386-pc \ + images/eltorito.img=${outroot}/images/eltorito.img \ + EFI/BOOT=${outroot}/EFI/BOOT treeinfo images-${basearch} boot.iso images/boot.iso