forked from netbootxyz/netboot.xyz-custom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
osdetect.cfg
524 lines (469 loc) · 16.3 KB
/
osdetect.cfg
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# Super Grub Disk - osdetect.cfg
# Copyright (C) 2009,2010,2011,2012,2013,2014,2015 Adrian Gibanel Lopez.
#
# Super Grub Disk is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Super Grub Disk is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the imp# Super Grub Disk - osdetect.cfg
# Copyright (C) 2009,2010,2011,2012,2013,2014,2015 Adrian Gibanel Lopez.
#
# Super Grub Disk is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Super Grub Disk is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Super Grub Disk. If not, see <http://www.gnu.org/licenses/>.
set option_title=$"Operating Systems"
function freebsd_ufs_variants {
set device="$1"
set fstype="$2"
set uuid="$3"
menuentry "${finaloption_tab_str}FreeBSD ($fstype $device)" $device $uuid {
set root="$2"
set uuid="$3"
kfreebsd /boot/kernel/kernel
set kFreeBSD.acpi_load=YES
set kFreeBSD.hint.acpi.0.disabled=0
set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
kfreebsd_loadenv /boot/device.hints
}
menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (single)" $device $uuid {
set root="$2"
set uuid="$3"
kfreebsd /boot/kernel/kernel -s
set kFreeBSD.acpi_load=YES
set kFreeBSD.hint.acpi.0.disabled=0
set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
kfreebsd_loadenv /boot/device.hints
}
menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (verbose)" $device $uuid {
set root="$2"
set uuid="$3"
kfreebsd /boot/kernel/kernel -v
set kFreeBSD.acpi_load=YES
set kFreeBSD.hint.acpi.0.disabled=0
set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
kfreebsd_loadenv /boot/device.hints
}
menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (no ACPI)" $device $uuid {
set root="$2"
set uuid="$3"
kfreebsd /boot/kernel/kernel -v
unset kFreeBSD.acpi_load
set kFreeBSD.hint.acpi.0.disabled=1
set kFreeBSD.loader.acpi_disabled_by_user=1
set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
kfreebsd_loadenv /boot/device.hints
}
menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (safe mode)" $device $uuid {
set root="$2"
set uuid="$3"
kfreebsd /boot/kernel/kernel -v
unset kFreeBSD.acpi_load
set kFreeBSD.hint.acpi.0.disabled=1
set kFreeBSD.loader.acpi_disabled_by_user=1
set kFreeBSD.hint.apic.0.disabled=1
set kFreeBSD.hw.ata.ata_dma=0
set kFreeBSD.hw.ata.atapi_dma=0
set kFreeBSD.hw.ata.wc=0
set kFreeBSD.hw.eisa_slots=0
set kFreeBSD.hint.kbdmux.0.disabled=1
set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
kfreebsd_loadenv /boot/device.hints
}
menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (Default boot loader)" $device $uuid {
set root="$2"
kfreebsd /boot/loader
}
}
function freebsd_zfs_variants {
set device="$1"
set fstype=zfs
menuentry "${finaloption_tab_str}FreeBSD ($fstype $device)" $device {
set root="$2"
kfreebsd /@/boot/kernel/kernel
set kFreeBSD.acpi_load=YES
set kFreeBSD.hint.acpi.0.disabled=0
kfreebsd_module_elf /@/boot/kernel/opensolaris.ko
kfreebsd_module_elf /@/boot/kernel/zfs.ko
kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
probe -l -s name $root
set kFreeBSD.vfs.root.mountfrom=zfs:$name
kfreebsd_loadenv /@/boot/device.hints
}
menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (single)" $device {
set root="$2"
kfreebsd /@/boot/kernel/kernel -s
set kFreeBSD.acpi_load=YES
set kFreeBSD.hint.acpi.0.disabled=0
kfreebsd_module_elf /@/boot/kernel/opensolaris.ko
kfreebsd_module_elf /@/boot/kernel/zfs.ko
kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
probe -l -s name $root
set kFreeBSD.vfs.root.mountfrom=zfs:$name
kfreebsd_loadenv /@/boot/device.hints
}
menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (verbose)" $device {
set root="$2"
kfreebsd /@/boot/kernel/kernel -v
set kFreeBSD.acpi_load=YES
set kFreeBSD.hint.acpi.0.disabled=0
kfreebsd_module_elf /@/boot/kernel/opensolaris.ko
kfreebsd_module_elf /@/boot/kernel/zfs.ko
kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
probe -l -s name $root
set kFreeBSD.vfs.root.mountfrom=zfs:$name
kfreebsd_loadenv /@/boot/device.hints
}
menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (no ACPI)" $device {
set root="$2"
kfreebsd /@/boot/kernel/kernel -v
unset kFreeBSD.acpi_load
set kFreeBSD.hint.acpi.0.disabled=1
set kFreeBSD.loader.acpi_disabled_by_user=1
kfreebsd_module_elf /@/boot/kernel/opensolaris.ko
kfreebsd_module_elf /@/boot/kernel/zfs.ko
kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
probe -l -s name $root
set kFreeBSD.vfs.root.mountfrom=zfs:$name
kfreebsd_loadenv /@/boot/device.hints
}
menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (safe mode)" $device {
set root="$2"
kfreebsd /@/boot/kernel/kernel -v
unset kFreeBSD.acpi_load
set kFreeBSD.hint.acpi.0.disabled=1
set kFreeBSD.loader.acpi_disabled_by_user=1
set kFreeBSD.hint.apic.0.disabled=1
set kFreeBSD.hw.ata.ata_dma=0
set kFreeBSD.hw.ata.atapi_dma=0
set kFreeBSD.hw.ata.wc=0
set kFreeBSD.hw.eisa_slots=0
set kFreeBSD.hint.kbdmux.0.disabled=1
kfreebsd_module_elf /@/boot/kernel/opensolaris.ko
kfreebsd_module_elf /@/boot/kernel/zfs.ko
kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
probe -l -s name $root
set kFreeBSD.vfs.root.mountfrom=zfs:$name
kfreebsd_loadenv /@/boot/device.hints
}
menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (Default boot loader)" $device $uuid {
set root="$2"
kfreebsd /@/boot/loader
}
}
function get_efis {
blockdev="$1"
blockfs="$2"
efis=""
if [ "$blockfs" = "fat" ]; then
insmod regexp
for efi in \
($blockdev)/efi/*/*.efi \
($blockdev)/efi/*/*/*.efi \
($blockdev)/*.efi \
($blockdev)/*/*.efi \
($blockdev)/EFI/*/*.EFI \
($blockdev)/EFI/*/*/*.EFI \
($blockdev)/*.EFI \
($blockdev)/*/*.EFI \
($blockdev)/EFI/*/*.efi \
($blockdev)/EFI/*/*/*.efi \
($blockdev)/efi/*/*.EFI \
($blockdev)/efi/*/*/*.EFI \
; do
if [ -f "$efi" ] ; then
efis="$efis $efi"
fi
done
rmmod regexp
if [ -n "$efis" ]; then
return 0
fi
fi
return 1
}
function osx_entry_add {
set device="$1"
set uuid="$2"
set kerncmd="$3"
set arch="$4"
set args="$5"
set desc="$6"
menuentry "${finaloption_tab_str}Mac OS X/Darwin $arch-bit ($device) - $desc" $device $uuid $kerncmd $args {
set root="$2"
set uuid="$3"
set kerncmd="$4"
set args="$5"
insmod all_video
set do_resume=0
if [ /var/vm/sleepimage -nt10 / ]; then
if xnu_resume /var/vm/sleepimage; then
set do_resume=1
fi
fi
if [ $do_resume = 0 ]; then
xnu_uuid ${uuid} uuid
if [ -f /Extra/DSDT.aml ]; then
acpi -e /Extra/DSDT.aml
fi
if [ /kernelcache -nt /System/Library/Extensions ]; then
$kerncmd /kernelcache boot-uuid=${uuid} rd=*uuid $args
else
$kerncmd /mach_kernel boot-uuid=${uuid} rd=*uuid $args
if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
xnu_mkext /System/Library/Extensions.mkext
else
xnu_kextdir /System/Library/Extensions
fi
fi
if [ -f /Extra/Extensions.mkext ]; then
xnu_mkext /Extra/Extensions.mkext
fi
if [ -d /Extra/Extensions ]; then
xnu_kextdir /Extra/Extensions
fi
if [ -f /Extra/devprop.bin ]; then
xnu_devprop_load /Extra/devprop.bin
fi
if [ -f /Extra/splash.jpg ]; then
insmod jpeg
xnu_splash /Extra/splash.jpg
fi
if [ -f /Extra/splash.png ]; then
insmod png
xnu_splash /Extra/splash.png
fi
if [ -f /Extra/splash.tga ]; then
insmod tga
xnu_splash /Extra/splash.tga
fi
fi
}
}
function linux_entry_add {
set fstype="$1"
set device="$2"
set uuid="$3"
set kernel="$4"
set subvol="$5"
set bootdir="$6"
set version="$7"
set kernel_option="$8"
if test "$kernel_option" = ""; then
set kernel_option_str=" "
else
set kernel_option_str=" (${kernel_option}) "
fi
menuentry "${finaloption_tab_str} Linux ${kernel}${kernel_option_str}($device)" $device $uuid $kernel $version $fstype $subvol $bootdir $kernel_option {
set root="$2"
set uuid="$3"
set kernel="$4"
set version="$5"
set fstype="$6"
set subvol="$7"
set bootdir="$8"
set kernel_option="$9"
if test $fstype = "btrfs" -a $subvol != "/" ;then
linux $kernel root=UUID=$uuid ro rootflags=subvol=$subvol ${kernel_option}
else
linux $kernel root=UUID=$uuid ro ${kernel_option}
fi
for initrd_file in \
${bootdir}/initrd-$version.img \
${bootdir}/initrd.img-$version \
${bootdir}/initrd-$version \
${bootdir}/initramfs-genkernel-$version \
${bootdir}/initramfs-$version.img \
; do
if test -f $initrd_file; then
initrd $initrd_file
break
fi
done
}
}
function flagplatform {
sgdflagplat=""
if [ "$1" = "efi" ]; then
if [ "${grub_platform}" = "efi" ]; then
return 0
else
sgdflagplat=$"UEFI-BOOT-REQUIRED:"
fi
else
if [ "${grub_platform}" != "efi" ]; then
return 0
else
sgdflagplat=$"BIOS-BOOT-REQUIRED:"
fi
fi
}
function run_option {
source "${sg2d_directory}/tools.cfg"
set saved_root=$root
update_sg2d_devices
for dev in ${sg2d_devices}; do
getdevice device $dev
# $fstype: filesystem type identified
probe -s fstype -f $dev
# uuid: filesystem UUID
probe -s uuid -u $dev
if test -f ($device)/bootmgr ; then
for bootdir in boot Boot BOOT ;do
if test \
-f ($device)/$bootdir/bcd \
-o \
-f ($device)/$bootdir/Bcd \
-o \
-f ($device)/$bootdir/BCD \
; then
flagplatform bios
menuentry "${finaloption_tab_str}${sgdflagplat}Windows Vista/7/8/2008 (R2) ... ($device)" $device {
if withplatform bios ; then
set root="$2"
chainloader +1
fi
}
flagplatform bios
menuentry "${finaloption_tab_str}${sgdflagplat}Windows Vista/7/8/2008 (R2) (Direct /bootmgr) ... ($device)" $device {
if withplatform bios ; then
set root="$2"
ntldr /bootmgr
fi
}
break
fi
done
elif test \
'(' -f ($device)/ntldr -o -f ($device)/NTLDR ')' \
-a \
'(' -e ($device)/ntdetect.com -o -e ($device)/NTDETECT.COM ')' \
-a \
'(' -f ($device)/boot.ini -o -f ($device)/BOOT.INI ')' \
; then
flagplatform bios
menuentry "${finaloption_tab_str}${sgdflagplat}Windows NT/2000/XP ($device)" $device {
if withplatform bios ; then
set root="$2"
insmod regexp
regexp -s devnum 'hd([0-9]+)' $root
rmmod regexp
if test "$devnum" != "0"; then
drivemap -s hd0 $root
fi
chainloader +1
fi
}
flagplatform bios
menuentry "${finaloption_tab_str}${sgdflagplat}Windows NT/2000/XP (Direct /ntldr) ($device)" $device {
if withplatform bios ; then
ntldr /ntldr
fi
}
elif test -f ($device)/windows/win.com; then
flagplatform bios
menuentry "${finaloption_tab_str}${sgdflagplat}Windows 98/ME ($device)" $device {
if withplatform bios ; then
set root="$2"
insmod regexp
regexp -s devnum 'hd([0-9]+)' $root
rmmod regexp
if test "$devnum" != "0"; then
drivemap -s hd0 $root
fi
chainloader +1
fi
}
elif test -f ($device)/io.sys -a -f ($device)/command.com; then
flagplatform bios
menuentry "${finaloption_tab_str}${sgdflagplat}MS-DOS ($device)" $device {
if withplatform bios ; then
set root="$2"
insmod regexp
regexp -s devnum 'hd([0-9]+)' $root
rmmod regexp
if test "$devnum" != "0"; then
drivemap -s hd0 $root
fi
chainloader +1
fi
}
elif test -f ($device)/kernel.sys; then
flagplatform bios
menuentry "${finaloption_tab_str}${sgdflagplat}FreeDOS ($device)" $device {
if withplatform bios ; then
set root="$2"
insmod regexp
regexp -s type '([fh])d[0-9]+' $root
regexp -s devnum '[fh]d([0-9]+)' $root
rmmod regexp
if test $type = 'h' -a "$devnum" != "0"; then
drivemap -s hd0 $root
fi
chainloader +1
fi
}
elif test "$fstype" = ufs1 -o "$fstype" = ufs2 -a \
-e ($device)/boot/kernel/kernel -a \
-e ($device)/boot/device.hints; then
freebsd_ufs_variants $device $fstype $uuid
elif test "$fstype" = zfs -a \
-e ($device)/@/boot/kernel/kernel -a \
-e ($device)/@/boot/device.hints; then
freebsd_zfs_variants $device
elif test "$fstype" = hfsplus -a -f ($device)/mach_kernel -a -d ($device)/Users; then
osx_entry_add $device $uuid "xnu_kernel" "32" "-v" "Verbose Mode"
osx_entry_add $device $uuid "xnu_kernel" "32" "-x" "Safe Mode"
osx_entry_add $device $uuid "xnu_kernel" "32" "-s" "Single User"
osx_entry_add $device $uuid "xnu_kernel" "32" "-f" "Ignore Caches"
osx_entry_add $device $uuid "xnu_kernel64" "64" "-v" "Verbose Mode"
osx_entry_add $device $uuid "xnu_kernel64" "64" "-x" "Safe Mode"
osx_entry_add $device $uuid "xnu_kernel64" "64" "-s" "Single User"
osx_entry_add $device $uuid "xnu_kernel64" "64" "-f" "Ignore Caches"
elif get_efis $device $fstype; then
flagplatform efi
for efi in $efis; do
menuentry "${finaloption_tab_str}${sgdflagplat}${efi} ($device)" "$efi" "$device" {
efi_device="$3"
efi="$2"
if withplatform efi; then
root="$efi_device"
chainloader "$efi"
fi
}
done
else
set root=$device
insmod regexp
for subvol in / /@*;do
if test $subvol = "/" -o ( $fstype = "btrfs" -a -d $subvol) ;then
if test $subvol = "/" ;then
set bootdir=/boot
else
set bootdir="${subvol}/boot"
fi
for file in $bootdir/vmlinuz-* $bootdir/linux-* $bootdir/kernel-genkernel-*; do
if test -f $file; then
regexp -s 1:bootdir -s 4:version '((|/@.*)/boot)/(vmlinuz|linux|kernel-genkernel)-(.*)' $file
linux_entry_add $fstype $device $uuid $file $subvol $bootdir $version ""
linux_entry_add $fstype $device $uuid $file $subvol $bootdir $version "recovery"
linux_entry_add $fstype $device $uuid $file $subvol $bootdir $version "single"
fi
done
fi
done
rmmod regexp
fi
done
set root=$saved_root
}