1 #************************************************************************************
2 # Copyright (c) 2020, longpanda <admin@ventoy.net>
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.
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.
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/>.
17 #************************************************************************************
19 function ventoy_pause {
20 echo "press Enter to continue ......"
24 function ventoy_debug_pause {
25 if [ -n "${vtdebug_flag}" ]; then
26 echo "press Enter to continue ......"
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
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
47 function ventoy_acpi_param {
48 if [ "$VTOY_PARAM_NO_ACPI" != "1" ]; then
49 vt_acpi_param "$1" "$2"
53 function ventoy_power {
54 configfile $prefix/power.cfg
57 function ventoy_diagnosis {
59 configfile $prefix/debug.cfg
62 function ventoy_localboot {
63 configfile $prefix/localboot.cfg
66 function ventoy_ext_menu {
67 if [ -e $vt_plugin_path/ventoy/ventoy_grub.cfg ]; then
68 set ventoy_new_context=1
69 configfile $vt_plugin_path/ventoy/ventoy_grub.cfg
70 unset ventoy_new_context
72 echo "ventoy_grub.cfg NOT exist."
73 echo -e "\npress ENTER to exit ..."
78 function get_os_type {
81 for file in "efi/microsoft/boot/bcd" "sources/boot.wim" "boot/bcd" "bootmgr.efi" "boot/etfsboot.com" ; do
82 if vt_file_exist_nocase (loop)/$file; then
88 if [ "$vtoy_os" = "Linux" ]; then
89 if vt_strstr "$vt_system_id" "FreeBSD"; then
91 set vt_unix_type=FreeBSD
92 elif [ -e (loop)/bin/freebsd-version ]; then
94 set vt_unix_type=FreeBSD
95 elif vt_str_begin "$vt_system_id" "DragonFly"; then
97 set vt_unix_type=DragonFly
100 elif [ -e (loop)/boot/kernel/kernel ]; then
101 if file --is-x86-kfreebsd (loop)/boot/kernel/kernel; then
103 set vt_unix_type=FreeBSD
104 elif file --is-x86-knetbsd (loop)/boot/kernel/kernel; then
106 set vt_unix_type=NetBSD
111 if [ -n "${vtdebug_flag}" ]; then
112 echo ISO is "$vtoy_os"
116 function vt_check_compatible_pe {
117 #Check for PE without external tools
118 if [ -f "$1/HBCD_PE.ini" ]; then
119 set ventoy_compatible=YES
123 function locate_initrd {
124 vt_linux_locate_initrd
126 if [ -n "${vtdebug_flag}" ]; then
132 function locate_wim {
133 vt_windows_locate_wim_patch (loop)
135 if [ -n "${vtdebug_flag}" ]; then
136 echo '###############################################'
138 echo '###############################################'
143 function distro_specify_wim_patch {
144 if [ -d (loop)/h3pe ]; then
145 vt_windows_collect_wim_patch wim /BOOT/H3_10PE.WIM
146 vt_windows_collect_wim_patch wim /BOOT/H3_7PE.WIM
147 vt_windows_collect_wim_patch wim /BOOT/H3_8PE.WIM
148 vt_windows_collect_wim_patch wim /BOOT/H3_81PE.WIM
152 function distro_specify_wim_patch_phase2 {
153 if [ -f (loop)/boot/boot.wim ]; then
154 vt_windows_collect_wim_patch wim /boot/boot.wim
159 function distro_specify_initrd_file {
160 if [ -e (loop)/boot/all.rdz ]; then
161 vt_linux_specify_initrd_file /boot/all.rdz
162 elif [ -e (loop)/boot/xen.gz ]; then
163 if [ -e (loop)/install.img ]; then
164 vt_linux_specify_initrd_file /install.img
166 elif [ -d (loop)/casper ]; then
167 if [ -e (loop)/casper/initrd ]; then
168 vt_linux_specify_initrd_file /casper/initrd
170 if [ -e (loop)/casper/initrd.gz ]; then
171 vt_linux_specify_initrd_file /casper/initrd.gz
173 if [ -e (loop)/casper/initrd-oem ]; then
174 vt_linux_specify_initrd_file /casper/initrd-oem
176 elif [ -e (loop)/boot/grub/initrd.xz ]; then
177 vt_linux_specify_initrd_file /boot/grub/initrd.xz
178 elif [ -e (loop)/initrd.gz ]; then
179 vt_linux_specify_initrd_file /initrd.gz
180 elif [ -e (loop)/slax/boot/initrfs.img ]; then
181 vt_linux_specify_initrd_file /slax/boot/initrfs.img
182 elif [ -e (loop)/pmagic/initrd.img ]; then
183 vt_linux_specify_initrd_file /pmagic/initrd.img
184 elif [ -e (loop)/boot/initrd.xz ]; then
185 vt_linux_specify_initrd_file /boot/initrd.xz
186 elif [ -e (loop)/boot/initrd.gz ]; then
187 vt_linux_specify_initrd_file /boot/initrd.gz
188 elif [ -f (loop)/boot/initrd ]; then
189 vt_linux_specify_initrd_file /boot/initrd
190 elif [ -f (loop)/boot/x86_64/loader/initrd ]; then
191 vt_linux_specify_initrd_file /boot/x86_64/loader/initrd
192 elif [ -f (loop)/boot/initramfs-x86_64.img ]; then
193 vt_linux_specify_initrd_file /boot/initramfs-x86_64.img
194 elif [ -f (loop)/boot/isolinux/initramfs_data64.cpio.gz ]; then
195 vt_linux_specify_initrd_file /boot/isolinux/initramfs_data64.cpio.gz
200 if [ -f (loop)/isolinux/initrd.gz ]; then
201 vt_linux_specify_initrd_file /isolinux/initrd.gz
204 if [ "$vt_chosen_size" = "1133375488" ]; then
205 if [ -d (loop)/boot/grub/x86_64-efi ]; then
206 vt_cpio_busybox64 "64h"
212 function distro_specify_initrd_file_phase2 {
213 if [ -f (loop)/boot/initrd.img ]; then
214 vt_linux_specify_initrd_file /boot/initrd.img
215 elif [ -f (loop)/Setup/initrd.gz ]; then
216 vt_linux_specify_initrd_file /Setup/initrd.gz
217 elif [ -f (loop)/isolinux/initramfs ]; then
218 vt_linux_specify_initrd_file /isolinux/initramfs
219 elif [ -f (loop)/boot/iniramfs.igz ]; then
220 vt_linux_specify_initrd_file /boot/iniramfs.igz
221 elif [ -f (loop)/initrd-x86_64 ]; then
222 vt_linux_specify_initrd_file /initrd-x86_64
223 elif [ -f (loop)/live/initrd.img ]; then
224 vt_linux_specify_initrd_file /live/initrd.img
225 elif [ -f (loop)/initrd.img ]; then
226 vt_linux_specify_initrd_file /initrd.img
227 elif [ -f (loop)/sysresccd/boot/x86_64/sysresccd.img ]; then
228 vt_linux_specify_initrd_file /sysresccd/boot/x86_64/sysresccd.img
229 elif [ -f (loop)/CDlinux/initrd ]; then
230 vt_linux_specify_initrd_file /CDlinux/initrd
231 elif [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
232 vt_linux_specify_initrd_file /parabola/boot/x86_64/parabolaiso.img
233 if [ -f (loop)/parabola/boot/i686/parabolaiso.img ]; then
234 vt_linux_specify_initrd_file /parabola/boot/i686/parabolaiso.img
236 elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then
237 vt_linux_specify_initrd_file /parabola/boot/x86_64/initramfs-linux-libre.img
238 if [ -f (loop)/parabola/boot/i686/initramfs-linux-libre.img ]; then
239 vt_linux_specify_initrd_file /parabola/boot/i686/initramfs-linux-libre.img
241 elif [ -f (loop)/hyperbola/boot/x86_64/hyperiso.img ]; then
242 vt_linux_specify_initrd_file /hyperbola/boot/x86_64/hyperiso.img
243 if [ -f (loop)/hyperbola/boot/i686/hyperiso.img ]; then
244 vt_linux_specify_initrd_file /hyperbola/boot/i686/hyperiso.img
246 elif [ -f (loop)/EFI/BOOT/initrd.img ]; then
248 vt_linux_specify_initrd_file /EFI/BOOT/initrd.img
249 if [ "$grub_platform" != "pc" ]; then
250 vt_add_replace_file 0 "initrd.img"
252 elif [ -f (loop)/initrd ]; then
253 vt_linux_specify_initrd_file /initrd
254 elif [ -f (loop)/live/initrd1 ]; then
255 vt_linux_specify_initrd_file /live/initrd1
256 elif [ -f (loop)/isolinux/initrd.img ]; then
257 vt_linux_specify_initrd_file /isolinux/initrd.img
258 elif [ -f (loop)/isolinux/initrd.gz ]; then
259 vt_linux_specify_initrd_file /isolinux/initrd.gz
260 elif [ -f (loop)/syslinux/kernel/initramfs.gz ]; then
261 vt_linux_specify_initrd_file /syslinux/kernel/initramfs.gz
262 elif vt_strstr "$vt_volume_id" "Daphile"; then
263 vt_linux_parse_initrd_isolinux (loop)/isolinux/
264 elif [ -f (loop)/boot/rootfs.xz ]; then
265 vt_linux_specify_initrd_file /boot/rootfs.xz
266 if [ "$grub_platform" != "pc" ]; then
267 vt_add_replace_file 0 "minimal\\x86_64\\rootfs.xz"
269 elif [ -f (loop)/arch/boot/x86_64/archiso.img ]; then
270 vt_linux_specify_initrd_file /arch/boot/x86_64/archiso.img
271 if [ "$grub_platform" != "pc" ]; then
272 vt_add_replace_file 0 "EFI\\archiso\\archiso.img"
274 elif [ -f (loop)/blackarch/boot/x86_64/archiso.img ]; then
275 vt_linux_specify_initrd_file /blackarch/boot/x86_64/archiso.img
276 elif [ -f (loop)/blackarch/boot/x86_64/initramfs-linux.img ]; then
277 vt_linux_specify_initrd_file /blackarch/boot/x86_64/initramfs-linux.img
279 elif [ -f (loop)/install.amd/initrd.gz ]; then
280 vt_linux_specify_initrd_file /live/initrd2.img
281 vt_linux_specify_initrd_file /install.amd/initrd.gz
282 vt_linux_specify_initrd_file /install.amd/gtk/initrd.gz
283 elif [ -f (loop)/boot/grub/kernels.cfg ]; then
284 vt_linux_parse_initrd_grub file (loop)/boot/grub/kernels.cfg
285 elif [ -f (loop)/austrumi/initrd.gz ]; then
286 vt_linux_specify_initrd_file /austrumi/initrd.gz
287 if [ -f (loop)/EFI/BOOT/bootx64.efi ]; then
288 vt_cpio_busybox64 "64h"
290 elif [ -f (loop)/boot/initfs.x86_64-efi ]; then
291 vt_linux_specify_initrd_file /boot/initfs.x86_64-efi
292 if [ -f (loop)/boot/initfs.i386-pc ]; then
293 vt_linux_specify_initrd_file /boot/initfs.i386-pc
295 elif [ -f (loop)/antiX/initrd.gz ]; then
296 vt_linux_specify_initrd_file /antiX/initrd.gz
297 elif [ -f (loop)/360Disk/initrd.gz ]; then
298 vt_linux_specify_initrd_file /360Disk/initrd.gz
303 function ventoy_get_ghostbsd_ver {
305 # vt_parse_iso_create_date "$1/${chosen_path}" vt_create_date
306 # if regexp "^202005" "$vt_create_date"; then
307 # set vt_freebsd_ver=12.x
310 set vt_freebsd_ver=12.x
313 function ventoy_get_furybsd_ver {
314 if regexp "13\.[0-9]" "$2"; then
315 set vt_freebsd_ver=13.x
317 set vt_freebsd_ver=12.x
321 function ventoy_get_freenas_ver {
322 set vt_freebsd_ver=11.x
324 if [ -e (loop)/FreeNAS-MANIFEST ]; then
325 vt_parse_freenas_ver (loop)/FreeNAS-MANIFEST vt_freenas_ver
326 if regexp "^13\.[0-9]" "$vt_freenas_ver"; then
327 set vt_freebsd_ver=13.x
328 elif regexp "^12\.[0-9]" "$vt_freenas_ver"; then
329 set vt_freebsd_ver=12.x
330 elif regexp "^11\.[0-9]" "$vt_freenas_ver"; then
331 set vt_freebsd_ver=11.x
336 function ventoy_get_truenas_ver {
337 set vt_freebsd_ver=12.x
339 if [ -e (loop)/TrueNAS-MANIFEST ]; then
340 vt_parse_freenas_ver (loop)/TrueNAS-MANIFEST vt_truenas_ver
341 if regexp "^13\.[0-9]" "$vt_truenas_ver"; then
342 set vt_freebsd_ver=13.x
343 elif regexp "^12\.[0-9]" "$vt_truenas_ver"; then
344 set vt_freebsd_ver=12.x
345 elif regexp "^11\.[0-9]" "$vt_truenas_ver"; then
346 set vt_freebsd_ver=11.x
351 function ventoy_get_midnightbsd_ver {
352 set vt_freebsd_ver=11.x
355 function ventoy_freebsd_proc {
356 set vtFreeBsdDistro=FreeBSD
358 if vt_strstr "$vt_volume_id" "GHOSTBSD"; then
359 ventoy_get_ghostbsd_ver "$1" "${chosen_path}"
360 elif vt_strstr "$vt_volume_id" "FREENAS"; then
361 ventoy_get_freenas_ver "$1" "${chosen_path}"
362 elif vt_strstr "$vt_volume_id" "TRUENAS"; then
363 ventoy_get_truenas_ver "$1" "${chosen_path}"
364 elif vt_strstr "$vt_volume_id" "FURYBSD"; then
365 ventoy_get_furybsd_ver "$1" "${chosen_path}"
366 elif regexp "^13_[0-9]" "$vt_volume_id"; then
367 set vt_freebsd_ver=13.x
368 elif regexp "^12_[0-9]" "$vt_volume_id"; then
369 set vt_freebsd_ver=12.x
370 elif regexp "^11_[0-9]" "$vt_volume_id"; then
371 set vt_freebsd_ver=11.x
372 elif regexp "^10_[0-9]" "$vt_volume_id"; then
373 set vt_freebsd_ver=10.x
374 elif regexp "^9_[0-9]" "$vt_volume_id"; then
375 set vt_freebsd_ver=9.x
376 elif [ -d (loop)/usr/midnightbsd-dist ]; then
377 ventoy_get_midnightbsd_ver "$1" "${chosen_path}"
378 set vtFreeBsdDistro=MidnightBSD
379 elif [ -e (loop)/bin/freebsd-version ]; then
380 vt_unix_parse_freebsd_ver (loop)/bin/freebsd-version vt_userland_ver
381 if regexp "\"13\.[0-9]-" "$vt_userland_ver"; then
382 set vt_freebsd_ver=13.x
383 elif regexp "\"12\.[0-9]-" "$vt_userland_ver"; then
384 set vt_freebsd_ver=12.x
385 elif regexp "\"11\.[0-9]-" "$vt_userland_ver"; then
386 set vt_freebsd_ver=11.x
387 elif regexp "\"10\.[0-9]-" "$vt_userland_ver"; then
388 set vt_freebsd_ver=10.x
389 elif regexp "\"9\.[0-9]-" "$vt_userland_ver"; then
390 set vt_freebsd_ver=9.x
392 elif [ -e (loop)/README.TXT ]; then
393 vt_1st_line (loop)/README.TXT vt_freebsd_line1
394 if regexp "FreeBSD 13\.[0-9]-" "$vt_freebsd_line1"; then
395 set vt_freebsd_ver=13.x
396 elif regexp "FreeBSD 12\.[0-9]-" "$vt_freebsd_line1"; then
397 set vt_freebsd_ver=12.x
398 elif regexp "FreeBSD 11\.[0-9]-" "$vt_freebsd_line1"; then
399 set vt_freebsd_ver=11.x
400 elif regexp "FreeBSD 10\.[0-9]-" "$vt_freebsd_line1"; then
401 set vt_freebsd_ver=10.x
402 elif regexp "FreeBSD 9\.[0-9]-" "$vt_freebsd_line1"; then
403 set vt_freebsd_ver=9.x
405 elif vt_strstr "${chosen_path}" "MidnightBSD"; then
406 set vt_freebsd_ver=9.x
408 set vt_freebsd_ver=12.x
411 set vt_freebsd_bit=64
412 for file in "/boot/kernel/kernel" "/boot/kernel/kernel.gz"; do
413 if [ -e (loop)/$file ]; then
414 if file --is-i386-kfreebsd (loop)/$file; then
415 set vt_freebsd_bit=32
421 if [ -n "${vtdebug_flag}" ]; then
422 echo "This is FreeBSD $vt_freebsd_ver ${vt_freebsd_bit}bit"
425 unset vt_unix_mod_path
426 for file in "/COPYRIGHT" "/FreeNAS-MANIFEST" "/TrueNAS-MANIFEST" "/version" "/etc/fstab"; do
427 if [ -e (loop)${file} ]; then
428 set vt_unix_mod_path=${file}
433 if [ -e (loop)/usr/freebsd-dist/cloninst.sh ]; then
434 set vtFreeBsdDistro=ClonOS
437 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
438 vt_unix_replace_conf FreeBSD "${1}${chosen_path}"
441 function ventoy_dragonfly_proc {
443 unset vt_unix_mod_path
444 for file in "/boot/kernel/initrd.img.gz"; do
445 if [ -e (loop)${file} ]; then
446 set vt_unix_mod_path=${file}
451 vt_unix_replace_ko $vt_unix_mod_path ${vtoy_path}/dragonfly.mfs.xz
452 vt_unix_fill_image_desc
454 vt_unix_replace_conf DragonFly "${1}${chosen_path}"
457 function ventoy_unix_comm_proc {
460 if [ "$ventoy_compatible" = "NO" ]; then
461 loopback vtunix $vtoy_efi_part/ventoy/ventoy_unix.cpio
463 if [ "$vt_unix_type" = "FreeBSD" ]; then
464 ventoy_freebsd_proc "$1" "${chosen_path}"
465 elif [ "$vt_unix_type" = "DragonFly" ]; then
466 ventoy_dragonfly_proc "$1" "${chosen_path}"
467 elif [ "$vt_unix_type" = "NetBSD" ]; then
468 echo "NetBSD not supported"
472 if [ -n "${vtdebug_flag}" ]; then
473 echo "Unknown unix type"
478 vt_unix_chain_data "${1}${chosen_path}"
483 function uefi_windows_menu_func {
486 if [ "$ventoy_compatible" = "NO" ]; then
488 if [ "$ventoy_fs_probe" = "iso9660" ]; then
490 vt_iso9660_nojoliet 1
494 for file in "efi/microsoft/boot/bcd"; do
495 vt_windows_collect_wim_patch bcd (loop)/$file
498 vt_windows_count_wim_patch vt_wim_cnt
499 if [ $vt_wim_cnt -eq 0 ]; then
500 distro_specify_wim_patch_phase2
507 vt_windows_chain_data "${1}${chosen_path}"
510 if [ -n "$vtoy_chain_mem_addr" ]; then
511 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
513 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}
516 echo "chain empty failed"
521 function uefi_linux_menu_func {
523 if [ "$ventoy_compatible" = "NO" ]; then
525 if [ "$ventoy_fs_probe" = "udf" ]; then
527 set ventoy_fs_probe=iso9660
531 vt_load_cpio ${vtoy_path}/ventoy.cpio "$2" "$1" "busybox=$ventoy_busybox_ver"
533 vt_linux_clear_initrd
535 if [ -d (loop)/pmagic ]; then
536 vt_linux_specify_initrd_file /pmagic/initrd.img
538 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
539 if [ -e (loop)/$file ]; then
540 vt_linux_parse_initrd_grub file (loop)/$file
545 # special process for special distros
546 if [ -d (loop)/loader/entries ]; then
547 vt_linux_parse_initrd_grub dir (loop)/loader/entries/
548 elif [ -d (loop)/boot/grub ]; then
549 vt_linux_parse_initrd_grub dir (loop)/boot/grub/
552 distro_specify_initrd_file
554 vt_linux_initrd_count vtcount
556 if [ $vtcount -eq 0 ]; then
557 distro_specify_initrd_file_phase2
559 if [ "$vt_efi_dir" = "NO" ]; then
560 if [ -f (loop)/efi.img ]; then
561 vt_add_replace_file 0 "initrd"
568 if [ -d (loop)/loader/entries ]; then
569 vt_linux_get_main_initrd_index vtindex
571 if [ -d (loop)/arch ]; then
572 if [ -f (loop)/arch/boot/x86_64/archiso.img ]; then
573 vt_add_replace_file $vtindex "EFI\\archiso\\archiso.img"
574 elif [ -f (loop)/arch/boot/x86_64/initramfs-linux.img ]; then
575 vt_add_replace_file $vtindex "arch\\boot\\x86_64\\initramfs-linux.img"
576 elif [ -f (loop)/boot/initramfs_x86_64.img ]; then
577 vt_add_replace_file $vtindex "boot\\initramfs_x86_64.img"
579 elif [ -d (loop)/blackarch ]; then
580 if [ -f (loop)/blackarch/boot/x86_64/archiso.img ]; then
581 vt_add_replace_file $vtindex "EFI\\archiso\\archiso.img"
582 elif [ -f (loop)/blackarch/boot/x86_64/initramfs-linux.img ]; then
583 vt_add_replace_file $vtindex "blackarch\\boot\\x86_64\\initramfs-linux.img"
585 elif [ -d (loop)/anarchy ]; then
586 if [ -f (loop)/anarchy/boot/x86_64/initramfs-linux.img ]; then
587 vt_add_replace_file $vtindex "anarchy\\boot\\x86_64\\initramfs-linux.img"
589 elif [ -d (loop)/parabola ]; then
590 if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
591 vt_add_replace_file $vtindex "EFI\\parabolaiso\\parabolaiso.img"
592 elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then
593 vt_add_replace_file $vtindex "parabola\\boot\\x86_64\\initramfs-linux-libre.img"
595 elif [ -f (loop)/EFI/BOOT/initrd.gz ]; then
596 vt_add_replace_file $vtindex "EFI\\BOOT\\initrd.gz"
597 elif [ -f (loop)/loader/entries/thinstation.conf ]; then
598 vt_add_replace_file $vtindex "boot\\initrd"
599 elif [ -f (loop)/loader/entries/pisi-efi-x86_64.conf ]; then
600 vt_add_replace_file $vtindex "EFI\\pisi\\initrd.img"
602 elif [ -d (loop)/EFI/boot/entries ]; then
603 if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
604 vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
605 elif [ -f (loop)/hyperbola/boot/x86_64/hyperiso.img ]; then
606 vt_add_replace_file 0 "EFI\\hyperiso\\hyperiso.img"
608 elif [ -d (loop)/EFI/BOOT/entries ]; then
609 if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
610 vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
611 elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then
612 vt_add_replace_file $vtindex "parabola\\boot\\x86_64\\initramfs-linux-libre.img"
614 elif [ -e (loop)/syslinux/alt0/full.cz ]; then
615 vt_add_replace_file 0 "EFI\\BOOT\\full.cz"
616 set FirstTryBootFile='@EFI@BOOT@grubx64.efi'
623 vt_linux_chain_data "${1}${chosen_path}"
625 if [ -n "$LoadIsoEfiDriver" -a $vt_chosen_size -lt 104857600 ]; then
626 if [ -f (loop)/efi/clover/cloverx64.efi ]; then
627 unset LoadIsoEfiDriver
631 if [ -n "$vtoy_chain_mem_addr" ]; then
632 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
634 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}
637 echo "chain empty failed"
642 function uefi_unix_menu_func {
643 ventoy_unix_comm_proc $1 "${chosen_path}"
645 if [ -n "$vtoy_chain_mem_addr" ]; then
646 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
648 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}
651 echo "chain empty failed"
656 function uefi_iso_menu_func {
658 if [ -d (loop)/ ]; then
662 if [ -n "$vtisouefi" ]; then
663 set LoadIsoEfiDriver=on
665 elif vt_check_mode 2; then
666 set LoadIsoEfiDriver=on
668 unset LoadIsoEfiDriver
672 vt_select_auto_install "${chosen_path}"
673 vt_select_persistence "${chosen_path}"
675 if vt_is_udf "${1}${chosen_path}"; then
676 set ventoy_fs_probe=udf
678 set ventoy_fs_probe=iso9660
679 vt_iso9660_nojoliet 0
682 loopback loop "${1}${chosen_path}"
685 if [ -d (loop)/EFI ]; then
687 elif [ -d (loop)/efi ]; then
693 if [ -n "$vtcompat" ]; then
694 set ventoy_compatible=YES
696 elif vt_check_mode 1; then
697 set ventoy_compatible=YES
699 vt_check_compatible (loop)
702 vt_img_sector "${1}${chosen_path}"
704 if [ "$ventoy_fs_probe" = "iso9660" ]; then
705 vt_select_conf_replace "${1}" "${chosen_path}"
708 if [ "$vtoy_os" = "Windows" ]; then
709 vt_check_compatible_pe (loop)
710 uefi_windows_menu_func "$1" "${chosen_path}"
711 elif [ "$vtoy_os" = "Unix" ]; then
712 uefi_unix_menu_func "$1" "${chosen_path}"
714 uefi_linux_menu_func "$1" "${chosen_path}"
720 function uefi_iso_memdisk {
721 echo 'Loading ISO file to memory ...'
722 vt_load_img_memdisk "${1}${2}" vtoy_iso_buf
725 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}
732 function legacy_windows_menu_func {
735 if [ "$ventoy_compatible" = "NO" ]; then
737 if [ "$ventoy_fs_probe" = "iso9660" ]; then
739 vt_iso9660_nojoliet 1
743 for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD"; do
744 vt_windows_collect_wim_patch bcd (loop)/$file
747 distro_specify_wim_patch
749 vt_windows_count_wim_patch vt_wim_cnt
750 if [ $vt_wim_cnt -eq 0 ]; then
751 distro_specify_wim_patch_phase2
758 vt_windows_chain_data "${1}${chosen_path}"
761 if [ -n "$vtoy_chain_mem_addr" ]; then
762 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
763 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
766 echo "chain empty failed"
771 function legacy_linux_menu_func {
772 if [ "$ventoy_compatible" = "NO" ]; then
774 if [ "$ventoy_fs_probe" = "udf" ]; then
776 set ventoy_fs_probe=iso9660
780 vt_load_cpio $vtoy_path/ventoy.cpio "$2" "$1" "busybox=$ventoy_busybox_ver"
782 vt_linux_clear_initrd
784 if [ -d (loop)/pmagic ]; then
785 vt_linux_specify_initrd_file /pmagic/initrd.img
787 for dir in "isolinux" "boot/isolinux" "boot/x86_64/loader" "syslinux" "boot/syslinux"; do
788 if [ -d (loop)/$dir ]; then
789 vt_linux_parse_initrd_isolinux (loop)/$dir/
794 # special process for special distros
796 if [ -d (loop)/arch/boot/syslinux ]; then
797 vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/
798 vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/boot/syslinux/
799 elif [ -d (loop)/anarchy/boot/syslinux ]; then
800 vt_linux_parse_initrd_isolinux (loop)/anarchy/boot/syslinux/ /anarchy/
803 elif [ -d (loop)/manjaro ]; then
804 if [ -e (loop)/boot/grub/kernels.cfg ]; then
805 vt_linux_parse_initrd_grub file (loop)/boot/grub/kernels.cfg
807 elif [ -e (loop)/boot/grub/grub.cfg ]; then
808 vt_linux_parse_initrd_grub file (loop)/boot/grub/grub.cfg
811 distro_specify_initrd_file
813 vt_linux_initrd_count vtcount
814 if [ $vtcount -eq 0 ]; then
815 if [ -d (loop)/rancheros ]; then
816 vt_linux_parse_initrd_isolinux (loop)/boot/ /boot/isolinux/
819 distro_specify_initrd_file_phase2
825 vt_linux_chain_data "${1}${chosen_path}"
828 if [ -n "$vtoy_chain_mem_addr" ]; then
829 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
830 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
833 echo "chain empty failed"
839 function legacy_unix_menu_func {
840 ventoy_unix_comm_proc $1 "${chosen_path}"
842 if [ -n "$vtoy_chain_mem_addr" ]; then
843 #ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
844 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
847 echo "chain empty failed"
853 function legacy_iso_menu_func {
855 if [ -d (loop)/ ]; then
861 vt_select_auto_install "${chosen_path}"
862 vt_select_persistence "${chosen_path}"
864 if vt_is_udf "${1}${chosen_path}"; then
865 set ventoy_fs_probe=udf
867 set ventoy_fs_probe=iso9660
868 vt_iso9660_nojoliet 0
871 loopback loop "${1}${chosen_path}"
875 if [ -n "$vtcompat" ]; then
876 set ventoy_compatible=YES
878 elif vt_check_mode 1; then
879 set ventoy_compatible=YES
881 vt_check_compatible (loop)
884 vt_img_sector "${1}${chosen_path}"
886 if [ "$ventoy_fs_probe" = "iso9660" ]; then
887 vt_select_conf_replace "${1}" "${chosen_path}"
890 if [ "$vtoy_os" = "Windows" ]; then
891 vt_check_compatible_pe (loop)
892 legacy_windows_menu_func "$1" "${chosen_path}"
893 elif [ "$vtoy_os" = "Unix" ]; then
894 legacy_unix_menu_func "$1" "${chosen_path}"
896 legacy_linux_menu_func "$1" "${chosen_path}"
900 function legacy_iso_memdisk {
902 linux16 $vtoy_path/memdisk iso raw
903 echo "Loading ISO file to memory ..."
909 function iso_endless_os_proc {
910 if [ -d (loop)/ ]; then
914 loopback loop "${1}${2}"
915 vt_img_sector "${1}${2}"
917 vt_load_cpio $vtoy_path/ventoy.cpio "$2" "$1" "busybox=$ventoy_busybox_ver"
918 vt_trailer_cpio "$1" "$2" noinit
922 vt_set_boot_opt '@kparams' rdinit=/vtoy/vtoy
925 set ventoy_bls_bootdev=/boot
926 set ventoy_loading_tip="Loading files ......"
929 configfile (loop)/endless/grub/grub.cfg
932 unset ventoy_bls_bootdev
933 unset ventoy_loading_tip
939 function ventoy_iso_busybox_ver {
941 if [ "$VTOY_EFI_ARCH" = "aa64" ]; then
942 set ventoy_busybox_ver=a64
944 set ventoy_busybox_ver=32
946 #special process for deepin-live iso
947 if [ "$vt_chosen_size" = "403701760" ]; then
948 if vt_str_str "$vt_chosen_path" "/deepin-live"; then
949 set ventoy_busybox_ver=64
951 elif vt_str_begin "$vt_volume_id" "PHOTON_"; then
952 set ventoy_busybox_ver=64
953 elif vt_str_begin "$vt_volume_id" "smgl-test-quinq-x86_64"; then
954 set ventoy_busybox_ver=64
955 elif vt_str_begin "$vt_volume_id" "LDiagBootable"; then
956 set ventoy_busybox_ver=64
962 function iso_common_menuentry {
966 vt_chosen_img_path vt_chosen_path vt_chosen_size
967 vt_parse_iso_volume "${vtoy_iso_part}${vt_chosen_path}" vt_system_id vt_volume_id
969 if vt_check_password "${vt_chosen_path}"; then
973 if vt_str_begin "$vt_volume_id" "Avira"; then
974 vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}"
977 ventoy_iso_busybox_ver
979 #special process for Endless OS
980 if vt_str_begin "$vt_volume_id" "Endless-OS"; then
981 iso_endless_os_proc $vtoy_iso_part "$vt_chosen_path"
982 elif vt_str_begin "$vt_volume_id" "TENS-Public"; then
986 if [ "$grub_platform" = "pc" ]; then
987 if vt_check_mode 0; then
988 legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
990 legacy_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
993 if vt_check_mode 0; then
994 uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
996 uefi_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
1001 function miso_common_menuentry {
1002 vt_chosen_img_path vt_chosen_path vt_chosen_size
1004 if vt_check_password "${vt_chosen_path}"; then
1008 echo "memdisk mode boot for $vt_chosen_path"
1012 if [ "$grub_platform" = "pc" ]; then
1013 legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1015 uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1020 function common_unsupport_menuentry {
1021 echo -e "\n The name of the iso file could NOT contain space or non-ascii characters. \n"
1022 echo -e " 文件名中不能有中文或空格 \n"
1023 echo -e "\npress ENTER to exit (请按 回车 键返回) ..."
1027 function miso_unsupport_menuentry {
1028 common_unsupport_menuentry
1031 function iso_unsupport_menuentry {
1032 common_unsupport_menuentry
1035 function wim_common_menuentry {
1036 vt_chosen_img_path vt_chosen_path vt_chosen_size
1038 if vt_check_password "${vt_chosen_path}"; then
1042 if vt_wim_check_bootable "${vtoy_iso_part}${vt_chosen_path}"; then
1043 vt_wim_chain_data "${vtoy_iso_part}${vt_chosen_path}"
1045 echo -e "\n This is NOT a bootable WIM file. \n"
1046 echo -e " 这不是一个可启动的 WIM 文件。\n"
1051 if [ -n "$vtoy_chain_mem_addr" ]; then
1052 if [ "$grub_platform" = "pc" ]; then
1053 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1056 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}
1061 echo "chain empty failed"
1066 function wim_unsupport_menuentry {
1067 common_unsupport_menuentry
1070 function efi_common_menuentry {
1071 vt_chosen_img_path vt_chosen_path vt_chosen_size
1073 if vt_check_password "${vt_chosen_path}"; then
1077 vt_concat_efi_iso "${vtoy_iso_part}${vt_chosen_path}" vtoy_iso_buf
1083 unset vtoy_dotefi_retry
1084 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}
1087 if [ -n "$vtoy_dotefi_retry" ]; then
1088 unset vtoy_dotefi_retry
1089 chainloader "${vtoy_iso_part}${vt_chosen_path}"
1096 function efi_unsupport_menuentry {
1097 common_unsupport_menuentry
1100 function vhd_common_menuentry {
1102 if [ "$VTOY_VHD_NO_WARNING" != "1" ]; then
1103 if [ "$vtoy_iso_fs" != "ntfs" ]; then
1104 echo -e "!!! WARNING !!!\n"
1105 echo -e "\nPartition1 ($vtoy_iso_fs) is NOT ntfs, the VHD(x) file may not boot normally \n"
1106 echo -e "\nVHD(x) 文件所在分区不是 ntfs 格式, 可能无法正常启动 \n\n"
1107 echo -n "press ENTER to continue boot (请按 回车 键继续) ..."
1112 vt_chosen_img_path vt_chosen_path vt_chosen_size
1114 if vt_check_password "${vt_chosen_path}"; then
1118 vt_patch_vhdboot "$vt_chosen_path"
1122 if [ -n "$vtoy_vhd_buf_addr" ]; then
1123 if [ "$grub_platform" = "pc" ]; then
1124 linux16 $vtoy_path/memdisk iso raw
1125 initrd16 mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size}
1129 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}
1134 echo "Please put the right ventoy_vhdboot.img file to the 1st partition"
1139 function vhd_unsupport_menuentry {
1140 common_unsupport_menuentry
1143 function vtoyboot_common_func {
1147 vt_get_vtoy_type "${1}" vtoytype parttype AltBootPart
1149 if vt_str_begin $vtoytype vhd; then
1151 elif [ "$vtoytype" = "raw" ]; then
1153 elif [ "$vtoytype" = "vdi" ]; then
1157 if [ $vtoysupport -eq 1 ]; then
1158 if [ "$grub_platform" = "pc" ]; then
1159 if [ "$parttype" = "gpt" -a $AltBootPart -eq 0 ]; then
1160 echo "The OS in the vdisk was created in UEFI mode, but current is Legacy BIOS mode."
1161 echo "虚拟磁盘内的系统是在UEFI模式下创建的,而当前系统是Legacy BIOS模式,可能无法正常启动。"
1165 if [ "$parttype" = "mbr" -a $AltBootPart -eq 0 ]; then
1166 echo "The OS in the vdisk was created in Legacy BIOS mode, but current is UEFI mode."
1167 echo "虚拟磁盘内的系统是在Legacy BIOS模式下创建的,而当前系统是UEFI模式,可能无法正常启动。"
1172 vt_img_sector "${1}"
1173 vt_raw_chain_data "${1}"
1177 if [ -n "$vtoy_chain_mem_addr" ]; then
1178 if [ "$grub_platform" = "pc" ]; then
1179 vt_acpi_param ${vtoy_chain_mem_addr} 512
1180 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} bios80 sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1183 vt_acpi_param ${vtoy_chain_mem_addr} 512
1185 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}
1190 echo "chain empty failed!"
1194 echo "Unsupported vtoy type $vtoytype"
1199 function vtoy_common_menuentry {
1200 vt_chosen_img_path vt_chosen_path vt_chosen_size
1202 if vt_check_password "${vt_chosen_path}"; then
1206 vtoyboot_common_func "${vtoy_iso_part}${vt_chosen_path}"
1209 function vtoy_unsupport_menuentry {
1210 common_unsupport_menuentry
1214 #============================================================#
1215 # IMG file boot process #
1216 #============================================================#
1220 function ventoy_img_easyos {
1221 vt_load_cpio $vtoy_path/ventoy.cpio "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1222 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1224 loopback easysfs (vtimghd,1)/easy.sfs
1225 vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver
1227 if [ -n "$vt_module_ver" ]; then
1228 for mod in "kernel/drivers/md/dm-mod.ko" "kernel/drivers/dax/dax.ko"; do
1229 vt_img_extra_initrd_append (easysfs)/lib/modules/$vt_module_ver/$mod
1236 vt_set_boot_opt rdinit=/vtoy/vtoy
1239 syslinux_configfile (vtimghd,1)/syslinux.cfg
1246 function ventoy_img_volumio {
1247 vt_load_cpio $vtoy_path/ventoy.cpio "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1248 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1253 vt_set_boot_opt rdinit=/vtoy/vtoy imgpart=/dev/ventoy2 bootpart=/dev/ventoy1
1256 syslinux_configfile (vtimghd,1)/syslinux.cfg
1262 function ventoy_img_openelec {
1265 vt_load_cpio $vtoy_path/ventoy.cpio "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1266 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1268 loopback vtloopex $vtoy_efi_part/ventoy/vtloopex.cpio
1269 vt_img_extra_initrd_append (vtloopex)/$elec_ver/vtloopex.tar.xz
1274 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=$elec_ver
1277 set root=(vtimghd,1)
1278 syslinux_configfile (vtimghd,1)/syslinux.cfg
1282 loopback -d vtloopex
1286 function ventoy_img_freedombox {
1287 vt_load_cpio $vtoy_path/ventoy.cpio "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1288 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1290 vt_get_lib_module_ver (vtimghd,1) /lib/modules/ vt_module_ver
1291 if [ -n "$vt_module_ver" ]; then
1292 vt_img_extra_initrd_append (vtimghd,1)/lib/modules/$vt_module_ver/kernel/drivers/md/dm-mod.ko
1298 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=freedombox
1301 configfile (vtimghd,1)/boot/grub/grub.cfg
1307 function ventoy_img_paldo {
1308 vt_load_cpio $vtoy_path/ventoy.cpio "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1309 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1314 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=paldo
1317 vt_fs_enum_1st_file (vtimghd,1) /loader/entries/ vt_paldo_entry_conf
1318 vt_file_basename $vt_paldo_entry_conf vtPaldoVer
1320 echo loading file...
1321 linux (vtimghd,1)/linux-${vtPaldoVer} root=/dev/ventoy1 rootfstype=vfat
1322 initrd (vtimghd,1)/initramfs-${vtPaldoVer}
1329 function ventoy_img_ubos {
1330 vt_load_cpio $vtoy_path/ventoy.cpio "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1331 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1333 vt_get_lib_module_ver (vtimghd,3) /lib/modules/ vt_module_ver
1334 if [ -n "$vt_module_ver" ]; then
1335 vt_img_extra_initrd_append (vtimghd,3)/lib/modules/$vt_module_ver/kernel/drivers/md/dm-mod.ko.xz
1341 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=ubos
1344 echo loading file...
1345 linux (vtimghd,2)/vmlinuz-linux root=/dev/ventoy3 rw
1346 initrd (vtimghd,2)/initramfs-linux.img
1353 function ventoy_img_recalbox {
1354 vt_load_cpio $vtoy_path/ventoy.cpio "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1355 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1360 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=recalbox
1363 set root=(vtimghd,1)
1364 configfile (vtimghd,1)/boot/grub/grub.cfg
1370 function ventoy_img_batocera {
1371 vt_load_cpio $vtoy_path/ventoy.cpio "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1372 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1377 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=batocera
1380 set root=(vtimghd,1)
1381 syslinux_configfile (vtimghd,1)/boot/syslinux/syslinux.cfg
1387 function ventoy_img_memtest86 {
1388 chainloader (vtimghd,1)/efi/boot/BOOTX64.efi
1392 function img_unsupport_tip {
1393 echo -e "\n This IMG file is NOT supported now. \n"
1394 echo -e " 当前不支持启动此 IMG 文件 \n"
1395 echo -e "\npress ENTER to exit (请按 回车 键返回) ..."
1399 function img_common_menuentry {
1400 set ventoy_compatible=YES
1401 set ventoy_busybox_ver=32
1403 vt_chosen_img_path vt_chosen_path vt_chosen_size
1405 if vt_check_password "${vt_chosen_path}"; then
1409 if [ -d (vtimghd)/ ]; then
1413 loopback vtimghd "${vtoy_iso_part}${vt_chosen_path}"
1414 vt_img_sector "${vtoy_iso_part}${vt_chosen_path}"
1416 vt_img_part_info (vtimghd)
1418 set vtback_root=$root
1422 vt_img_extra_initrd_reset
1424 vt_get_fs_label (vtimghd,1) vtImgHd1Label
1425 if [ -d (vtimghd,2)/lib ]; then
1426 vt_get_fs_label (vtimghd,2) vtImgHd2Label
1429 if [ -e (vtimghd,1)/etc/hostname ]; then
1430 vt_1st_line (vtimghd,1)/etc/hostname vtImgHostname
1433 if [ -e (vtimghd,1)/easy.sfs ]; then
1435 elif [ -e (vtimghd,1)/volumio.initrd ]; then
1437 elif vt_str_begin "$vtImgHd1Label" "LAKKA"; then
1438 ventoy_img_openelec lakka
1439 elif vt_str_begin "$vtImgHd1Label" "LIBREELEC"; then
1440 ventoy_img_openelec LibreELEC
1441 elif vt_str_begin "$vtImgHd1Label" "paldo-live"; then
1443 elif vt_str_begin "$vtImgHostname" "freedombox"; then
1444 ventoy_img_freedombox
1445 elif vt_str_begin "$vtImgHd1Label" "BATOCERA"; then
1447 elif [ "$vtImgHd2Label" = "RECALBOX" ]; then
1449 elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then
1451 elif [ -f (vtimghd,1)/efi/boot/mt86.png ]; then
1452 if [ "$grub_platform" = "pc" ]; then
1455 ventoy_img_memtest86
1458 vt_linux_chain_data "${vtoy_iso_part}${vt_chosen_path}"
1459 ventoy_acpi_param ${vtoy_chain_mem_addr} 512
1460 if [ "$grub_platform" = "pc" ]; then
1461 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1464 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}
1469 set root=$vtback_root
1472 set ventoy_compatible=NO
1475 function img_unsupport_menuentry {
1476 common_unsupport_menuentry
1479 #############################################################
1480 #############################################################
1481 #############################################################
1482 ####### Main Process ###########
1483 #############################################################
1484 #############################################################
1485 #############################################################
1487 set VENTOY_VERSION="1.0.33"
1489 #ACPI not compatible with Window7/8, so disable by default
1490 set VTOY_PARAM_NO_ACPI=1
1492 # Default menu display mode, you can change it as you want.
1495 set VTOY_DEFAULT_MENU_MODE=0
1497 set VTOY_MEM_DISK_STR="[Memdisk]"
1498 set VTOY_ISO_RAW_STR="Compatible Mode"
1499 set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
1501 set VTOY_F2_CMD="ventoy_power"
1502 set VTOY_F4_CMD="ventoy_localboot"
1503 set VTOY_F5_CMD="ventoy_diagnosis"
1504 set VTOY_F6_CMD="ventoy_ext_menu"
1506 if [ "$grub_platform" = "pc" ]; then
1507 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net"
1509 if [ "$grub_cpu" = "i386" ]; then
1510 set VTOY_EFI_ARCH=ia32
1511 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION IA32 www.ventoy.net"
1512 elif [ "$grub_cpu" = "arm64" ]; then
1513 set VTOY_EFI_ARCH=aa64
1514 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION AA64 www.ventoy.net"
1516 set VTOY_EFI_ARCH=x64
1517 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION UEFI www.ventoy.net"
1521 vt_device $root vtoy_dev
1523 if [ "$vtoy_dev" = "tftp" ]; then
1524 set vtoy_path=($root)
1525 for vtid in 0 1 2 3; do
1526 if [ -f (hd$vtid,2)/ventoy/ventoy.cpio ]; then
1527 set vtoy_iso_part=(hd$vtid,1)
1528 set vtoy_efi_part=(hd$vtid,2)
1535 if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
1536 set vt_plugin_path=$vtoy_iso_part
1538 set vt_plugin_path=$prefix
1539 vt_load_plugin $vt_plugin_path
1542 if [ "$prefix" = "(ventoydisk)/grub" ]; then
1543 set vtoy_path=(ventoydisk)/ventoy
1545 set vtoy_path=($root)/ventoy
1548 set vtoydev=$vtoy_dev
1549 set vtoy_iso_part=($vtoy_dev,1)
1550 set vtoy_efi_part=($vtoy_dev,2)
1552 set vt_plugin_path=$vtoy_iso_part
1555 #Load Partition Table
1556 vt_load_part_table $vtoydev
1559 if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
1561 vt_load_plugin $vtoy_iso_part
1565 if [ -n "$VTOY_MENU_TIMEOUT" ]; then
1566 set timeout=$VTOY_MENU_TIMEOUT
1571 if [ -f $vtoy_iso_part/ventoy/ventoy_wimboot.img ]; then
1572 vt_load_wimboot $vtoy_iso_part/ventoy/ventoy_wimboot.img
1573 elif [ -f $vtoy_efi_part/ventoy/ventoy_wimboot.img ]; then
1574 vt_load_wimboot $vtoy_efi_part/ventoy/ventoy_wimboot.img
1577 if [ -f $vtoy_iso_part/ventoy/ventoy_vhdboot.img ]; then
1578 vt_load_vhdboot $vtoy_iso_part/ventoy/ventoy_vhdboot.img
1579 elif [ -f $vtoy_efi_part/ventoy/ventoy_vhdboot.img ]; then
1580 vt_load_vhdboot $vtoy_efi_part/ventoy/ventoy_vhdboot.img
1584 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
1585 set VTOY_F3_CMD="vt_dynamic_menu 1 1"
1586 set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:TreeView F4:Localboot F5:Tools F6:ExMenu"
1588 set VTOY_F3_CMD="vt_dynamic_menu 1 0"
1589 set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:ListView F4:Localboot F5:Tools F6:ExMenu"
1593 if [ -n "$vtoy_gfxmode" ]; then
1594 set gfxmode=$vtoy_gfxmode
1597 set gfxmode=1024x768
1602 if [ "$vtoy_display_mode" = "CLI" ]; then
1603 terminal_output console
1604 elif [ "$vtoy_display_mode" = "serial" ]; then
1605 if [ -n "$vtoy_serial_param" ]; then
1606 serial $vtoy_serial_param
1608 terminal_input serial
1609 terminal_output serial
1610 elif [ "$vtoy_display_mode" = "serial_console" ]; then
1611 if [ -n "$vtoy_serial_param" ]; then
1612 serial $vtoy_serial_param
1614 terminal_input serial console
1615 terminal_output serial console
1617 if [ -n "$vtoy_theme" ]; then
1618 set theme=$vtoy_theme
1620 set theme=$prefix/themes/ventoy/theme.txt
1622 terminal_output gfxterm
1626 if [ -n "$VTOY_PLUGIN_SYNTAX_ERROR" ]; then
1628 echo -e "\n Syntax error detected in ventoy.json, please check! \n"
1629 echo -e " ventoy.json 文件中有语法错误,所有配置都不会生效,请检查!\n"
1630 echo -e "\n press ENTER to continue (请按 回车 键继续) ..."
1634 #export necessary variable
1641 export vtoy_iso_part
1642 export vtoy_efi_part
1643 export VENTOY_VERSION
1644 export VTOY_CUR_VIDEO_MODE
1645 export VTOY_EFI_ARCH
1647 #special VTOY_DEFAULT_IMAGE process
1648 if [ -n "$VTOY_DEFAULT_IMAGE" ]; then
1649 if regexp --set 1:vtHotkey --set 2:vtDefault "(F[2-9])>(.*)" "$VTOY_DEFAULT_IMAGE"; then
1651 set default="$vtDefault"
1652 if [ -z "$VTOY_MENU_TIMEOUT" ]; then
1655 set timeout=$VTOY_MENU_TIMEOUT
1661 if [ "$vtHotkey" = "F2" ]; then
1663 elif [ "$vtHotkey" = "F4" ]; then
1665 elif [ "$vtHotkey" = "F5" ]; then
1667 elif [ "$vtHotkey" = "F6" ]; then
1676 #colect all image files (iso files)
1677 set ventoy_img_count=0
1678 vt_list_img $vtoy_iso_part ventoy_img_count
1681 if [ $ventoy_img_count -gt 0 ]; then
1682 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
1688 if [ -n "$VTOY_NO_ISO_TIP" ]; then
1689 NO_ISO_MENU="No ISO files found, $VTOY_NO_ISO_TIP"
1690 elif [ -n "$VTOY_DEFAULT_SEARCH_ROOT" ]; then
1691 NO_ISO_MENU="No ISO files found, please check VTOY_DEFAULT_SEARCH_ROOT"
1693 NO_ISO_MENU="No ISO files found"
1695 menuentry "$NO_ISO_MENU (Press enter to reboot ...)" {
1696 echo -e "\n Rebooting ... "