Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
Add submenu to look for bootable partitions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aguslr committed Oct 26, 2017
1 parent 48b0873 commit d759ab6
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion mbusb.cfg
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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... "
Expand Down

0 comments on commit d759ab6

Please sign in to comment.