From 9c99b11a822bef1d6443f59119104d5360d085ba Mon Sep 17 00:00:00 2001 From: Matthias Saou Date: Sun, 28 May 2023 13:04:13 +0200 Subject: [PATCH] iPXE simplified back to a single entry Easier to keep the .efi files inside the same iso tree. Add a note about what firmware to use with KVM. Fix the double empty lines after distro list. --- README.md | 2 ++ grub2/grub.cfg | 31 ++++++++------------------- grub2/inc-ipxe-efi.cfg | 17 --------------- grub2/inc-ipxe.cfg | 48 +++++++++++++++++++++++++++++------------- 4 files changed, 44 insertions(+), 54 deletions(-) delete mode 100644 grub2/inc-ipxe-efi.cfg diff --git a/README.md b/README.md index 6dcae33..8e51df4 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,8 @@ an IDE or SATA disk (for some reason, as USB disk didn't work for me on Fedora 17), that way you can easily and quickly test changes. Make sure you unmount the disk from the host OS before you start the KVM virtual machine that uses it. +For UEFI testing, you'll need to use one of the `/usr/share/edk2/ovmf/*.fd` +firmwares. Troubleshooting diff --git a/grub2/grub.cfg b/grub2/grub.cfg index 64a371a..16ffb4b 100644 --- a/grub2/grub.cfg +++ b/grub2/grub.cfg @@ -16,11 +16,9 @@ loadfont unicode insmod png set theme=${prefix}/themes/invader/theme.txt -set efipath=/EFI/BOOT set isopath=/boot/iso probe --set rootuuid --fs-uuid $root # Required to have these available in other configfile files -export efipath export isopath export rootuuid export theme @@ -160,6 +158,15 @@ for isofile in ${isopath}/grml/grml*.iso; do fi done +for isofile in ${isopath}/ipxe/ipxe*.iso ${isopath}/ipxe/ipxe*.efi; do + if [ -e "$isofile" ]; then + menuentry "iPXE >" --class net { + configfile "${prefix}/inc-ipxe.cfg" + } + break + fi +done + for isofile in ${isopath}/kali/kali-*.iso; do if [ -e "$isofile" ]; then menuentry "Kali >" --class kali { @@ -310,26 +317,6 @@ for isofile in ${isopath}/xubuntu/xubuntu-*.iso; do fi done -for isofile in ${isopath}/ipxe/ipxe*.iso; do - if [ -e "$isofile" ]; then - menuentry "iPXE >" --class net { - configfile "${prefix}/inc-ipxe.cfg" - } - break - fi -done - -if [ "${grub_platform}" = "efi" ]; then - for efifile in ${efipath}/ipxe/ipxe*.efi; do - if [ -e "$efifile" ]; then - menuentry "iPXE (EFI) >" --class net { - configfile "${prefix}/inc-ipxe-efi.cfg" - } - break - fi - done -fi - menuentry ' ' { # Empty line true } diff --git a/grub2/inc-ipxe-efi.cfg b/grub2/inc-ipxe-efi.cfg deleted file mode 100644 index a61c155..0000000 --- a/grub2/inc-ipxe-efi.cfg +++ /dev/null @@ -1,17 +0,0 @@ -# iPXE EFI: E.g. ipxe1.21.1.efi -for efifile in $efipath/ipxe/ipxe*.efi; do - if [ ! -e "$efifile" ]; then break; fi - regexp \ - --set 1:efiname \ - --set 2:version \ - "^${efipath}/ipxe/(ipxe(.*)?\.efi)\$" "${efifile}" - menuentry "iPXE ${version}" "${efifile}" "${efiname}" --class net { - set efifile=$2 - set efiname=$3 - echo "Using ${efiname}..." - insmod part_gpt - insmod chain - chainloader $efipath/ipxe/$efiname - } -done - diff --git a/grub2/inc-ipxe.cfg b/grub2/inc-ipxe.cfg index 06d764b..20d2a0b 100644 --- a/grub2/inc-ipxe.cfg +++ b/grub2/inc-ipxe.cfg @@ -1,15 +1,33 @@ -# iPXE -for isofile in $isopath/ipxe/ipxe*.iso; do - if [ ! -e "$isofile" ]; then break; fi - regexp \ - --set 1:isoname \ - --set 2:version \ - "^${isopath}/ipxe/(ipxe(.*)?\.iso)\$" "${isofile}" - menuentry "iPXE ${version}" "${isofile}" "${isoname}" --class net { - set isofile=$2 - set isoname=$3 - echo "Using ${isoname}..." - loop $isofile - linux (loop)/ipxe.lkrn - } -done \ No newline at end of file +# iPXE .iso "DOS magic is invalid." on EFI, so use special .efi +if [ "${grub_platform}" != "efi" ]; then + for isofile in $isopath/ipxe/ipxe*.iso; do + if [ ! -e "$isofile" ]; then break; fi + regexp \ + --set 1:isoname \ + --set 2:version \ + "^${isopath}/ipxe/(ipxe(.*)?\.iso)\$" "${isofile}" + menuentry "iPXE (iso) ${version}" "${isofile}" "${isoname}" --class net { + set isofile=$2 + set isoname=$3 + echo "Using ${isoname}..." + loop $isofile + linux (loop)/ipxe.lkrn + } + done +else + for efifile in $isopath/ipxe/ipxe*.efi; do + if [ ! -e "$efifile" ]; then break; fi + regexp \ + --set 1:efiname \ + --set 2:version \ + "^${isopath}/ipxe/(ipxe(.*)?\.efi)\$" "${efifile}" + menuentry "iPXE (efi) ${version}" "${efifile}" "${efiname}" --class net { + set efifile=$2 + set efiname=$3 + echo "Using ${efiname}..." + insmod part_gpt + insmod chain + chainloader $isopath/ipxe/$efiname + } + done +fi