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

Commit d759ab6

Browse files
committed
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.
1 parent 48b0873 commit d759ab6

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

mbusb.cfg

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Partition holding files
2+
regexp --set=rootdisk "^(.*),.*" "$root"
3+
regexp --set=rootpartnum "^.*,.*([0-9]+)" "$root"
24
probe -u $root --set=rootuuid
35
set imgdevpath="/dev/disk/by-uuid/$rootuuid"
4-
export imgdevpath rootuuid
6+
export imgdevpath rootuuid rootdisk rootpartnum
57

68
# Custom variables
79
set isopath="/boot/isos"
@@ -67,6 +69,18 @@ function search_files {
6769
}
6870
fi
6971
done
72+
73+
if [ "x$grub_platform" == "xefi" ]; then
74+
for efifile in /efi/boot/bootx64.efi; do
75+
if [ -e "$efifile" ]; then
76+
menuentry "EFI boot ($efifile)" "$efifile" {
77+
efi_file="$2"
78+
chainloader "$efi_file"
79+
}
80+
fi
81+
done
82+
fi
83+
7084
}
7185

7286
# MultiBoot USB menu
@@ -92,6 +106,22 @@ submenu "Multiboot ->" {
92106
done
93107
}
94108

109+
# Search partitions for boot files
110+
submenu "Auto-detect bootable partitions ->" {
111+
echo -n "Searching pendrive's partitions... "
112+
for part in ($rootdisk,*); do
113+
regexp --set=partnum "^.*,.*([0-9]+)" "$part"
114+
if [ "$partnum" -le "$rootpartnum" ]; then continue; fi
115+
submenu "$part ->" "$part" {
116+
part_name="$2"
117+
probe --fs-uuid $part_name --set=part_uuid
118+
search --fs-uuid --no-floppy --hint=$part_name --set=root $part_uuid
119+
# Look for boot files
120+
search_files $root
121+
}
122+
done
123+
}
124+
95125
# Search ISO files for boot files
96126
submenu "Auto-detect ISO's configfiles ->" {
97127
echo -n "Looking for ISO files... "

0 commit comments

Comments
 (0)