From d759ab692768553debe14d91bbcd882545f6656d Mon Sep 17 00:00:00 2001 From: Agus Lopez Date: Wed, 25 Oct 2017 16:29:04 +0200 Subject: [PATCH] Add submenu to look for bootable partitions Look for partitions in the current USB drive that have either some common boot files (e.g. GRUB, SYSLINUX, etc.) or an EFI binary. This can be used to boot a Windows installation CD by creating a partition and dumping the contents of the CD into it. --- mbusb.cfg | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/mbusb.cfg b/mbusb.cfg index 7e7bf29f..a7a0c6c1 100644 --- a/mbusb.cfg +++ b/mbusb.cfg @@ -1,7 +1,9 @@ # Partition holding files +regexp --set=rootdisk "^(.*),.*" "$root" +regexp --set=rootpartnum "^.*,.*([0-9]+)" "$root" probe -u $root --set=rootuuid set imgdevpath="/dev/disk/by-uuid/$rootuuid" -export imgdevpath rootuuid +export imgdevpath rootuuid rootdisk rootpartnum # Custom variables set isopath="/boot/isos" @@ -67,6 +69,18 @@ function search_files { } fi done + + if [ "x$grub_platform" == "xefi" ]; then + for efifile in /efi/boot/bootx64.efi; do + if [ -e "$efifile" ]; then + menuentry "EFI boot ($efifile)" "$efifile" { + efi_file="$2" + chainloader "$efi_file" + } + fi + done + fi + } # MultiBoot USB menu @@ -92,6 +106,22 @@ submenu "Multiboot ->" { done } + # Search partitions for boot files + submenu "Auto-detect bootable partitions ->" { + echo -n "Searching pendrive's partitions... " + for part in ($rootdisk,*); do + regexp --set=partnum "^.*,.*([0-9]+)" "$part" + if [ "$partnum" -le "$rootpartnum" ]; then continue; fi + submenu "$part ->" "$part" { + part_name="$2" + probe --fs-uuid $part_name --set=part_uuid + search --fs-uuid --no-floppy --hint=$part_name --set=root $part_uuid + # Look for boot files + search_files $root + } + done + } + # Search ISO files for boot files submenu "Auto-detect ISO's configfiles ->" { echo -n "Looking for ISO files... "