forked from Mexit/MultiOS-USB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrub.config
259 lines (224 loc) · 5.69 KB
/
grub.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# MultiOS-USB main config file
# https://gitlab.com/MultiOS-USB
# https://github.com/Mexit/MultiOS-USB
# Load modules
insmod fat
insmod ntfs
insmod udf
insmod part_msdos
insmod part_gpt
insmod regexp
insmod font
if [ "${grub_platform}" == "efi" ]; then
# Unload modules
rmmod tpm
fi
regexp -s dev '^(.*),' "$root"
probe --fs-uuid $root --set=rootuuid
set imgdevpath="/dev/disk/by-uuid/$rootuuid"
set pager=1
set iso_dir="/ISOs"
set theme_path="/MultiOS-USB/themes/MultiOS-USB/theme.txt"
export dev rootuuid imgdevpath iso_dir
if [ -e "$theme_path" ]; then
set theme="$theme_path"
export theme
fi
if loadfont unicode; then
if [ "${grub_platform}" == "efi" ]; then
set gfxmode=auto
insmod efi_gop
insmod efi_uga
else
insmod vbe
insmod vga
set gfxmode="1280x800;1280x720;1024x768;auto"
set gfxpayload="1920x1080;1600x1200;1600x1050;1600x900;1440x900;1366x768;1280x1024;1280x800;1280x720;1024x768;auto"
fi
insmod all_video
insmod gfxterm
insmod gfxmenu
insmod png
export gfxmode gfxpayload
terminal_output gfxterm
fi
function find_grub_cfg {
submenu "Detect GRUB config file (grub.cfg) -->" {
grubcfg_found=false
insmod ext2
insmod xfs
insmod zfs
insmod btrfs
insmod jfs
insmod reiserfs
for grubcfg in (*,*)/boot/grub*/grub.cfg (lvm\/*)/boot/grub*/grub.cfg; do
regexp --set=1:grubcfg_device '^\((.*)\)/' "${grubcfg}"
if [ -f "${grubcfg}" ]; then
grubcfg_found=true
menuentry --class=linux "Boot Linux from: ${grubcfg}" "${grubcfg}" "${grubcfg_device}" {
root="(${3})"
configfile "${2}"
}
fi
done
if [ "${grubcfg_found}" != true ]; then
menuentry "GRUB configuration files (grub.cfg) not found..." { false }
fi
}
}
function LOOPBACK {
if [ -e (loop) ]; then
loopback --delete loop
fi
loopback loop "$1"
}
submenu "Auto-detect ISOs (Directory: $iso_dir) -->" {
echo -n "Loading configuration files... "
for cfgfile in /MultiOS-USB/config/*/*.cfg /MultiOS-USB/config_priv/*/*.cfg; do
source "$cfgfile"
done
}
if [ "${grub_platform}" == "pc" ]; then
submenu "Tools -->" {
submenu "Detect Windows Boot Manager -->" {
bootmgr_found=false
for bootmgr in (*,*)/bootmgr; do
regexp --set=1:bootmgr_device '^\((.*)\)/' "${bootmgr}"
if [ -f "${bootmgr}" ]; then
bootmgr_found=true
insmod ntldr
menuentry --class=windows "Windows Boot Manager on (${bootmgr_device})" "${bootmgr_device}" {
root="(${2})"
ntldr "(${2})/bootmgr"
}
fi
done
if [ "${bootmgr_found}" != true ]; then
menuentry "Windows Boot Manager not found." { false }
fi
}
# Menu: boot from GRUB config file
find_grub_cfg
file="/MultiOS-USB/tools/mt86plus_*/memtest64.bin"
if [ -f ${file} ]; then
menuentry "Memtest86+" {
linux16 ${file}
}
fi
menuentry "Boot from 1st Hard Disk" {
set root=(hd1)
chainloader +1
}
menuentry "Boot from 2nd Hard Disk" {
set root=(hd2)
chainloader +1
}
menuentry "Boot from 3rd Hard Disk" {
set root=(hd3)
chainloader +1
}
}
fi
if [ "${grub_platform}" == "efi" ]; then
submenu "EFI Tools -->" {
menuentry "Reboot to UEFI Firmware Setup" {
fwsetup
}
if [ -f ($dev,1)/efi/boot/mmx64.efi ]; then
menuentry --class=efi "Add UEFI key or hash" {
chainloader ($dev,1)/efi/boot/mmx64.efi
}
fi
if [ -f /MultiOS-USB/tools/efitools-*/KeyTool.efi ]; then
menuentry --class=efi "Manage UEFI keys and hashes" {
chainloader /MultiOS-USB/tools/efitools-*/KeyTool.efi
}
fi
submenu "Detect EFI bootloaders -->" {
efi_found=false
for efi in (*,*)/efi/*/*/*.efi (*,*)/efi/*/*.efi (*,*)/efi/*.efi; do
regexp --set=1:efi_device '^\((.*)\)/' "${efi}"
if [ -f "${efi}" ]; then
efi_found=true
if [ ${efi} == (${efi_device})/efi/Microsoft/Boot/bootmgfw.efi ]; then
menuentry --class=efi "Windows Boot Manager on (${efi_device})" "${efi_device}" {
root="(${2})"
chainloader "(${2})/efi/Microsoft/Boot/bootmgfw.efi"
}
else
menuentry --class=efi "${efi}" "${efi_device}" {
root="(${2})"
chainloader "${1}"
}
fi
fi
done
if [ "${efi_found}" != true ]; then
menuentry "No EFI files detected." { false }
fi
}
# Menu: boot from GRUB config file
find_grub_cfg
file="/MultiOS-USB/tools/mt86plus_*/memtest64.efi"
if [ -f ${file} ]; then
menuentry --class=efi "Memtest86+ EFI" {
chainloader ${file}
}
fi
}
submenu "Network bootable OS installers (DHCP) -->" {
if net_bootp; then
source /MultiOS-USB/config/grub_netboot/main.cfgnet
else
echo -e "\n\nIf your network card is not detected,"
echo -e "check the BIOS/UEFI settings to see"
echo -e "if PXE/network card booting is enabled.\n"
fi
}
fi
submenu "GRUB2 options -->" {
menuentry "Set terminal output to console" {
terminal_output console
}
menuentry "Set terminal output to gfxterm" {
terminal_output gfxterm
}
menuentry "List devices/partitions" {
ls -l
sleep --interruptible 9999
}
menuentry "Enable GRUB2's LVM support" {
insmod lvm
}
menuentry "Enable GRUB2's RAID support" {
insmod dm_nv
insmod mdraid09_be
insmod mdraid09
insmod mdraid1x
insmod raid5rec
insmod raid6rec
}
menuentry "Enable GRUB2's PATA support (to work around BIOS bugs/limitations)" {
insmod ata
update_paths
}
menuentry "Enable GRUB2's USB support *experimental*" {
insmod ohci
insmod uhci
insmod usbms
update_paths
}
menuentry "Mount encrypted volumes (LUKS and geli)" {
insmod luks
insmod luks2
insmod geli
cryptomount -a
}
menuentry "Enable serial terminal" {
serial
terminal_input --append serial
terminal_output --append serial
}
}
menuentry "Reboot (r)" --hotkey=r --class reboot { reboot }
menuentry "Power Off (p)" --hotkey=p --class shutdown { halt }