From 79365921800b676d4d607585a48e6a90937c30bc Mon Sep 17 00:00:00 2001 From: Agus Lopez Date: Wed, 25 Oct 2017 16:25:35 +0200 Subject: [PATCH 1/5] Use submenu to boot ISO files Put the option to boot a supported ISO/kernel file in a submenu. --- mbusb.cfg | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mbusb.cfg b/mbusb.cfg index 346df545..091756b9 100644 --- a/mbusb.cfg +++ b/mbusb.cfg @@ -18,6 +18,7 @@ fi # MultiBoot USB menu submenu "Multiboot ->" { + # Warning for 32-bit systems if ! cpuid -l; then clear @@ -30,9 +31,12 @@ submenu "Multiboot ->" { echo fi - # Load configuration files - echo -n "Loading configuration files... " - for cfgfile in $prefix/mbusb.d/*.d/*.cfg; do - source "$cfgfile" - done + # Load configuration for ISO/kernel files + submenu "Boot supported ISO/kernel files ->" { + echo -n "Loading configuration files... " + for cfgfile in $prefix/mbusb.d/*.d/*.cfg; do + source "$cfgfile" + done + } + } From afdb139d3118f041b10d926112760fbd277db23e Mon Sep 17 00:00:00 2001 From: Agus Lopez Date: Wed, 25 Oct 2017 16:26:08 +0200 Subject: [PATCH 2/5] Add submenu to use MEMDISK with ISO files For each available ISO file, show a menu entry to boot it using MEMDISK. --- mbusb.cfg | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mbusb.cfg b/mbusb.cfg index 091756b9..ffc7e5d0 100644 --- a/mbusb.cfg +++ b/mbusb.cfg @@ -39,4 +39,33 @@ submenu "Multiboot ->" { done } + # Use MEMDISK to load ISO files + submenu "Use MEMDISK to boot ISO files ->" { + echo -n "Looking for ISO files... " + for isofile in $isopath/*.iso; do + if [ -e "$isofile" ]; then + regexp --set=isoname "$isopath/(.*)" "$isofile" + menuentry "$isoname" "$isofile" { + iso_path="$2" + bootoptions="iso raw" + linux16 $prefix/memdisk $bootoptions + initrd16 $iso_path + } + fi + done + echo + echo -n "Looking for ISO files... " + for imgfile in $isopath/*.img; do + if [ -e "$imgfile" ]; then + regexp --set=imgname "$isopath/(.*)" "$imgfile" + menuentry "$imgname" "$imgfile" { + img_path="$2" + bootoptions="raw" + linux16 $prefix/memdisk $bootoptions + initrd16 $img_path + } + fi + done + } + } From 48b0873d627d6326acd3ccb3cf32c8b407b28a55 Mon Sep 17 00:00:00 2001 From: Agus Lopez Date: Wed, 25 Oct 2017 16:27:19 +0200 Subject: [PATCH 3/5] Add submenu to look for some boot files For each available ISO file, mount it and look for some common boot files (e.g. GRUB, SYSLINUX, etc.) and show menu entries for each one of those. This can be used to test unsupported ISO files. --- mbusb.cfg | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/mbusb.cfg b/mbusb.cfg index ffc7e5d0..7e7bf29f 100644 --- a/mbusb.cfg +++ b/mbusb.cfg @@ -16,6 +16,59 @@ if [ -e "$prefix/mbusb.cfg.local" ]; then source "$prefix/mbusb.cfg.local" fi +# Function to look for boot files +function search_files { + root="$1" + + insmod bitmap + insmod jpeg + insmod png + insmod tga + + for grubfile in \ + /boot/grub/loopback.cfg \ + /boot/grub/grub.cfg \ + /boot/grub/x86_64-efi/grub.cfg \ + /EFI/BOOT/grub.cfg; do + if [ -e "$grubfile" ]; then + menuentry "GRUB boot ($grubfile)" "$grubfile" { + grub_file="$2" + configfile "$grub_file" + } + fi + done + + for syslinuxfile in \ + /isolinux.cfg \ + /syslinux.cfg \ + /isolinux/isolinux.cfg \ + /isolinux/syslinux.cfg \ + /syslinux/isolinux.cfg \ + /boot/isolinux.cfg \ + /boot/isolinux/isolinux.cfg \ + /boot/syslinux.cfg \ + /boot/syslinux/isolinux.cfg \ + /boot/syslinux/syslinux.cfg; do + if [ -e "$syslinuxfile" ]; then + menuentry "SYSLINUX boot ($syslinuxfile)" "$syslinuxfile" { + syslinux_file="$2" + syslinux_configfile -i "$syslinux_file" + } + fi + done + + for legacyfile in \ + /boot/grub/menu.lst \ + /menu.lst; do + if [ -e "$legacyfile" ]; then + menuentry "GRUB legacy boot ($legacyfile)" "$legacyfile" { + legacy_file="$2" + legacy_configfile "$legacy_file" + } + fi + done +} + # MultiBoot USB menu submenu "Multiboot ->" { @@ -39,6 +92,25 @@ submenu "Multiboot ->" { done } + # Search ISO files for boot files + submenu "Auto-detect ISO's configfiles ->" { + echo -n "Looking for ISO files... " + for isofile in $isopath/*.iso $isopath/*.img; do + if [ -e "$isofile" ]; then + regexp --set=isoname "$isopath/(.*)" "$isofile" + submenu "$isoname ->" "$isofile" { + iso_path="$2" + export iso_path + search --set=root --file "$iso_path" + loopback loop "$iso_path" + root=(loop) + # Look for boot files + search_files $root + } + fi + done + } + # Use MEMDISK to load ISO files submenu "Use MEMDISK to boot ISO files ->" { echo -n "Looking for ISO files... " From d759ab692768553debe14d91bbcd882545f6656d Mon Sep 17 00:00:00 2001 From: Agus Lopez Date: Wed, 25 Oct 2017 16:29:04 +0200 Subject: [PATCH 4/5] 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... " From 9ae32a73ae120bc1698d56ea6ee7e0e9cf81cd1d Mon Sep 17 00:00:00 2001 From: Mark Furland Date: Mon, 26 Mar 2018 19:07:57 -0400 Subject: [PATCH 5/5] Find win7 partition; explain if can't find configfile If someone uses "Auto-detect ISO's configfiles" or "Auto-detect bootable partitions" and it doesn't find anything it just blinks and is confusing, so this shows a message and waits 5 seconds. This also searches for `/efi/microsoft/boot/bootdmgfw.efi` which should be the efi boot file for a windows 7 installer. --- mbusb.cfg | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mbusb.cfg b/mbusb.cfg index a7a0c6c1..579b4a1d 100644 --- a/mbusb.cfg +++ b/mbusb.cfg @@ -21,6 +21,7 @@ fi # Function to look for boot files function search_files { root="$1" + found="" insmod bitmap insmod jpeg @@ -33,6 +34,7 @@ function search_files { /boot/grub/x86_64-efi/grub.cfg \ /EFI/BOOT/grub.cfg; do if [ -e "$grubfile" ]; then + found="found" menuentry "GRUB boot ($grubfile)" "$grubfile" { grub_file="$2" configfile "$grub_file" @@ -52,6 +54,7 @@ function search_files { /boot/syslinux/isolinux.cfg \ /boot/syslinux/syslinux.cfg; do if [ -e "$syslinuxfile" ]; then + found="found" menuentry "SYSLINUX boot ($syslinuxfile)" "$syslinuxfile" { syslinux_file="$2" syslinux_configfile -i "$syslinux_file" @@ -63,6 +66,7 @@ function search_files { /boot/grub/menu.lst \ /menu.lst; do if [ -e "$legacyfile" ]; then + found="found" menuentry "GRUB legacy boot ($legacyfile)" "$legacyfile" { legacy_file="$2" legacy_configfile "$legacy_file" @@ -71,8 +75,11 @@ function search_files { done if [ "x$grub_platform" == "xefi" ]; then - for efifile in /efi/boot/bootx64.efi; do + for efifile in \ + /efi/boot/bootx64.efi \ + /efi/microsoft/boot/bootmgfw.efi; do if [ -e "$efifile" ]; then + found="found" menuentry "EFI boot ($efifile)" "$efifile" { efi_file="$2" chainloader "$efi_file" @@ -80,6 +87,10 @@ function search_files { fi done fi + if [ "x$found" == "x" ]; then + echo "no bootable things found on $root" + sleep -v -i 5 + fi }