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