]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/grub/grub.cfg
Fix the issue when booting latest systemrescue
[Ventoy.git] / INSTALL / grub / grub.cfg
1 #************************************************************************************
2 # Copyright (c) 2020, longpanda <admin@ventoy.net>
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, see <http://www.gnu.org/licenses/>.
16 #
17 #************************************************************************************
18
19 function ventoy_pause {
20 echo "press Enter to continue ......"
21 read vtTmpPause
22 }
23
24 function ventoy_debug_pause {
25 if [ -n "${vtdebug_flag}" ]; then
26 echo "press Enter to continue ......"
27 read vtTmpPause
28 fi
29 }
30
31 function ventoy_cli_console {
32 if [ -z "$vtoy_display_mode" ]; then
33 terminal_output console
34 elif [ "$vtoy_display_mode" = "GUI" ]; then
35 terminal_output console
36 fi
37 }
38
39 function ventoy_gui_console {
40 if [ -z "$vtoy_display_mode" ]; then
41 terminal_output gfxterm
42 elif [ "$vtoy_display_mode" = "GUI" ]; then
43 terminal_output gfxterm
44 fi
45 }
46
47 function ventoy_acpi_param {
48 if [ "$VTOY_PARAM_NO_ACPI" != "1" ]; then
49 vt_acpi_param "$1" "$2"
50 fi
51 }
52
53 function ventoy_vcfg_proc {
54 if vt_check_custom_boot "${1}" vt_vcfg; then
55 set vtoy_chosen_path="${1}"
56 vt_file_basefile "${vtoy_chosen_path}" vtoy_chosen_file
57
58 export vtoy_chosen_path
59 export vtoy_chosen_file
60 ventoy_debug_pause
61 configfile "${vtoy_iso_part}${vt_vcfg}"
62 true
63 else
64 false
65 fi
66 }
67
68 function ventoy_power {
69 configfile $prefix/power.cfg
70 }
71
72 function ventoy_diagnosis {
73 vt_enum_video_mode
74 configfile $prefix/debug.cfg
75 }
76
77 function ventoy_localboot {
78 configfile $prefix/localboot.cfg
79 }
80
81 function ventoy_ext_menu {
82 if [ -e $vt_plugin_path/ventoy/ventoy_grub.cfg ]; then
83 set ventoy_new_context=1
84 configfile $vt_plugin_path/ventoy/ventoy_grub.cfg
85 unset ventoy_new_context
86 else
87 echo "ventoy_grub.cfg NOT exist."
88 echo -e "\npress ENTER to exit ..."
89 read vtInputKey
90 fi
91 }
92
93 function ventoy_checksum {
94 if [ -f "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}" ]; then
95 configfile $prefix/checksum.cfg
96 fi
97 }
98
99 function ventoy_show_help {
100 if [ -f $prefix/help.tar.gz ]; then
101 if [ -z "$vtoy_help_txt_mem_addr" ]; then
102 vt_load_file_to_mem "auto" $prefix/help.tar.gz vtoy_help_txt_mem
103 fi
104
105 loopback vt_help_tarfs mem:${vtoy_help_txt_mem_addr}:size:${vtoy_help_txt_mem_size}
106 if [ -f "(vt_help_tarfs)/help/${VTOY_HELP_TXT_LANGUAGE}.txt" ]; then
107 cat "(vt_help_tarfs)/help/${VTOY_HELP_TXT_LANGUAGE}.txt"
108 else
109 cat "(vt_help_tarfs)/help/en_US.txt"
110 fi
111 loopback -d vt_help_tarfs
112 fi
113 }
114
115 function get_os_type {
116 set vtoy_os=Linux
117
118 for file in "efi/microsoft/boot/bcd" "sources/boot.wim" "boot/bcd" "bootmgr.efi" "boot/etfsboot.com" ; do
119 if vt_file_exist_nocase (loop)/$file; then
120 set vtoy_os=Windows
121 break
122 fi
123 done
124
125 if [ "$vtoy_os" = "Linux" ]; then
126 if vt_strstr "$vt_system_id" "FreeBSD"; then
127 set vtoy_os=Unix
128 set vt_unix_type=FreeBSD
129 elif [ -e (loop)/bin/freebsd-version ]; then
130 set vtoy_os=Unix
131 set vt_unix_type=FreeBSD
132 elif [ -e (loop)/boot/kernel/geom_ventoy.ko ]; then
133 set vtoy_os=Unix
134 set vt_unix_type=FreeBSD
135 elif vt_str_begin "$vt_system_id" "DragonFly"; then
136 set vtoy_os=Unix
137 set vt_unix_type=DragonFly
138
139
140 elif [ -e (loop)/boot/kernel/kernel ]; then
141 if file --is-x86-kfreebsd (loop)/boot/kernel/kernel; then
142 set vtoy_os=Unix
143 set vt_unix_type=FreeBSD
144 elif file --is-x86-knetbsd (loop)/boot/kernel/kernel; then
145 set vtoy_os=Unix
146 set vt_unix_type=NetBSD
147 fi
148 fi
149 fi
150
151 if [ -n "${vtdebug_flag}" ]; then
152 echo ISO is "$vtoy_os"
153 fi
154 }
155
156 function vt_check_compatible_pe {
157 #Check for PE without external tools
158 #set compatible if ISO file is less than 80MB
159 if [ $vt_chosen_size -gt 33554432 -a $vt_chosen_size -le 83886080 ]; then
160 set ventoy_compatible=YES
161 fi
162
163 return
164 }
165
166 function vt_check_compatible_linux {
167 if vt_str_begin "$vt_volume_id" "embootkit"; then
168 set ventoy_compatible=YES
169 elif [ -e "$1/casper/tinycore.gz" ]; then
170 set ventoy_compatible=YES
171 fi
172
173 return
174 }
175
176 function locate_initrd {
177 vt_linux_locate_initrd
178
179 if [ -n "${vtdebug_flag}" ]; then
180 vt_linux_dump_initrd
181 ventoy_debug_pause
182 fi
183 }
184
185 function locate_wim {
186 vt_windows_locate_wim_patch (loop)
187
188 if [ -n "${vtdebug_flag}" ]; then
189 echo '###############################################'
190 vt_dump_wim_patch
191 echo '###############################################'
192 ventoy_debug_pause
193 fi
194 }
195
196 function distro_specify_wim_patch {
197 if [ -d (loop)/h3pe ]; then
198 vt_windows_collect_wim_patch wim /BOOT/H3_10PE.WIM
199 vt_windows_collect_wim_patch wim /BOOT/H3_7PE.WIM
200 vt_windows_collect_wim_patch wim /BOOT/H3_8PE.WIM
201 vt_windows_collect_wim_patch wim /BOOT/H3_81PE.WIM
202 elif [ -d (loop)/2k10/winpe ]; then
203 vt_windows_collect_wim_patch wim /2k10/winpe/w1086pe.wim
204 vt_windows_collect_wim_patch wim /2k10/winpe/w8x86pe.wim
205 vt_windows_collect_wim_patch wim /2k10/winpe/w7x86pe.wim
206 fi
207 }
208
209 function distro_specify_wim_patch_phase2 {
210 if [ -f (loop)/boot/boot.wim ]; then
211 vt_windows_collect_wim_patch wim /boot/boot.wim
212 fi
213 }
214
215
216 function distro_specify_initrd_file {
217 if [ -e (loop)/boot/all.rdz ]; then
218 vt_linux_specify_initrd_file /boot/all.rdz
219 elif [ -e (loop)/boot/xen.gz ]; then
220 if [ -e (loop)/install.img ]; then
221 vt_linux_specify_initrd_file /install.img
222 fi
223 elif [ -d (loop)/casper ]; then
224 if [ -e (loop)/casper/initrd ]; then
225 vt_linux_specify_initrd_file /casper/initrd
226 fi
227 if [ -e (loop)/casper/initrd.gz ]; then
228 vt_linux_specify_initrd_file /casper/initrd.gz
229 fi
230 if [ -e (loop)/casper/initrd-oem ]; then
231 vt_linux_specify_initrd_file /casper/initrd-oem
232 fi
233 elif [ -e (loop)/boot/grub/initrd.xz ]; then
234 vt_linux_specify_initrd_file /boot/grub/initrd.xz
235 elif [ -e (loop)/initrd.gz ]; then
236 vt_linux_specify_initrd_file /initrd.gz
237 elif [ -e (loop)/slax/boot/initrfs.img ]; then
238 vt_linux_specify_initrd_file /slax/boot/initrfs.img
239 elif [ -e (loop)/minios/boot/initrfs.img ]; then
240 vt_linux_specify_initrd_file /minios/boot/initrfs.img
241 elif [ -e (loop)/pmagic/initrd.img ]; then
242 vt_linux_specify_initrd_file /pmagic/initrd.img
243 elif [ -e (loop)/boot/initrd.xz ]; then
244 vt_linux_specify_initrd_file /boot/initrd.xz
245 elif [ -e (loop)/boot/initrd.gz ]; then
246 vt_linux_specify_initrd_file /boot/initrd.gz
247 elif [ -f (loop)/boot/initrd ]; then
248 vt_linux_specify_initrd_file /boot/initrd
249 elif [ -f (loop)/boot/x86_64/loader/initrd ]; then
250 vt_linux_specify_initrd_file /boot/x86_64/loader/initrd
251 elif [ -f (loop)/boot/initramfs-x86_64.img ]; then
252 vt_linux_specify_initrd_file /boot/initramfs-x86_64.img
253 elif [ -f (loop)/boot/isolinux/initramfs_data64.cpio.gz ]; then
254 vt_linux_specify_initrd_file /boot/isolinux/initramfs_data64.cpio.gz
255 elif [ -f (loop)/boot/initrd.img ]; then
256 vt_linux_specify_initrd_file /boot/initrd.img
257
258 fi
259
260 if [ -f (loop)/isolinux/initrd.gz ]; then
261 vt_linux_specify_initrd_file /isolinux/initrd.gz
262 fi
263
264 if [ "$vt_chosen_size" = "1133375488" ]; then
265 if [ -d (loop)/boot/grub/x86_64-efi ]; then
266 vt_cpio_busybox64 "64h"
267 fi
268 fi
269 }
270
271
272 function distro_specify_initrd_file_phase2 {
273 if [ -f (loop)/boot/initrd.img ]; then
274 vt_linux_specify_initrd_file /boot/initrd.img
275 elif [ -f (loop)/Setup/initrd.gz ]; then
276 vt_linux_specify_initrd_file /Setup/initrd.gz
277 elif [ -f (loop)/isolinux/initramfs ]; then
278 vt_linux_specify_initrd_file /isolinux/initramfs
279 elif [ -f (loop)/boot/iniramfs.igz ]; then
280 vt_linux_specify_initrd_file /boot/iniramfs.igz
281 elif [ -f (loop)/initrd-x86_64 ]; then
282 vt_linux_specify_initrd_file /initrd-x86_64
283 elif [ -f (loop)/live/initrd.img ]; then
284 vt_linux_specify_initrd_file /live/initrd.img
285 elif [ -f (loop)/initrd.img ]; then
286 vt_linux_specify_initrd_file /initrd.img
287 elif [ -f (loop)/sysresccd/boot/x86_64/sysresccd.img ]; then
288 vt_linux_specify_initrd_file /sysresccd/boot/x86_64/sysresccd.img
289 elif [ -f (loop)/CDlinux/initrd ]; then
290 vt_linux_specify_initrd_file /CDlinux/initrd
291 elif [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
292 vt_linux_specify_initrd_file /parabola/boot/x86_64/parabolaiso.img
293 if [ -f (loop)/parabola/boot/i686/parabolaiso.img ]; then
294 vt_linux_specify_initrd_file /parabola/boot/i686/parabolaiso.img
295 fi
296 elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then
297 vt_linux_specify_initrd_file /parabola/boot/x86_64/initramfs-linux-libre.img
298 if [ -f (loop)/parabola/boot/i686/initramfs-linux-libre.img ]; then
299 vt_linux_specify_initrd_file /parabola/boot/i686/initramfs-linux-libre.img
300 fi
301 elif [ -f (loop)/hyperbola/boot/x86_64/hyperiso.img ]; then
302 vt_linux_specify_initrd_file /hyperbola/boot/x86_64/hyperiso.img
303 if [ -f (loop)/hyperbola/boot/i686/hyperiso.img ]; then
304 vt_linux_specify_initrd_file /hyperbola/boot/i686/hyperiso.img
305 fi
306 elif [ -f (loop)/EFI/BOOT/initrd.img ]; then
307 #Qubes
308 vt_linux_specify_initrd_file /EFI/BOOT/initrd.img
309 if [ "$grub_platform" != "pc" ]; then
310 vt_add_replace_file 0 "initrd.img"
311 fi
312 elif [ -f (loop)/initrd ]; then
313 vt_linux_specify_initrd_file /initrd
314 elif [ -f (loop)/live/initrd1 ]; then
315 vt_linux_specify_initrd_file /live/initrd1
316 elif [ -f (loop)/isolinux/initrd.img ]; then
317 vt_linux_specify_initrd_file /isolinux/initrd.img
318 elif [ -f (loop)/isolinux/initrd.gz ]; then
319 vt_linux_specify_initrd_file /isolinux/initrd.gz
320 elif [ -f (loop)/syslinux/kernel/initramfs.gz ]; then
321 vt_linux_specify_initrd_file /syslinux/kernel/initramfs.gz
322 elif vt_strstr "$vt_volume_id" "Daphile"; then
323 vt_linux_parse_initrd_isolinux (loop)/isolinux/
324 elif [ -f (loop)/boot/rootfs.xz ]; then
325 vt_linux_specify_initrd_file /boot/rootfs.xz
326 if [ "$grub_platform" != "pc" ]; then
327 vt_add_replace_file 0 "minimal\\x86_64\\rootfs.xz"
328 fi
329 elif [ -f (loop)/arch/boot/x86_64/archiso.img ]; then
330 vt_linux_specify_initrd_file /arch/boot/x86_64/archiso.img
331 if [ "$grub_platform" != "pc" ]; then
332 vt_add_replace_file 0 "EFI\\archiso\\archiso.img"
333 fi
334 elif [ -f (loop)/blackarch/boot/x86_64/archiso.img ]; then
335 vt_linux_specify_initrd_file /blackarch/boot/x86_64/archiso.img
336 elif [ -f (loop)/blackarch/boot/x86_64/initramfs-linux.img ]; then
337 vt_linux_specify_initrd_file /blackarch/boot/x86_64/initramfs-linux.img
338
339 elif [ -f (loop)/install.amd/initrd.gz ]; then
340 vt_linux_specify_initrd_file /live/initrd2.img
341 vt_linux_specify_initrd_file /install.amd/initrd.gz
342 vt_linux_specify_initrd_file /install.amd/gtk/initrd.gz
343 elif [ -f (loop)/boot/grub/kernels.cfg ]; then
344 vt_linux_parse_initrd_grub file (loop)/boot/grub/kernels.cfg
345 elif [ -f (loop)/austrumi/initrd.gz ]; then
346 vt_linux_specify_initrd_file /austrumi/initrd.gz
347 if [ -f (loop)/EFI/BOOT/bootx64.efi ]; then
348 vt_cpio_busybox64 "64h"
349 fi
350 elif [ -f (loop)/boot/initfs.x86_64-efi ]; then
351 vt_linux_specify_initrd_file /boot/initfs.x86_64-efi
352 if [ -f (loop)/boot/initfs.i386-pc ]; then
353 vt_linux_specify_initrd_file /boot/initfs.i386-pc
354 fi
355 elif [ -f (loop)/antiX/initrd.gz ]; then
356 vt_linux_specify_initrd_file /antiX/initrd.gz
357 elif [ -f (loop)/360Disk/initrd.gz ]; then
358 vt_linux_specify_initrd_file /360Disk/initrd.gz
359 elif [ -f (loop)/porteus/initrd.xz ]; then
360 vt_linux_specify_initrd_file /porteus/initrd.xz
361 elif [ -f (loop)/pyabr/boot/initrfs.img ]; then
362 vt_linux_specify_initrd_file /pyabr/boot/initrfs.img
363 elif [ -f (loop)/initrd0.img ]; then
364 vt_linux_specify_initrd_file /initrd0.img
365 elif [ -f (loop)/sysresccd/boot/i686/sysresccd.img ]; then
366 vt_linux_specify_initrd_file /sysresccd/boot/i686/sysresccd.img
367
368
369 fi
370 }
371
372 function ventoy_get_ghostbsd_ver {
373 # fallback to parse version from elf /boot/kernel/kernel
374 set vt_freebsd_ver=xx
375 }
376
377 function ventoy_get_furybsd_ver {
378 if regexp "13\.[0-9]" "$2"; then
379 set vt_freebsd_ver=13.x
380 else
381 set vt_freebsd_ver=12.x
382 fi
383 }
384
385 function ventoy_get_freenas_ver {
386 set vt_freebsd_ver=11.x
387
388 if [ -e (loop)/FreeNAS-MANIFEST ]; then
389 vt_parse_freenas_ver (loop)/FreeNAS-MANIFEST vt_freenas_ver
390 if regexp "^13\.[0-9]" "$vt_freenas_ver"; then
391 set vt_freebsd_ver=13.x
392 elif regexp "^12\.[0-9]" "$vt_freenas_ver"; then
393 set vt_freebsd_ver=12.x
394 elif regexp "^11\.[0-9]" "$vt_freenas_ver"; then
395 set vt_freebsd_ver=11.x
396 fi
397 fi
398 }
399
400 function ventoy_get_truenas_ver {
401 set vt_freebsd_ver=12.x
402
403 if [ -e (loop)/TrueNAS-MANIFEST ]; then
404 vt_parse_freenas_ver (loop)/TrueNAS-MANIFEST vt_truenas_ver
405 if regexp "^13\.[0-9]" "$vt_truenas_ver"; then
406 set vt_freebsd_ver=13.x
407 elif regexp "^12\.[0-9]" "$vt_truenas_ver"; then
408 set vt_freebsd_ver=12.x
409 elif regexp "^11\.[0-9]" "$vt_truenas_ver"; then
410 set vt_freebsd_ver=11.x
411 fi
412 fi
413 }
414
415 function ventoy_get_midnightbsd_ver {
416 if vt_str_begin "$vt_volume_id" "1_"; then
417 set vt_freebsd_ver=11.x
418 elif vt_str_begin "$vt_volume_id" "2_"; then
419 set vt_freebsd_ver=2.x
420 elif vt_str_begin "$vt_volume_id" "3_"; then
421 set vt_freebsd_ver=3.x
422 fi
423 }
424
425 function ventoy_freebsd_proc {
426 set vtFreeBsdDistro=FreeBSD
427 set vt_freebsd_ver=xx
428
429 if [ -e (loop)/boot/kernel/geom_ventoy.ko ]; then
430 vt_unix_ko_fillmap /boot/kernel/geom_ventoy.ko
431 return
432 fi
433
434 if vt_strstr "$vt_volume_id" "GHOSTBSD"; then
435 ventoy_get_ghostbsd_ver "$1" "${chosen_path}"
436 elif vt_strstr "$vt_volume_id" "FREENAS"; then
437 ventoy_get_freenas_ver "$1" "${chosen_path}"
438 elif vt_strstr "$vt_volume_id" "TRUENAS"; then
439 ventoy_get_truenas_ver "$1" "${chosen_path}"
440 elif vt_strstr "$vt_volume_id" "FURYBSD"; then
441 ventoy_get_furybsd_ver "$1" "${chosen_path}"
442 elif regexp "^13_[0-9]" "$vt_volume_id"; then
443 set vt_freebsd_ver=13.x
444 elif regexp "^12_[0-9]" "$vt_volume_id"; then
445 set vt_freebsd_ver=12.x
446 elif regexp "^11_[0-9]" "$vt_volume_id"; then
447 set vt_freebsd_ver=11.x
448 elif regexp "^10_[0-9]" "$vt_volume_id"; then
449 set vt_freebsd_ver=10.x
450 elif regexp "^9_[0-9]" "$vt_volume_id"; then
451 set vt_freebsd_ver=9.x
452 elif [ -d (loop)/usr/midnightbsd-dist ]; then
453 ventoy_get_midnightbsd_ver "$1" "${chosen_path}"
454 set vtFreeBsdDistro=MidnightBSD
455 elif [ -e (loop)/bin/freebsd-version ]; then
456 vt_unix_parse_freebsd_ver (loop)/bin/freebsd-version vt_userland_ver
457 if regexp "\"13\.[0-9]-" "$vt_userland_ver"; then
458 set vt_freebsd_ver=13.x
459 elif regexp "\"12\.[0-9]-" "$vt_userland_ver"; then
460 set vt_freebsd_ver=12.x
461 elif regexp "\"11\.[0-9]-" "$vt_userland_ver"; then
462 set vt_freebsd_ver=11.x
463 elif regexp "\"10\.[0-9]-" "$vt_userland_ver"; then
464 set vt_freebsd_ver=10.x
465 elif regexp "\"9\.[0-9]-" "$vt_userland_ver"; then
466 set vt_freebsd_ver=9.x
467 fi
468 elif [ -e (loop)/README.TXT ]; then
469 vt_1st_line (loop)/README.TXT vt_freebsd_line1
470 if regexp "FreeBSD 13\.[0-9]-" "$vt_freebsd_line1"; then
471 set vt_freebsd_ver=13.x
472 elif regexp "FreeBSD 12\.[0-9]-" "$vt_freebsd_line1"; then
473 set vt_freebsd_ver=12.x
474 elif regexp "FreeBSD 11\.[0-9]-" "$vt_freebsd_line1"; then
475 set vt_freebsd_ver=11.x
476 elif regexp "FreeBSD 10\.[0-9]-" "$vt_freebsd_line1"; then
477 set vt_freebsd_ver=10.x
478 elif regexp "FreeBSD 9\.[0-9]-" "$vt_freebsd_line1"; then
479 set vt_freebsd_ver=9.x
480 fi
481 elif vt_strstr "${chosen_path}" "MidnightBSD"; then
482 set vt_freebsd_ver=9.x
483 fi
484
485
486 if [ -e (loop)/usr/freebsd-dist/cloninst.sh ]; then
487 set vtFreeBsdDistro=ClonOS
488 fi
489
490 set vt_freebsd_bit=64
491 for file in "/boot/kernel/kernel" "/boot/kernel/kernel.gz"; do
492 if [ -e (loop)/$file ]; then
493 if file --is-i386-kfreebsd (loop)/$file; then
494 set vt_freebsd_bit=32
495 fi
496 break
497 fi
498 done
499
500 if [ "$vt_freebsd_ver" = "xx" ]; then
501 if [ -e (loop)/boot/kernel/kernel ]; then
502 vt_unix_parse_freebsd_ver_elf (loop)/boot/kernel/kernel $vt_freebsd_bit vt_freebsd_ver
503 fi
504
505 if [ "$vt_freebsd_ver" = "xx" ]; then
506 set vt_freebsd_ver=13.x
507 fi
508 fi
509
510 if [ -n "${vtdebug_flag}" ]; then
511 echo "This is $vtFreeBsdDistro $vt_freebsd_ver ${vt_freebsd_bit}bit"
512 fi
513
514 unset vt_unix_mod_path
515 for file in "/COPYRIGHT" "/FreeNAS-MANIFEST" "/TrueNAS-MANIFEST" "/version" "/etc/fstab"; do
516 if [ -e (loop)${file} ]; then
517 set vt_unix_mod_path=${file}
518 break
519 fi
520 done
521
522 vt_unix_replace_ko $vt_unix_mod_path (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
523 vt_unix_replace_conf FreeBSD "${1}${chosen_path}"
524 }
525
526 function ventoy_dragonfly_proc {
527
528 unset vt_unix_mod_path
529 for file in "/boot/kernel/initrd.img.gz"; do
530 if [ -e (loop)${file} ]; then
531 set vt_unix_mod_path=${file}
532 break
533 fi
534 done
535
536 vt_unix_replace_ko $vt_unix_mod_path ${vtoy_path}/dragonfly.mfs.xz
537 vt_unix_fill_image_desc
538 vt_unix_gzip_new_ko
539 vt_unix_replace_conf DragonFly "${1}${chosen_path}"
540 }
541
542 function ventoy_unix_comm_proc {
543 vt_unix_reset
544
545 if [ "$ventoy_compatible" = "NO" ]; then
546 loopback vtunix $vtoy_efi_part/ventoy/ventoy_unix.cpio
547
548 if [ "$vt_unix_type" = "FreeBSD" ]; then
549 ventoy_freebsd_proc "$1" "${chosen_path}"
550 elif [ "$vt_unix_type" = "DragonFly" ]; then
551 ventoy_dragonfly_proc "$1" "${chosen_path}"
552 elif [ "$vt_unix_type" = "NetBSD" ]; then
553 echo "NetBSD not supported"
554
555
556 else
557 if [ -n "${vtdebug_flag}" ]; then
558 echo "Unknown unix type"
559 fi
560 fi
561 fi
562
563 vt_unix_chain_data "${1}${chosen_path}"
564 ventoy_debug_pause
565 }
566
567
568 function uefi_windows_menu_func {
569 vt_windows_reset
570
571 if [ "$ventoy_compatible" = "NO" ]; then
572
573 if [ "$ventoy_fs_probe" = "iso9660" ]; then
574 loopback -d loop
575 vt_iso9660_nojoliet 1
576 loopback loop "$1$2"
577 fi
578
579 for file in "efi/microsoft/boot/bcd"; do
580 vt_windows_collect_wim_patch bcd (loop)/$file
581 done
582
583 vt_windows_count_wim_patch vt_wim_cnt
584 if [ $vt_wim_cnt -eq 0 ]; then
585 distro_specify_wim_patch_phase2
586 fi
587
588 ventoy_debug_pause
589 locate_wim
590 fi
591
592 vt_windows_chain_data "${1}${chosen_path}"
593 ventoy_debug_pause
594
595 if vt_check_mode 4; then
596 vtoy_windows_wimboot_func
597 fi
598
599 if [ -n "$vtoy_chain_mem_addr" ]; then
600 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
601 ventoy_cli_console
602 chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} iso_${ventoy_fs_probe} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
603 boot
604 else
605 echo "chain empty failed"
606 ventoy_pause
607 fi
608 }
609
610 function uefi_find_replace_initrd {
611 if vt_get_efi_vdisk_offset "${1}${2}" vt_efivdisk_offset; then
612 loopback -s $vt_efivdisk_offset vtefivdisk "${1}${2}"
613
614 unset vt_rp_initrd
615 vt_search_replace_initrd (vtefivdisk) vt_rp_initrd
616
617 if [ -n "$vt_rp_initrd" ]; then
618 vt_add_replace_file $3 "$vt_rp_initrd"
619 fi
620
621 loopback -d vtefivdisk
622 ventoy_debug_pause
623 fi
624 }
625
626 function uefi_linux_menu_func {
627
628 if [ "$ventoy_compatible" = "NO" ]; then
629
630 if [ "$ventoy_fs_probe" = "udf" ]; then
631 loopback -d loop
632 set ventoy_fs_probe=iso9660
633 loopback loop "$1$2"
634 fi
635
636 vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver"
637
638 vt_linux_clear_initrd
639
640 if [ -d (loop)/pmagic ]; then
641 vt_linux_specify_initrd_file /pmagic/initrd.img
642 else
643 for file in "boot/grub/grub.cfg" "EFI/BOOT/grub.cfg" "EFI/boot/grub.cfg" "efi/boot/grub.cfg" "EFI/BOOT/BOOTX64.conf" "/grub/grub.cfg"; do
644 if [ -e (loop)/$file ]; then
645 vt_linux_parse_initrd_grub file (loop)/$file
646 fi
647 done
648 fi
649
650 # special process for special distros
651 if [ -d (loop)/loader/entries ]; then
652 vt_linux_parse_initrd_grub dir (loop)/loader/entries/
653 elif [ -d (loop)/boot/grub ]; then
654 vt_linux_parse_initrd_grub dir (loop)/boot/grub/
655 fi
656
657 distro_specify_initrd_file
658
659 vt_linux_initrd_count vtcount
660
661 if [ $vtcount -eq 0 ]; then
662 distro_specify_initrd_file_phase2
663
664 if [ "$vt_efi_dir" = "NO" ]; then
665 if [ -f (loop)/efi.img ]; then
666 vt_add_replace_file 0 "initrd"
667 fi
668 fi
669 fi
670
671 locate_initrd
672
673 if [ -d (loop)/loader/entries ]; then
674 vt_linux_get_main_initrd_index vtindex
675
676 if [ -d (loop)/arch ]; then
677 if [ -f (loop)/arch/boot/x86_64/archiso.img ]; then
678 vt_add_replace_file $vtindex "EFI\\archiso\\archiso.img"
679 elif [ -f (loop)/arch/boot/x86_64/initramfs-linux.img ]; then
680 vt_add_replace_file $vtindex "arch\\boot\\x86_64\\initramfs-linux.img"
681 elif [ -f (loop)/boot/initramfs_x86_64.img ]; then
682 vt_add_replace_file $vtindex "boot\\initramfs_x86_64.img"
683 fi
684 elif [ -d (loop)/blackarch ]; then
685 if [ -f (loop)/blackarch/boot/x86_64/archiso.img ]; then
686 vt_add_replace_file $vtindex "EFI\\archiso\\archiso.img"
687 elif [ -f (loop)/blackarch/boot/x86_64/initramfs-linux.img ]; then
688 vt_add_replace_file $vtindex "blackarch\\boot\\x86_64\\initramfs-linux.img"
689 fi
690 elif [ -d (loop)/anarchy ]; then
691 if [ -f (loop)/anarchy/boot/x86_64/initramfs-linux.img ]; then
692 vt_add_replace_file $vtindex "anarchy\\boot\\x86_64\\initramfs-linux.img"
693 fi
694 elif [ -d (loop)/parabola ]; then
695 if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
696 vt_add_replace_file $vtindex "EFI\\parabolaiso\\parabolaiso.img"
697 elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then
698 vt_add_replace_file $vtindex "parabola\\boot\\x86_64\\initramfs-linux-libre.img"
699 fi
700 elif [ -f (loop)/EFI/BOOT/initrd.gz ]; then
701 vt_add_replace_file $vtindex "EFI\\BOOT\\initrd.gz"
702 elif [ -f (loop)/loader/entries/thinstation.conf ]; then
703 vt_add_replace_file $vtindex "boot\\initrd"
704 elif [ -f (loop)/loader/entries/pisi-efi-x86_64.conf ]; then
705 vt_add_replace_file $vtindex "EFI\\pisi\\initrd.img"
706 fi
707
708 vt_get_replace_file_cnt vt_replace_cnt
709 if [ $vt_replace_cnt -eq 0 ]; then
710 uefi_find_replace_initrd "$1" "$2" $vtindex
711 fi
712 elif [ -d (loop)/EFI/boot/entries ]; then
713 if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
714 vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
715 elif [ -f (loop)/hyperbola/boot/x86_64/hyperiso.img ]; then
716 vt_add_replace_file 0 "EFI\\hyperiso\\hyperiso.img"
717 fi
718 elif [ -d (loop)/EFI/BOOT/entries ]; then
719 vt_linux_get_main_initrd_index vtindex
720
721 if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
722 vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
723 elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then
724 vt_add_replace_file $vtindex "parabola\\boot\\x86_64\\initramfs-linux-libre.img"
725 fi
726 elif [ -e (loop)/syslinux/alt0/full.cz ]; then
727 vt_add_replace_file 0 "EFI\\BOOT\\full.cz"
728 set FirstTryBootFile='@EFI@BOOT@grubx64.efi'
729
730 elif vt_str_begin "$vt_volume_id" "SolusLive"; then
731 vt_add_replace_file 0 "initrd"
732
733 fi
734
735 fi
736
737 vt_linux_chain_data "${1}${chosen_path}"
738
739 if [ -n "$LoadIsoEfiDriver" -a $vt_chosen_size -lt 104857600 ]; then
740 if [ -f (loop)/efi/clover/cloverx64.efi ]; then
741 unset LoadIsoEfiDriver
742 fi
743 fi
744
745 if [ -n "$vtoy_chain_mem_addr" ]; then
746 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
747 ventoy_cli_console
748
749 if vt_check_mode 3; then
750 ventoy_debug_pause
751 else
752 if [ "$VTOY_EFI_ARCH" != "mips" ]; then
753 chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi fallback env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
754 boot
755 fi
756 fi
757
758 # fallback
759 set vtback_root=$root
760 vt_push_last_entry
761 set vtback_theme=$theme
762 unset theme
763
764 vt_trailer_cpio "$vtoy_iso_part" "$vt_chosen_path" noinit
765 vt_set_boot_opt rdinit=/vtoy/vtoy
766
767 set root=(loop)
768 set vtback_cfg_find=0
769 for cfg in "/boot/grub/grub.cfg" "/EFI/BOOT/grub.cfg" "/EFI/debian/grub.cfg" "EFI/boot/grub.cfg" "efi/boot/grub.cfg" "/grub/grub.cfg" "EFI/BOOT/BOOTX64.conf"; do
770 if [ -e "$cfg" ]; then
771 set vtback_cfg_find=1
772 configfile "$cfg"
773 break
774 fi
775 done
776
777 if [ "$vtback_cfg_find" = "0" ]; then
778 echo " "
779 echo "No bootfile found for UEFI!"
780 echo "Maybe the image does not support $VTOY_EFI_ARCH UEFI"
781 echo " "
782 sleep 30
783 fi
784
785 vt_unset_boot_opt
786 set root=$vtback_root
787 set theme=$vtback_theme
788 vt_pop_last_entry
789 ventoy_gui_console
790 else
791 echo "chain empty failed"
792 ventoy_pause
793 fi
794 }
795
796 function uefi_unix_menu_func {
797 ventoy_unix_comm_proc $1 "${chosen_path}"
798
799 if [ -n "$vtoy_chain_mem_addr" ]; then
800 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
801 ventoy_cli_console
802 chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
803 boot
804 else
805 echo "chain empty failed"
806 ventoy_pause
807 fi
808 }
809
810 function ventoy_reset_nojoliet {
811 if vt_str_begin "$vt_volume_id" "ARCARESCUE"; then
812 vt_iso9660_nojoliet 1
813 else
814 vt_iso9660_nojoliet 0
815 fi
816
817 vt_append_extra_sector 0
818 }
819
820 function uefi_iso_menu_func {
821
822 if [ -d (loop)/ ]; then
823 loopback -d loop
824 fi
825
826 if [ -n "$vtisouefi" ]; then
827 set LoadIsoEfiDriver=on
828 unset vtisouefi
829 elif vt_check_mode 2; then
830 set LoadIsoEfiDriver=on
831 else
832 unset LoadIsoEfiDriver
833 fi
834
835 set chosen_path="$2"
836 vt_select_auto_install "${chosen_path}"
837 vt_select_persistence "${chosen_path}"
838
839 if vt_is_udf "${1}${chosen_path}"; then
840 set ventoy_fs_probe=udf
841 else
842 set ventoy_fs_probe=iso9660
843 ventoy_reset_nojoliet
844
845 # Lenovo EasyStartup need an addional sector for boundary check
846 if vt_str_begin "$vt_volume_id" "EasyStartup"; then
847 vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}"
848 vt_append_extra_sector 1
849 fi
850 fi
851
852 loopback loop "${1}${chosen_path}"
853 get_os_type (loop)
854
855 if [ -d (loop)/EFI ]; then
856 set vt_efi_dir=YES
857 elif [ -d (loop)/efi ]; then
858 set vt_efi_dir=YES
859 else
860 set vt_efi_dir=NO
861 fi
862
863 if [ -n "$vtcompat" ]; then
864 set ventoy_compatible=YES
865 unset vtcompat
866 elif vt_check_mode 1; then
867 set ventoy_compatible=YES
868 else
869 vt_check_compatible (loop)
870 fi
871
872 vt_img_sector "${1}${chosen_path}"
873
874 if [ "$ventoy_fs_probe" = "iso9660" ]; then
875 vt_select_conf_replace "${1}" "${chosen_path}"
876 fi
877
878 if [ "$vtoy_os" = "Windows" ]; then
879 vt_check_compatible_pe (loop)
880 uefi_windows_menu_func "$1" "${chosen_path}"
881 elif [ "$vtoy_os" = "Unix" ]; then
882 uefi_unix_menu_func "$1" "${chosen_path}"
883 else
884 vt_check_compatible_linux (loop)
885 uefi_linux_menu_func "$1" "${chosen_path}"
886 fi
887
888 ventoy_gui_console
889 }
890
891 function uefi_iso_memdisk {
892 echo 'Loading ISO file to memory ...'
893 vt_load_img_memdisk "${1}${2}" vtoy_iso_buf
894
895 ventoy_cli_console
896 chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_iso_buf_addr}:size:${vtoy_iso_buf_size}
897 boot
898
899 ventoy_gui_console
900 }
901
902
903 function vtoy_windows_wimboot_func {
904 if [ -f (loop)/x86/sources/boot.wim -a -f (loop)/x64/sources/boot.wim ]; then
905 vt_sel_wimboot vtoy_wimboot_bit
906 if [ "$vtoy_wimboot_bit" = "32" ]; then
907 set vtoy_wimboot_prefix=(loop)/x86
908 else
909 set vtoy_wimboot_prefix=(loop)/x64
910 fi
911 else
912 set vtoy_wimboot_prefix=(loop)
913 if vt_is_pe64 $vtoy_wimboot_prefix/setup.exe; then
914 set vtoy_wimboot_bit=64
915 else
916 set vtoy_wimboot_bit=32
917 fi
918 fi
919
920 if [ -n "${vtdebug_flag}" ]; then
921 echo vtoy_wimboot_prefix=$vtoy_wimboot_prefix vtoy_wimboot_bit=$vtoy_wimboot_bit
922 fi
923
924 for wmfile in sources/boot.wim boot/bcd boot/boot.sdi; do
925 if [ ! -f $vtoy_wimboot_prefix/$wmfile ]; then
926 return
927 fi
928 done
929
930 if [ -f $vtoy_wimboot_prefix/sources/install.wim -o -f $vtoy_wimboot_prefix/sources/install.esd ]; then
931 vt_windows_wimboot_data
932 else
933 return
934 fi
935
936 if [ "$grub_platform" = "pc" ]; then
937 set vt_wimkernel=wimboot.x86_64.xz
938
939 linux16 "$vtoy_path/$vt_wimkernel" quiet
940 ventoy_debug_pause
941
942 vt_set_wim_load_prompt 1 "Loading files......"
943 initrd16 newc:vtoyjump.exe:$vtoy_path/vtoyjump${vtoy_wimboot_bit}.exe \
944 newc:wimboot.data:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size} \
945 newc:winpeshl.ini:mem:${vtoy_winpeshl_ini_addr}:size:${vtoy_winpeshl_ini_size} \
946 newc:bcd:$vtoy_wimboot_prefix/boot/bcd \
947 newc:boot.sdi:$vtoy_wimboot_prefix/boot/boot.sdi \
948 newc:boot.wim:$vtoy_wimboot_prefix/sources/boot.wim
949 vt_set_wim_load_prompt 0
950 boot
951 else
952 if [ "$grub_cpu" = "i386" ]; then
953 set vt_wimkernel=wimboot.i386.efi.xz
954 else
955 set vt_wimkernel=wimboot.x86_64.xz
956 fi
957
958 vt_set_wim_load_prompt 1 "Loading files......"
959 vt_load_file_to_mem "nodecompress" $vtoy_wimboot_prefix/sources/boot.wim vtoy_wimfile_mem
960 vt_set_wim_load_prompt 0
961
962 if [ $? -eq 0 ]; then
963 set vtoy_wimfile_path=mem:${vtoy_wimfile_mem_addr}:size:${vtoy_wimfile_mem_size}
964 else
965 set vtoy_wimfile_path=$vtoy_wimboot_prefix/sources/boot.wim
966 fi
967
968 ventoy_cli_console
969 chainloader "$vtoy_path/$vt_wimkernel" quiet \
970 "vf=wimboot.data:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size}" \
971 "vf=winpeshl.ini:mem:${vtoy_winpeshl_ini_addr}:size:${vtoy_winpeshl_ini_size}" \
972 "vf=vtoyjump.exe:$vtoy_path/vtoyjump${vtoy_wimboot_bit}.exe" \
973 "vf=bcd:$vtoy_wimboot_prefix/boot/bcd" \
974 "vf=boot.sdi:$vtoy_wimboot_prefix/boot/boot.sdi" \
975 "vf=boot.wim:$vtoy_wimfile_path" \
976 pfsize=$vtoy_chain_file_size \
977 pfread=$vtoy_chain_file_read
978 boot
979 ventoy_gui_console
980 fi
981 }
982
983 function legacy_windows_menu_func {
984 vt_windows_reset
985
986 if [ "$ventoy_compatible" = "NO" ]; then
987
988 if [ "$ventoy_fs_probe" = "iso9660" ]; then
989 loopback -d loop
990 vt_iso9660_nojoliet 1
991 loopback loop "$1$2"
992 fi
993
994 for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD" "boot/bce"; do
995 vt_windows_collect_wim_patch bcd (loop)/$file
996 done
997
998 distro_specify_wim_patch
999
1000 vt_windows_count_wim_patch vt_wim_cnt
1001 if [ $vt_wim_cnt -eq 0 ]; then
1002 distro_specify_wim_patch_phase2
1003 fi
1004
1005 ventoy_debug_pause
1006 locate_wim
1007 fi
1008
1009 vt_windows_chain_data "${1}${chosen_path}"
1010 ventoy_debug_pause
1011
1012 if vt_check_mode 4; then
1013 vtoy_windows_wimboot_func
1014 fi
1015
1016 if [ -n "$vtoy_chain_mem_addr" ]; then
1017 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
1018 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1019 boot
1020 else
1021 echo "chain empty failed"
1022 ventoy_pause
1023 fi
1024 }
1025
1026 function legacy_linux_menu_func {
1027 if [ "$ventoy_compatible" = "NO" ]; then
1028
1029 if [ "$ventoy_fs_probe" = "udf" ]; then
1030 loopback -d loop
1031 set ventoy_fs_probe=iso9660
1032 loopback loop "$1$2"
1033 fi
1034
1035
1036 if vt_syslinux_need_nojoliet "$1$2"; then
1037 vt_iso9660_nojoliet 1
1038 loopback -d loop
1039 loopback loop "$1$2"
1040 fi
1041
1042 vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver"
1043
1044 vt_linux_clear_initrd
1045
1046 if [ -d (loop)/pmagic ]; then
1047 vt_linux_specify_initrd_file /pmagic/initrd.img
1048 else
1049 for dir in "isolinux" "boot/isolinux" "boot/x86_64/loader" "syslinux" "boot/syslinux"; do
1050 if [ -d (loop)/$dir ]; then
1051 vt_linux_parse_initrd_isolinux (loop)/$dir/
1052 fi
1053 done
1054 fi
1055
1056 # special process for special distros
1057 #archlinux
1058 if [ -d (loop)/arch/boot/syslinux ]; then
1059 vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/
1060 vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/boot/syslinux/
1061 elif [ -d (loop)/anarchy/boot/syslinux ]; then
1062 vt_linux_parse_initrd_isolinux (loop)/anarchy/boot/syslinux/ /anarchy/
1063
1064 #manjaro
1065 elif [ -d (loop)/manjaro ]; then
1066 if [ -e (loop)/boot/grub/kernels.cfg ]; then
1067 vt_linux_parse_initrd_grub file (loop)/boot/grub/kernels.cfg
1068 fi
1069 elif [ -e (loop)/boot/grub/grub.cfg ]; then
1070 vt_linux_parse_initrd_grub file (loop)/boot/grub/grub.cfg
1071 fi
1072
1073 distro_specify_initrd_file
1074
1075 vt_linux_initrd_count vtcount
1076 if [ $vtcount -eq 0 ]; then
1077 if [ -d (loop)/rancheros ]; then
1078 vt_linux_parse_initrd_isolinux (loop)/boot/ /boot/isolinux/
1079 fi
1080
1081 distro_specify_initrd_file_phase2
1082 fi
1083
1084 locate_initrd
1085 fi
1086
1087 vt_linux_chain_data "${1}${chosen_path}"
1088 ventoy_debug_pause
1089
1090 if [ -n "$vtoy_chain_mem_addr" ]; then
1091 if vt_check_mode 3; then
1092 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
1093 ventoy_cli_console
1094
1095 # fallback
1096 set vtback_root=$root
1097 vt_push_last_entry
1098 set vtback_theme=$theme
1099 unset theme
1100
1101 vt_trailer_cpio "$vtoy_iso_part" "$vt_chosen_path" noinit
1102 vt_set_boot_opt rdinit=/vtoy/vtoy
1103
1104 set root=(loop)
1105 set vtback_cfg_find=0
1106 for cfg in "/boot/grub/grub.cfg" "/EFI/BOOT/grub.cfg" "/EFI/debian/grub.cfg" "EFI/boot/grub.cfg" "efi/boot/grub.cfg" "/grub/grub.cfg" "EFI/BOOT/BOOTX64.conf"; do
1107 if [ -e "$cfg" ]; then
1108 set vtback_cfg_find=1
1109 configfile "$cfg"
1110 break
1111 fi
1112 done
1113
1114 vt_unset_boot_opt
1115 set root=$vtback_root
1116 set theme=$vtback_theme
1117 vt_pop_last_entry
1118 ventoy_gui_console
1119 else
1120 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
1121 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1122 boot
1123 fi
1124 else
1125 echo "chain empty failed"
1126 ventoy_pause
1127 fi
1128 }
1129
1130
1131 function legacy_unix_menu_func {
1132 ventoy_unix_comm_proc $1 "${chosen_path}"
1133
1134 if [ -n "$vtoy_chain_mem_addr" ]; then
1135 #ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
1136 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1137 boot
1138 else
1139 echo "chain empty failed"
1140 ventoy_pause
1141 fi
1142 }
1143
1144
1145 function legacy_iso_menu_func {
1146
1147 if [ -d (loop)/ ]; then
1148 loopback -d loop
1149 fi
1150
1151 set chosen_path="$2"
1152
1153 vt_select_auto_install "${chosen_path}"
1154 vt_select_persistence "${chosen_path}"
1155
1156 if vt_is_udf "${1}${chosen_path}"; then
1157 set ventoy_fs_probe=udf
1158 else
1159 set ventoy_fs_probe=iso9660
1160 ventoy_reset_nojoliet
1161 fi
1162
1163 loopback loop "${1}${chosen_path}"
1164
1165 get_os_type (loop)
1166
1167 if [ -n "$vtcompat" ]; then
1168 set ventoy_compatible=YES
1169 unset vtcompat
1170 elif vt_check_mode 1; then
1171 set ventoy_compatible=YES
1172 else
1173 vt_check_compatible (loop)
1174 fi
1175
1176 vt_img_sector "${1}${chosen_path}"
1177
1178 if [ "$ventoy_fs_probe" = "iso9660" ]; then
1179 vt_select_conf_replace "${1}" "${chosen_path}"
1180 fi
1181
1182 if [ "$vtoy_os" = "Windows" ]; then
1183 vt_check_compatible_pe (loop)
1184 legacy_windows_menu_func "$1" "${chosen_path}"
1185 elif [ "$vtoy_os" = "Unix" ]; then
1186 legacy_unix_menu_func "$1" "${chosen_path}"
1187 else
1188 vt_check_compatible_linux (loop)
1189 legacy_linux_menu_func "$1" "${chosen_path}"
1190 fi
1191 }
1192
1193 function legacy_iso_memdisk {
1194
1195 linux16 $vtoy_path/memdisk iso raw
1196 echo "Loading ISO file to memory ..."
1197 initrd16 "${1}${2}"
1198 boot
1199 }
1200
1201
1202 function iso_endless_os_proc {
1203 if [ -d (loop)/ ]; then
1204 loopback -d loop
1205 fi
1206
1207 loopback loop "${1}${2}"
1208 vt_img_sector "${1}${2}"
1209
1210 vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver"
1211 vt_trailer_cpio "$1" "$2" noinit
1212
1213 ventoy_debug_pause
1214
1215 vt_set_boot_opt '@kparams' rdinit=/vtoy/vtoy
1216
1217 set eosimage=loop
1218 set ventoy_bls_bootdev=/boot
1219 set ventoy_loading_tip="Loading files ......"
1220
1221 export eosimage
1222 configfile (loop)/endless/grub/grub.cfg
1223
1224 unset eosimage
1225 unset ventoy_bls_bootdev
1226 unset ventoy_loading_tip
1227
1228 vt_unset_boot_opt
1229 }
1230
1231
1232 function ventoy_iso_busybox_ver {
1233
1234 if [ "$VTOY_EFI_ARCH" = "aa64" ]; then
1235 set ventoy_busybox_ver=a64
1236 elif [ "$VTOY_EFI_ARCH" = "mips" ]; then
1237 set ventoy_busybox_ver=m64
1238 else
1239 set ventoy_busybox_ver=32
1240
1241 #special process for deepin-live iso
1242 if [ "$vt_chosen_size" = "403701760" ]; then
1243 if vt_str_str "$vt_chosen_path" "/deepin-live"; then
1244 set ventoy_busybox_ver=64
1245 fi
1246 elif vt_str_begin "$vt_volume_id" "PHOTON_"; then
1247 set ventoy_busybox_ver=64
1248 elif vt_str_begin "$vt_volume_id" "smgl-test-quinq-x86_64"; then
1249 set ventoy_busybox_ver=64
1250 elif vt_str_begin "$vt_volume_id" "LDiagBootable"; then
1251 set ventoy_busybox_ver=64
1252
1253 fi
1254 fi
1255 }
1256
1257
1258 function iso_common_menuentry {
1259 unset vt_system_id
1260 unset vt_volume_id
1261
1262 vt_chosen_img_path vt_chosen_path vt_chosen_size
1263
1264 vt_parse_iso_volume "${vtoy_iso_part}${vt_chosen_path}" vt_system_id vt_volume_id vt_volume_space
1265 if [ $vt_volume_space -ne $vt_chosen_size ]; then
1266 vt_mod $vt_chosen_size 2048 vt_chosen_size_mod
1267 if [ $vt_chosen_size_mod -ne 0 ]; then
1268 echo -e "\n $vt_volume_space $vt_chosen_size $vt_chosen_size_mod\n"
1269 echo -e "\n The size of the iso file \"$vt_chosen_size\" is invalid. File corrupted ?\n"
1270 echo -e " 此ISO文件的大小 \"$vt_chosen_size\" 有问题,请确认文件是否损坏。\n"
1271 echo -e "\n press ENTER to continue (请按 回车 键继续) ..."
1272 read vtInputKey
1273 fi
1274 fi
1275
1276 if vt_check_password "${vt_chosen_path}"; then
1277 return
1278 fi
1279
1280 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1281 return
1282 fi
1283
1284 if vt_str_begin "$vt_volume_id" "Avira"; then
1285 vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}"
1286 fi
1287
1288 ventoy_iso_busybox_ver
1289
1290 #special process for Endless OS
1291 if vt_str_begin "$vt_volume_id" "Endless-OS"; then
1292 iso_endless_os_proc $vtoy_iso_part "$vt_chosen_path"
1293 elif vt_str_begin "$vt_volume_id" "TENS-Public"; then
1294 set vtcompat=1
1295 fi
1296
1297 if [ "$grub_platform" = "pc" ]; then
1298 if vt_check_mode 0; then
1299 legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1300 else
1301 legacy_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
1302 fi
1303 else
1304 if vt_check_mode 0; then
1305 uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1306 else
1307 uefi_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
1308 fi
1309 fi
1310 }
1311
1312 function miso_common_menuentry {
1313 vt_chosen_img_path vt_chosen_path vt_chosen_size
1314
1315 if vt_check_password "${vt_chosen_path}"; then
1316 return
1317 fi
1318
1319 echo "memdisk mode boot for $vt_chosen_path"
1320 echo ""
1321 ventoy_debug_pause
1322
1323 if [ "$grub_platform" = "pc" ]; then
1324 legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1325 else
1326 uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1327 fi
1328 }
1329
1330
1331 function common_unsupport_menuentry {
1332 echo -e "\n The name of the iso file could NOT contain space or non-ascii characters. \n"
1333 echo -e " 文件名中不能有中文或空格 \n"
1334 echo -e "\npress ENTER to exit (请按 回车 键返回) ..."
1335 read vtInputKey
1336 }
1337
1338 function miso_unsupport_menuentry {
1339 common_unsupport_menuentry
1340 }
1341
1342 function iso_unsupport_menuentry {
1343 common_unsupport_menuentry
1344 }
1345
1346 function wim_common_menuentry {
1347 vt_chosen_img_path vt_chosen_path vt_chosen_size
1348
1349 if vt_check_password "${vt_chosen_path}"; then
1350 return
1351 fi
1352
1353 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1354 return
1355 fi
1356
1357 if vt_wim_check_bootable "${vtoy_iso_part}${vt_chosen_path}"; then
1358 vt_wim_chain_data "${vtoy_iso_part}${vt_chosen_path}"
1359 else
1360 echo -e "\n This is NOT a bootable WIM file. \n"
1361 echo -e " 这不是一个可启动的 WIM 文件。\n"
1362 fi
1363
1364 ventoy_debug_pause
1365
1366 if [ -n "$vtoy_chain_mem_addr" ]; then
1367 if [ "$grub_platform" = "pc" ]; then
1368 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1369 else
1370 ventoy_cli_console
1371 chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1372 ventoy_gui_console
1373 fi
1374 boot
1375 else
1376 echo "chain empty failed"
1377 ventoy_pause
1378 fi
1379 }
1380
1381 function wim_unsupport_menuentry {
1382 common_unsupport_menuentry
1383 }
1384
1385 function efi_common_menuentry {
1386 vt_chosen_img_path vt_chosen_path vt_chosen_size
1387
1388 if vt_check_password "${vt_chosen_path}"; then
1389 return
1390 fi
1391
1392 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1393 return
1394 fi
1395
1396 unset vt_vlnk_dst
1397 if vt_is_vlnk_name "${vt_chosen_path}"; then
1398 vt_get_vlnk_dst "${vtoy_iso_part}${vt_chosen_path}" vt_vlnk_dst
1399 if [ -z "$vt_vlnk_dst" ]; then
1400 echo -e "\n### VLNK FILE NOT FOUND ###\n### VLNK 文件不存在 ###\n"
1401 ventoy_pause
1402 return
1403 fi
1404 else
1405 vt_vlnk_dst="${vtoy_iso_part}${vt_chosen_path}"
1406 fi
1407
1408 vt_concat_efi_iso "${vt_vlnk_dst}" vtoy_iso_buf
1409
1410 ventoy_debug_pause
1411
1412 ventoy_cli_console
1413
1414 unset vtoy_dotefi_retry
1415 chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi memdisk env_param=${env_param} dotefi isoefi=on ${vtdebug_flag} mem:${vtoy_iso_buf_addr}:size:${vtoy_iso_buf_size}
1416 boot
1417
1418 if [ -n "$vtoy_dotefi_retry" ]; then
1419 unset vtoy_dotefi_retry
1420 chainloader "${vt_vlnk_dst}"
1421 boot
1422 fi
1423
1424 ventoy_gui_console
1425 }
1426
1427 function efi_unsupport_menuentry {
1428 common_unsupport_menuentry
1429 }
1430
1431 function vhdboot_common_func {
1432 vt_patch_vhdboot "$1"
1433
1434 ventoy_debug_pause
1435
1436 if [ -n "$vtoy_vhd_buf_addr" ]; then
1437 if [ "$grub_platform" = "pc" ]; then
1438 ventoy_cli_console
1439 linux16 $vtoy_path/memdisk iso raw
1440 initrd16 mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size}
1441 boot
1442 ventoy_gui_console
1443 else
1444 ventoy_cli_console
1445 chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size}
1446 boot
1447 ventoy_gui_console
1448 fi
1449 else
1450 echo "Please put the right ventoy_vhdboot.img file to the 1st partition"
1451 ventoy_pause
1452 fi
1453 }
1454
1455 function vhd_common_menuentry {
1456 vt_chosen_img_path vt_chosen_path vt_chosen_size
1457
1458 if vt_check_password "${vt_chosen_path}"; then
1459 return
1460 fi
1461
1462 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1463 return
1464 fi
1465
1466 unset vt_vlnk_dst
1467 if vt_is_vlnk_name "${vt_chosen_path}"; then
1468 vt_get_vlnk_dst "${vtoy_iso_part}${vt_chosen_path}" vt_vlnk_dst
1469 if [ -z "$vt_vlnk_dst" ]; then
1470 echo -e "\n### VLNK FILE NOT FOUND ###\n### VLNK 文件不存在 ###\n"
1471 ventoy_pause
1472 return
1473 fi
1474 else
1475 vt_vlnk_dst="${vt_chosen_path}"
1476 if [ "$VTOY_VHD_NO_WARNING" != "1" ]; then
1477 if [ "$vtoy_iso_fs" != "ntfs" ]; then
1478 echo -e "!!! WARNING !!!\n"
1479 echo -e "\nPartition1 ($vtoy_iso_fs) is NOT ntfs, the VHD(x) file may not boot normally \n"
1480 echo -e "\nVHD(x) 文件所在分区不是 ntfs 格式, 可能无法正常启动 \n\n"
1481 echo -n "press ENTER to continue boot (请按 回车 键继续) ..."
1482 read vtInputKey
1483 fi
1484 fi
1485 fi
1486
1487 vhdboot_common_func "${vt_vlnk_dst}"
1488 }
1489
1490 function vhd_unsupport_menuentry {
1491 common_unsupport_menuentry
1492 }
1493
1494 function vtoyboot_common_func {
1495 set AltBootPart=0
1496 set vtoysupport=0
1497
1498 vt_get_vtoy_type "${1}" vtoytype parttype AltBootPart
1499
1500 if vt_str_begin $vtoytype vhd; then
1501 set vtoysupport=1
1502 elif [ "$vtoytype" = "raw" ]; then
1503 set vtoysupport=1
1504 elif [ "$vtoytype" = "vdi" ]; then
1505 set vtoysupport=1
1506 fi
1507
1508 if [ $vtoysupport -eq 1 ]; then
1509 if [ "$grub_platform" = "pc" ]; then
1510 if [ "$parttype" = "gpt" -a $AltBootPart -eq 0 ]; then
1511 echo "The OS in the vdisk was created in UEFI mode, but current is Legacy BIOS mode."
1512 echo "虚拟磁盘内的系统是在UEFI模式下创建的,而当前系统是Legacy BIOS模式,可能无法正常启动。"
1513 ventoy_pause
1514 fi
1515 else
1516 if [ "$parttype" = "mbr" -a $AltBootPart -eq 0 ]; then
1517 echo "The OS in the vdisk was created in Legacy BIOS mode, but current is UEFI mode."
1518 echo "虚拟磁盘内的系统是在Legacy BIOS模式下创建的,而当前系统是UEFI模式,可能无法正常启动。"
1519 ventoy_pause
1520 fi
1521 fi
1522
1523 vt_img_sector "${1}"
1524 vt_raw_chain_data "${1}"
1525
1526 ventoy_debug_pause
1527
1528 if [ -n "$vtoy_chain_mem_addr" ]; then
1529 if [ "$grub_platform" = "pc" ]; then
1530 vt_acpi_param ${vtoy_chain_mem_addr} 512
1531 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} bios80 sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1532 boot
1533 else
1534 if vt_check_secureboot_var; then
1535 vt_acpi_param ${vtoy_chain_mem_addr} 512
1536 fi
1537 ventoy_cli_console
1538 chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi sector512 env_param=${ventoy_env_param} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1539 boot
1540 ventoy_gui_console
1541 fi
1542 else
1543 echo "chain empty failed!"
1544 ventoy_pause
1545 fi
1546 else
1547 echo "Unsupported vtoy type $vtoytype"
1548 ventoy_pause
1549 fi
1550 }
1551
1552 function vtoy_common_menuentry {
1553 vt_chosen_img_path vt_chosen_path vt_chosen_size
1554
1555 if vt_check_password "${vt_chosen_path}"; then
1556 return
1557 fi
1558
1559 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1560 return
1561 fi
1562
1563 unset vt_vlnk_dst
1564 if vt_is_vlnk_name "${vt_chosen_path}"; then
1565 vt_get_vlnk_dst "${vtoy_iso_part}${vt_chosen_path}" vt_vlnk_dst
1566 if [ -z "$vt_vlnk_dst" ]; then
1567 echo -e "\n### VLNK FILE NOT FOUND ###\n### VLNK 文件不存在 ###\n"
1568 ventoy_pause
1569 return
1570 fi
1571 else
1572 vt_vlnk_dst="${vtoy_iso_part}${vt_chosen_path}"
1573 fi
1574
1575 vtoyboot_common_func "${vt_vlnk_dst}"
1576 }
1577
1578 function vtoy_unsupport_menuentry {
1579 common_unsupport_menuentry
1580 }
1581
1582 #
1583 #============================================================#
1584 # IMG file boot process #
1585 #============================================================#
1586 #
1587
1588 function only_uefi_tip {
1589 echo -e "\n This IMG file is only supported in UEFI mode. \n"
1590 echo -e "\n press ENTER to exit ..."
1591 read vtInputKey
1592 }
1593
1594 function ventoy_img_easyos {
1595 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1596 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1597
1598 loopback easysfs (vtimghd,1)/easy.sfs
1599 vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver
1600
1601 if [ -n "$vt_module_ver" ]; then
1602 for mod in "kernel/drivers/md/dm-mod.ko" "kernel/drivers/dax/dax.ko"; do
1603 vt_img_extra_initrd_append (easysfs)/lib/modules/$vt_module_ver/$mod
1604 done
1605 fi
1606
1607 ventoy_debug_pause
1608
1609 #boot image file
1610 vt_set_boot_opt rdinit=/vtoy/vtoy
1611 vt_img_hook_root
1612
1613 syslinux_configfile (vtimghd,1)/syslinux.cfg
1614
1615 vt_img_unhook_root
1616 vt_unset_boot_opt
1617 loopback -d easysfs
1618 }
1619
1620 function ventoy_img_volumio {
1621 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1622 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1623
1624 ventoy_debug_pause
1625
1626 #boot image file
1627 vt_set_boot_opt rdinit=/vtoy/vtoy imgpart=/dev/ventoy2 bootpart=/dev/ventoy1
1628 vt_img_hook_root
1629
1630 syslinux_configfile (vtimghd,1)/syslinux.cfg
1631
1632 vt_img_unhook_root
1633 vt_unset_boot_opt
1634 }
1635
1636 function ventoy_img_openelec {
1637 elec_ver=$1
1638
1639 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1640 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1641
1642 loopback vtloopex $vtoy_efi_part/ventoy/vtloopex.cpio
1643 vt_img_extra_initrd_append (vtloopex)/$elec_ver/vtloopex.tar.xz
1644
1645 ventoy_debug_pause
1646
1647 #boot image file
1648 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=$elec_ver
1649 vt_img_hook_root
1650
1651 set root=(vtimghd,1)
1652 syslinux_configfile (vtimghd,1)/syslinux.cfg
1653
1654 vt_img_unhook_root
1655 vt_unset_boot_opt
1656 loopback -d vtloopex
1657 }
1658
1659
1660 function ventoy_img_freedombox {
1661 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1662 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1663
1664 vt_get_lib_module_ver (vtimghd,1) /lib/modules/ vt_module_ver
1665 if [ -n "$vt_module_ver" ]; then
1666 vt_img_extra_initrd_append (vtimghd,1)/lib/modules/$vt_module_ver/kernel/drivers/md/dm-mod.ko
1667 fi
1668
1669 ventoy_debug_pause
1670
1671 #boot image file
1672 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=freedombox
1673 vt_img_hook_root
1674
1675 configfile (vtimghd,1)/boot/grub/grub.cfg
1676
1677 vt_img_unhook_root
1678 vt_unset_boot_opt
1679 }
1680
1681 function ventoy_img_paldo {
1682 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1683 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1684
1685 ventoy_debug_pause
1686
1687 #boot image file
1688 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=paldo
1689 vt_img_hook_root
1690
1691 vt_fs_enum_1st_file (vtimghd,1) /loader/entries/ vt_paldo_entry_conf
1692 vt_file_basename $vt_paldo_entry_conf vtPaldoVer
1693
1694 echo loading file...
1695 linux (vtimghd,1)/linux-${vtPaldoVer} root=/dev/ventoy1 rootfstype=vfat
1696 initrd (vtimghd,1)/initramfs-${vtPaldoVer}
1697 boot
1698
1699 vt_img_unhook_root
1700 vt_unset_boot_opt
1701 }
1702
1703 function ventoy_img_ubos {
1704 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1705 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1706
1707 vt_get_lib_module_ver (vtimghd,3) /lib/modules/ vt_module_ver
1708 if [ -n "$vt_module_ver" ]; then
1709 vt_img_extra_initrd_append (vtimghd,3)/lib/modules/$vt_module_ver/kernel/drivers/md/dm-mod.ko.xz
1710 fi
1711
1712 ventoy_debug_pause
1713
1714 #boot image file
1715 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=ubos
1716 vt_img_hook_root
1717
1718 echo loading file...
1719 linux (vtimghd,2)/vmlinuz-linux root=/dev/ventoy3 rw
1720 initrd (vtimghd,2)/initramfs-linux.img
1721 boot
1722
1723 vt_img_unhook_root
1724 vt_unset_boot_opt
1725 }
1726
1727 function ventoy_img_recalbox {
1728 if [ $vtoy_img_max_part_end -gt $vt_chosen_size ]; then
1729 echo -e "\nPlease extend the img file size before boot it. \n"
1730 ventoy_pause
1731 return
1732 fi
1733
1734 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1735 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1736
1737 if [ -e (vtimghd,1)/boot/recalbox ]; then
1738 loopback recalbox (vtimghd,1)/boot/recalbox
1739 vt_get_lib_module_ver (recalbox) /lib/modules/ vt_module_ver
1740 if [ -n "$vt_module_ver" ]; then
1741 vt_img_extra_initrd_append (recalbox)/lib/modules/$vt_module_ver/kernel/drivers/md/dm-mod.ko
1742 fi
1743 fi
1744
1745 ventoy_debug_pause
1746
1747 #boot image file
1748 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=recalbox
1749 vt_img_hook_root
1750
1751 set root=(vtimghd,1)
1752 configfile (vtimghd,1)/boot/grub/grub.cfg
1753
1754 vt_img_unhook_root
1755 vt_unset_boot_opt
1756 }
1757
1758 function ventoy_img_esysrescue {
1759 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1760 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1761
1762 ventoy_debug_pause
1763
1764 #boot image file
1765 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=esysrescue
1766 vt_img_hook_root
1767
1768 set root=(vtimghd,1)
1769 configfile (vtimghd,1)/boot/grub/grub.cfg
1770
1771 vt_img_unhook_root
1772 vt_unset_boot_opt
1773 }
1774
1775 function ventoy_img_batocera {
1776 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1777 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1778
1779 ventoy_debug_pause
1780
1781 #boot image file
1782 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=batocera
1783 vt_img_hook_root
1784
1785 set root=(vtimghd,1)
1786 syslinux_configfile (vtimghd,1)/boot/syslinux/syslinux.cfg
1787
1788 vt_img_unhook_root
1789 vt_unset_boot_opt
1790 }
1791
1792 function ventoy_img_openwrt {
1793 if [ -e (vtimghd,2)/lib64 ]; then
1794 set ventoy_busybox_ver=64
1795 fi
1796
1797 vt_fs_enum_1st_dir (vtimghd,2) /lib/modules/ vt_dir_name
1798
1799 if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko ]; then
1800 set openwrt_plugin_need=0
1801 vt_img_extra_initrd_append (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko
1802 if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko ]; then
1803 vt_img_extra_initrd_append (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko
1804 fi
1805 else
1806 set openwrt_plugin_need=1
1807 if [ ! -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
1808 ventoy_gui_console
1809 echo -e "\n ventoy_openwrt.xz not found. Please refer https://www.ventoy.net/en/doc_openwrt.html.\n"
1810 echo -e " 未找到 ventoy_openwrt.xz 文件。请参考 https://www.ventoy.net/cn/doc_openwrt.html\n"
1811 echo -e "\n press ENTER to exit (请按 回车 键返回) ..."
1812 read vtInputKey
1813 ventoy_cli_console
1814 return
1815 fi
1816 fi
1817
1818 if vt_img_check_range "${vtoy_iso_part}${vt_chosen_path}"; then
1819 ventoy_debug_pause
1820 else
1821 ventoy_gui_console
1822 echo -e "\n IMG file need processed. Please refer https://www.ventoy.net/en/doc_openwrt.html.\n"
1823 echo -e " 此 IMG 文件必须处理之后才能支持。请参考 https://www.ventoy.net/cn/doc_openwrt.html\n"
1824 echo -e "\n press ENTER to exit (请按 回车 键返回) ..."
1825 read vtInputKey
1826 ventoy_cli_console
1827 return
1828 fi
1829
1830 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1831 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1832
1833 if [ $openwrt_plugin_need -eq 1 ]; then
1834 if [ -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
1835 vt_img_extra_initrd_append ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz
1836 fi
1837 fi
1838
1839 #boot image file
1840 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=openwrt
1841 vt_img_hook_root
1842
1843 set root=(vtimghd,1)
1844 configfile (vtimghd,1)/boot/grub/grub.cfg
1845
1846 vt_img_unhook_root
1847 vt_unset_boot_opt
1848 }
1849
1850 function ventoy_img_tails {
1851 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1852 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1853
1854 ventoy_debug_pause
1855
1856 #boot image file
1857 vt_set_boot_opt rdinit=/vtoy/vtoy live-media=/dev/dm-1 ventoyos=tails
1858 vt_img_hook_root
1859
1860 set root=(vtimghd,1)
1861 configfile (vtimghd,1)/efi/debian/grub.cfg
1862
1863 vt_img_unhook_root
1864 vt_unset_boot_opt
1865 }
1866
1867 function ventoy_img_fydeos {
1868 if [ "$grub_platform" = "pc" ]; then
1869 only_uefi_tip
1870 return
1871 fi
1872
1873 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=64"
1874 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1875
1876 ventoy_debug_pause
1877
1878 #boot image file
1879 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=fydeos
1880 vt_img_hook_root
1881
1882 set grubdisk=vtimghd
1883 set grubpartA=(vtimghd,3)
1884 set grubpartB=(vtimghd,5)
1885 set linuxpartA=(sda,3)
1886 set linuxpartB=(sda,5)
1887
1888 set root=(vtimghd,12)
1889 configfile (vtimghd,12)/efi/boot/grub.cfg
1890
1891 vt_img_unhook_root
1892 vt_unset_boot_opt
1893
1894 unset grubdisk
1895 unset grubpartA
1896 unset grubpartB
1897 unset linuxpartA
1898 unset linuxpartB
1899 }
1900
1901 function ventoy_img_cloudready {
1902 if [ "$grub_platform" = "pc" ]; then
1903 only_uefi_tip
1904 return
1905 fi
1906
1907 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=64"
1908 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1909
1910 ventoy_debug_pause
1911
1912 #boot image file
1913 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=cloudready
1914 vt_img_hook_root
1915
1916 set grubdisk=vtimghd
1917 set grubpartA=(vtimghd,3)
1918 set grubpartB=(vtimghd,5)
1919 set linuxpartA=(sda,3)
1920 set linuxpartB=(sda,5)
1921
1922 set root=(vtimghd,12)
1923 configfile (vtimghd,12)/efi/boot/grub.cfg
1924
1925 vt_img_unhook_root
1926 vt_unset_boot_opt
1927
1928 unset grubdisk
1929 unset grubpartA
1930 unset grubpartB
1931 unset linuxpartA
1932 unset linuxpartB
1933 }
1934
1935 function ventoy_img_memtest86 {
1936 chainloader (vtimghd,1)/efi/boot/BOOTX64.efi
1937 boot
1938 }
1939
1940 function img_unsupport_tip {
1941 echo -e "\n This IMG file is NOT supported now. \n"
1942 echo -e " 当前不支持启动此 IMG 文件 \n"
1943 echo -e "\npress ENTER to exit (请按 回车 键返回) ..."
1944 read vtInputKey
1945 }
1946
1947 function legacy_img_memdisk {
1948 linux16 $vtoy_path/memdisk
1949 echo "Loading img file to memory ..."
1950 initrd16 "${1}${2}"
1951
1952 ventoy_cli_console
1953 boot
1954 }
1955
1956 function img_common_menuentry {
1957 set ventoy_compatible=YES
1958 set ventoy_busybox_ver=32
1959 unset LoadIsoEfiDriver
1960
1961 vt_chosen_img_path vt_chosen_path vt_chosen_size
1962
1963 if vt_check_password "${vt_chosen_path}"; then
1964 return
1965 fi
1966
1967 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1968 return
1969 fi
1970
1971 if [ "$grub_platform" = "pc" ]; then
1972 if vt_check_mode 0; then
1973 legacy_img_memdisk $vtoy_iso_part "$vt_chosen_path"
1974 return
1975 fi
1976 fi
1977
1978 loopback vtimghd "${vtoy_iso_part}${vt_chosen_path}"
1979 vt_img_sector "${vtoy_iso_part}${vt_chosen_path}"
1980
1981 vt_img_part_info (vtimghd)
1982
1983 set vtback_root=$root
1984 ventoy_cli_console
1985 vt_push_last_entry
1986 set vtback_theme=$theme
1987 unset theme
1988
1989 vt_img_extra_initrd_reset
1990
1991
1992 vt_get_fs_label (vtimghd,1) vtImgHd1Label
1993
1994 if [ "$vtImgHd1Label" = "STATE" ]; then
1995 vt_get_fs_label (vtimghd,3) vtImgHd3Label
1996 elif [ -d (vtimghd,2)/lib ]; then
1997 vt_get_fs_label (vtimghd,2) vtImgHd2Label
1998 fi
1999
2000 if [ -e (vtimghd,1)/etc/hostname ]; then
2001 vt_1st_line (vtimghd,1)/etc/hostname vtImgHostname
2002 fi
2003
2004 if vt_str_begin "$vtImgHd3Label" "ROOT-"; then
2005 if [ -f (vtimghd,3)/etc/os-release.d/ID ]; then
2006 vt_1st_line (vtimghd,3)/etc/os-release.d/ID vt_release_line1
2007 if [ vt_str_begin "$vt_release_line1" "FydeOS" ]; then
2008 ventoy_img_fydeos
2009 fi
2010 elif [ -f (vtimghd,3)/etc/cloudready-release ]; then
2011 ventoy_img_cloudready
2012 fi
2013 elif vt_str_begin "$vtImgHd1Label" "LAKKA"; then
2014 ventoy_img_openelec lakka
2015 elif vt_str_begin "$vtImgHd1Label" "LIBREELEC"; then
2016 ventoy_img_openelec LibreELEC
2017 elif vt_str_begin "$vtImgHd1Label" "paldo-live"; then
2018 ventoy_img_paldo
2019 elif vt_str_begin "$vtImgHostname" "freedombox"; then
2020 ventoy_img_freedombox
2021 elif vt_str_begin "$vtImgHd1Label" "BATOCERA"; then
2022 ventoy_img_batocera
2023 elif vt_str_begin "$vtImgHd1Label" "Tails"; then
2024 ventoy_img_tails
2025 elif [ "$vtImgHd2Label" = "RECALBOX" -o "$vtImgHd1Label" = "RECALBOX" ]; then
2026 ventoy_img_recalbox
2027 elif [ "$vtImgHd1Label" = "ESYSRESCUE" ]; then
2028 ventoy_img_esysrescue
2029 elif [ -e (vtimghd,1)/easy.sfs ]; then
2030 ventoy_img_easyos
2031 elif [ -e (vtimghd,1)/volumio.initrd ]; then
2032 ventoy_img_volumio
2033 elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then
2034 ventoy_img_ubos
2035 elif [ -f (vtimghd,2)/etc/openwrt_version ]; then
2036 ventoy_img_openwrt
2037 elif [ -f (vtimghd,1)/efi/boot/mt86.png ]; then
2038 if [ "$grub_platform" = "pc" ]; then
2039 img_unsupport_tip
2040 else
2041 ventoy_img_memtest86
2042 fi
2043 else
2044 vt_linux_chain_data "${vtoy_iso_part}${vt_chosen_path}"
2045 ventoy_acpi_param ${vtoy_chain_mem_addr} 512
2046 if [ "$grub_platform" = "pc" ]; then
2047 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
2048 boot
2049 else
2050 chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi sector512 env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
2051 boot
2052 fi
2053 fi
2054
2055 loopback -d vtimghd
2056
2057 set root=$vtback_root
2058 vt_pop_last_entry
2059 set theme=$vtback_theme
2060 ventoy_gui_console
2061 set ventoy_compatible=NO
2062 }
2063
2064 function img_unsupport_menuentry {
2065 common_unsupport_menuentry
2066 }
2067
2068 #############################################################
2069 #############################################################
2070 #############################################################
2071 ####### Main Process ###########
2072 #############################################################
2073 #############################################################
2074 #############################################################
2075
2076 set VENTOY_VERSION="1.0.66"
2077
2078 #ACPI not compatible with Window7/8, so disable by default
2079 set VTOY_PARAM_NO_ACPI=1
2080
2081 # Default menu display mode, you can change it as you want.
2082 # 0: List mode
2083 # 1: TreeView mode
2084 set VTOY_DEFAULT_MENU_MODE=1
2085
2086 set VTOY_MEM_DISK_STR="[Memdisk]"
2087 set VTOY_ISO_RAW_STR="Compatible Mode"
2088 set VTOY_GRUB2_MODE_STR="GRUB2 Mode"
2089 set VTOY_WIMBOOT_MODE_STR="WIMBOOT Mode"
2090 set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
2091
2092 set VTOY_F2_CMD="ventoy_power"
2093 set VTOY_F4_CMD="ventoy_localboot"
2094 set VTOY_F5_CMD="ventoy_diagnosis"
2095 set VTOY_F6_CMD="ventoy_ext_menu"
2096 set VTOY_HELP_CMD="ventoy_show_help"
2097 set VTOY_CHKSUM_CMD="ventoy_checksum"
2098 set VTOY_HELP_TXT_LANGUAGE="en_US"
2099 set VTOY_CHKSUM_FILE_PATH="X"
2100
2101
2102 if [ "$grub_platform" = "pc" ]; then
2103 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net"
2104 else
2105 if [ "$grub_cpu" = "i386" ]; then
2106 set VTOY_EFI_ARCH=ia32
2107 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION IA32 www.ventoy.net"
2108 elif [ "$grub_cpu" = "arm64" ]; then
2109 set VTOY_EFI_ARCH=aa64
2110 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION AA64 www.ventoy.net"
2111 elif [ "$grub_cpu" = "mips64el" ]; then
2112 set VTOY_EFI_ARCH=mips
2113 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION MIPS www.ventoy.net"
2114 else
2115 set VTOY_EFI_ARCH=x64
2116 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION UEFI www.ventoy.net"
2117 fi
2118 fi
2119
2120 vt_device $root vtoy_dev
2121
2122 if [ "$vtoy_dev" = "tftp" ]; then
2123 set vtoy_path=($root)
2124 for vtid in 0 1 2 3; do
2125 if [ -f (hd$vtid,2)/ventoy/ventoy.cpio ]; then
2126 set vtoy_iso_part=(hd$vtid,1)
2127 set vtoy_efi_part=(hd$vtid,2)
2128 set vtoydev=hd$vtid
2129 break
2130 fi
2131 done
2132 loadfont ascii
2133
2134 if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
2135 set vt_plugin_path=$vtoy_iso_part
2136 else
2137 set vt_plugin_path=$prefix
2138 vt_load_plugin $vt_plugin_path
2139 fi
2140 else
2141 if [ "$prefix" = "(ventoydisk)/grub" ]; then
2142 set vtoy_path=(ventoydisk)/ventoy
2143 else
2144 set vtoy_path=($root)/ventoy
2145 fi
2146
2147 set vtoydev=$vtoy_dev
2148 set vtoy_iso_part=($vtoy_dev,1)
2149 set vtoy_efi_part=($vtoy_dev,2)
2150
2151 vt_load_file_to_mem "auto" $prefix/fonts/unicode.pf2 vtoy_font_mem
2152 loadfont mem:${vtoy_font_mem_addr}:size:${vtoy_font_mem_size}
2153
2154 set vt_plugin_path=$vtoy_iso_part
2155 fi
2156
2157 #Load Partition Table
2158 vt_load_part_table $vtoydev
2159
2160 #Load Plugin
2161 if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
2162 clear
2163 vt_load_plugin $vtoy_iso_part
2164 clear
2165 else
2166 vt_check_json_path_case $vtoy_iso_part
2167 fi
2168
2169 if [ -n "$VTOY_MENU_TIMEOUT" ]; then
2170 set timeout=$VTOY_MENU_TIMEOUT
2171 else
2172 unset timeout
2173 fi
2174
2175 if [ -f $vtoy_iso_part/ventoy/ventoy_wimboot.img ]; then
2176 vt_load_wimboot $vtoy_iso_part/ventoy/ventoy_wimboot.img
2177 elif [ -f $vtoy_efi_part/ventoy/ventoy_wimboot.img ]; then
2178 vt_load_wimboot $vtoy_efi_part/ventoy/ventoy_wimboot.img
2179 fi
2180
2181 if [ -f $vtoy_iso_part/ventoy/ventoy_vhdboot.img ]; then
2182 vt_load_vhdboot $vtoy_iso_part/ventoy/ventoy_vhdboot.img
2183 elif [ -f $vtoy_efi_part/ventoy/ventoy_vhdboot.img ]; then
2184 vt_load_vhdboot $vtoy_efi_part/ventoy/ventoy_vhdboot.img
2185 fi
2186
2187
2188 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
2189 set VTOY_F3_CMD="vt_dynamic_menu 1 1"
2190 set VTOY_HOTKEY_TIP="h:Help F1:Memdisk F2:Power F3:TreeView F4:Localboot F5:Tools F6:ExMenu"
2191 else
2192 set VTOY_F3_CMD="vt_dynamic_menu 1 0"
2193 set VTOY_HOTKEY_TIP="h:Help F1:Memdisk F2:Power F3:ListView F4:Localboot F5:Tools F6:ExMenu"
2194 fi
2195
2196 terminal_output console
2197
2198 if [ -n "$vtoy_gfxmode" ]; then
2199 set gfxmode=$vtoy_gfxmode
2200 set gfxpayload=keep
2201 else
2202 set gfxmode=1024x768
2203 set gfxpayload=keep
2204 fi
2205
2206
2207 if [ "$vtoy_display_mode" = "CLI" ]; then
2208 terminal_output console
2209 elif [ "$vtoy_display_mode" = "serial" ]; then
2210 if [ -n "$vtoy_serial_param" ]; then
2211 serial $vtoy_serial_param
2212 fi
2213 terminal_input serial
2214 terminal_output serial
2215 elif [ "$vtoy_display_mode" = "serial_console" ]; then
2216 if [ -n "$vtoy_serial_param" ]; then
2217 serial $vtoy_serial_param
2218 fi
2219 terminal_input serial console
2220 terminal_output serial console
2221 else
2222 if [ -n "$vtoy_theme" ]; then
2223 vt_set_theme
2224 else
2225 set theme=$prefix/themes/ventoy/theme.txt
2226 fi
2227 terminal_output gfxterm
2228 fi
2229
2230 if [ -n "$VTOY_DEFAULT_KBD_LAYOUT" ]; then
2231 set_keyboard_layout "$VTOY_DEFAULT_KBD_LAYOUT"
2232 fi
2233
2234 if [ -n "$VTOY_PLUGIN_PATH_CASE_MISMATCH" ]; then
2235 clear
2236 echo "$VTOY_PLUGIN_PATH_CASE_MISMATCH"
2237 echo -e "\n\nPath case does not match! ventoy directory and ventoy.json MUST be all lowercase!"
2238 echo -e "\n路径大小写不匹配!ventoy 目录和 ventoy.json 文件的名字必须是全部小写,请修正!"
2239 echo -e "\n\npress ENTER to continue (请按回车键继续) ..."
2240 read vtInputKey
2241 fi
2242
2243 if [ -n "$VTOY_PLUGIN_SYNTAX_ERROR" ]; then
2244 clear
2245 if [ -n "$VTOY_PLUGIN_ENCODE_ERROR" ]; then
2246 echo -e "\n Encoding type for ventoy.json is not supported, please convert to UTF-8.\n"
2247 echo -e " ventoy.json 文件编码格式不支持,请转换为 UTF-8 编码格式!\n"
2248 else
2249 echo -e "\n Syntax error detected in ventoy.json, please check! \n"
2250 echo -e " ventoy.json 文件中有语法错误,所有配置都不会生效,请检查!\n"
2251 fi
2252
2253 echo -e "\n press ENTER to continue (请按 回车 键继续) ..."
2254 read vtInputKey
2255 fi
2256
2257
2258 for vtTFile in ventoy.json ventoy_grub.cfg; do
2259 if [ -f $vtoy_efi_part/ventoy/$vtTFile ]; then
2260 clear
2261 echo -e "\n You need to put $vtTFile in the 1st partition which hold the ISO files.\n"
2262 echo -e " $vtTFile 放错分区了,请放到镜像分区里的 ventoy 目录下(此目录需要手动创建)!\n"
2263 echo -e "\n press ENTER to continue (请按 回车 键继续) ..."
2264 read vtInputKey
2265 fi
2266 done
2267
2268 #clear all input key before show main menu
2269 vt_clear_key
2270
2271 #export necessary variable
2272 export theme
2273 export gfxmode
2274 export gfxpayload
2275 export vtoydev
2276 export vtoy_path
2277 export vtdebug_flag
2278 export vtoy_iso_fs
2279 export vtoy_iso_part
2280 export vtoy_efi_part
2281 export VENTOY_VERSION
2282 export VTOY_CUR_VIDEO_MODE
2283 export VTOY_EFI_ARCH
2284 export VTOY_MEM_DISK_STR
2285 export VTOY_ISO_RAW_STR
2286 export VTOY_GRUB2_MODE_STR
2287 export VTOY_WIMBOOT_MODE_STR
2288 export VTOY_ISO_UEFI_DRV_STR
2289 export VTOY_F2_CMD
2290 export VTOY_F4_CMD
2291 export VTOY_F5_CMD
2292 export VTOY_F6_CMD
2293 export VTOY_HELP_CMD
2294 export VTOY_CHKSUM_CMD
2295 export VTOY_HELP_TXT_LANGUAGE
2296 export VTOY_CHKSUM_FILE_PATH
2297
2298
2299 #special VTOY_DEFAULT_IMAGE process
2300 if [ -n "$VTOY_DEFAULT_IMAGE" ]; then
2301 if regexp --set 1:vtHotkey --set 2:vtDefault "(F[2-9])>(.*)" "$VTOY_DEFAULT_IMAGE"; then
2302
2303 set default="$vtDefault"
2304 if [ -z "$VTOY_MENU_TIMEOUT" ]; then
2305 set timeout=0
2306 else
2307 set timeout=$VTOY_MENU_TIMEOUT
2308 fi
2309
2310 export timeout
2311 export default
2312
2313 if [ "$vtHotkey" = "F2" ]; then
2314 ventoy_power
2315 elif [ "$vtHotkey" = "F4" ]; then
2316 ventoy_localboot
2317 elif [ "$vtHotkey" = "F5" ]; then
2318 ventoy_diagnosis
2319 elif [ "$vtHotkey" = "F6" ]; then
2320 ventoy_ext_menu
2321 fi
2322
2323 unset timeout
2324 unset default
2325 fi
2326 fi
2327
2328 #colect all image files (iso files)
2329 set ventoy_img_count=0
2330 vt_list_img $vtoy_iso_part ventoy_img_count
2331
2332 #Main menu
2333 if [ $ventoy_img_count -gt 0 ]; then
2334 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
2335 vt_dynamic_menu 0 0
2336 else
2337 vt_dynamic_menu 0 1
2338 fi
2339 else
2340 if [ -n "$VTOY_NO_ISO_TIP" ]; then
2341 NO_ISO_MENU="No ISO files found, $VTOY_NO_ISO_TIP"
2342 elif [ -n "$VTOY_DEFAULT_SEARCH_ROOT" ]; then
2343 NO_ISO_MENU="No ISO files found, please check VTOY_DEFAULT_SEARCH_ROOT"
2344 else
2345 NO_ISO_MENU="No ISO files found"
2346 fi
2347 menuentry "$NO_ISO_MENU (Press enter to reboot ...)" {
2348 echo -e "\n Rebooting ... "
2349 reboot
2350 }
2351 fi