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 if [ -n "${vtdebug_flag}" ]; then
21 echo "press Enter to continue ......"
26 function ventoy_debug_pause {
27 if [ -n "${vtdebug_flag}" ]; then
28 echo "press Enter to continue ......"
33 function ventoy_cli_console {
34 if [ "$grub_platform" = "pc" ]; then
35 #terminal_output vga_text
36 terminal_output console
38 if [ "$vtoy_display_mode" != "CLI" ]; then
39 terminal_output console
44 function ventoy_gui_console {
45 if [ "$grub_platform" = "pc" ]; then
46 if [ "$vtoy_display_mode" = "CLI" ]; then
47 terminal_output console
49 terminal_output gfxterm
52 if [ "$vtoy_display_mode" != "CLI" ]; then
53 terminal_output gfxterm
58 function ventoy_power {
59 configfile $prefix/power.cfg
62 function ventoy_diagnosis {
63 configfile $prefix/debug.cfg
66 function ventoy_localboot {
67 configfile $prefix/localboot.cfg
70 function ventoy_ext_menu {
71 if [ -e $vt_plugin_path/ventoy/ventoy_grub.cfg ]; then
72 set ventoy_new_context=1
73 configfile $vt_plugin_path/ventoy/ventoy_grub.cfg
74 unset ventoy_new_context
76 echo "ventoy_grub.cfg NOT exist."
77 echo -e "\npress ENTER to exit ..."
82 function get_os_type {
85 for file in "efi/microsoft/boot/bcd" "sources/boot.wim" "boot/bcd" "bootmgr.efi" "boot/etfsboot.com" ; do
86 if vt_file_exist_nocase (loop)/$file; then
92 if [ "$vtoy_os" = "Linux" ]; then
93 if vt_strstr "$vt_system_id" "FreeBSD"; then
95 set vt_unix_type=FreeBSD
96 elif [ -e (loop)/bin/freebsd-version ]; then
98 set vt_unix_type=FreeBSD
101 elif [ -e (loop)/boot/kernel/kernel ]; then
102 if file --is-x86-kfreebsd (loop)/boot/kernel/kernel; then
104 set vt_unix_type=FreeBSD
105 elif file --is-x86-knetbsd (loop)/boot/kernel/kernel; then
107 set vt_unix_type=NetBSD
112 if [ -n "${vtdebug_flag}" ]; then
117 function vt_check_compatible_pe {
118 #Check for PE without external tools
119 if [ -f $1/HBCD_PE.ini ]; then
120 set ventoy_compatible=YES
124 function locate_initrd {
125 vt_linux_locate_initrd
127 if [ -n "${vtdebug_flag}" ]; then
133 function locate_wim {
134 vt_windows_locate_wim_patch (loop)
136 if [ -n "${vtdebug_flag}" ]; then
137 echo '###############################################'
139 echo '###############################################'
144 function distro_specify_wim_patch {
145 if [ -d (loop)/h3pe ]; then
146 vt_windows_collect_wim_patch wim /BOOT/H3_10PE.WIM
147 vt_windows_collect_wim_patch wim /BOOT/H3_7PE.WIM
148 vt_windows_collect_wim_patch wim /BOOT/H3_8PE.WIM
149 vt_windows_collect_wim_patch wim /BOOT/H3_81PE.WIM
153 function distro_specify_wim_patch_phase2 {
154 if [ -f (loop)/boot/boot.wim ]; then
155 vt_windows_collect_wim_patch wim /boot/boot.wim
160 function distro_specify_initrd_file {
161 if [ -e (loop)/boot/all.rdz ]; then
162 vt_linux_specify_initrd_file /boot/all.rdz
163 elif [ -e (loop)/boot/xen.gz ]; then
164 if [ -e (loop)/install.img ]; then
165 vt_linux_specify_initrd_file /install.img
167 elif [ -d (loop)/casper ]; then
168 if [ -e (loop)/casper/initrd ]; then
169 vt_linux_specify_initrd_file /casper/initrd
171 if [ -e (loop)/casper/initrd-oem ]; then
172 vt_linux_specify_initrd_file /casper/initrd-oem
174 elif [ -e (loop)/boot/grub/initrd.xz ]; then
175 vt_linux_specify_initrd_file /boot/grub/initrd.xz
176 elif [ -e (loop)/initrd.gz ]; then
177 vt_linux_specify_initrd_file /initrd.gz
178 elif [ -e (loop)/slax/boot/initrfs.img ]; then
179 vt_linux_specify_initrd_file /slax/boot/initrfs.img
180 elif [ -e (loop)/pmagic/initrd.img ]; then
181 vt_linux_specify_initrd_file /pmagic/initrd.img
182 elif [ -e (loop)/boot/initrd.xz ]; then
183 vt_linux_specify_initrd_file /boot/initrd.xz
184 elif [ -f (loop)/boot/initrd ]; then
185 vt_linux_specify_initrd_file /boot/initrd
186 elif [ -f (loop)/boot/x86_64/loader/initrd ]; then
187 vt_linux_specify_initrd_file /boot/x86_64/loader/initrd
188 elif [ -f (loop)/boot/initramfs-x86_64.img ]; then
189 vt_linux_specify_initrd_file /boot/initramfs-x86_64.img
196 function distro_specify_initrd_file_phase2 {
197 if [ -f (loop)/boot/initrd.img ]; then
198 vt_linux_specify_initrd_file /boot/initrd.img
199 elif [ -f (loop)/Setup/initrd.gz ]; then
200 vt_linux_specify_initrd_file /Setup/initrd.gz
201 elif [ -f (loop)/isolinux/initramfs ]; then
202 vt_linux_specify_initrd_file /isolinux/initramfs
203 elif [ -f (loop)/boot/iniramfs.igz ]; then
204 vt_linux_specify_initrd_file /boot/iniramfs.igz
205 elif [ -f (loop)/initrd-x86_64 ]; then
206 vt_linux_specify_initrd_file /initrd-x86_64
207 elif [ -f (loop)/live/initrd.img ]; then
208 vt_linux_specify_initrd_file /live/initrd.img
209 elif [ -f (loop)/initrd.img ]; then
210 vt_linux_specify_initrd_file /initrd.img
211 elif [ -f (loop)/sysresccd/boot/x86_64/sysresccd.img ]; then
212 vt_linux_specify_initrd_file /sysresccd/boot/x86_64/sysresccd.img
213 elif [ -f (loop)/CDlinux/initrd ]; then
214 vt_linux_specify_initrd_file /CDlinux/initrd
215 elif [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
216 vt_linux_specify_initrd_file /parabola/boot/x86_64/parabolaiso.img
217 if [ -f (loop)/parabola/boot/i686/parabolaiso.img ]; then
218 vt_linux_specify_initrd_file /parabola/boot/i686/parabolaiso.img
220 elif [ -f (loop)/EFI/BOOT/initrd.img ]; then
222 vt_linux_specify_initrd_file /EFI/BOOT/initrd.img
223 if [ "$grub_platform" != "pc" ]; then
224 vt_add_replace_file 0 "initrd.img"
226 elif [ -f (loop)/initrd ]; then
227 vt_linux_specify_initrd_file /initrd
228 elif [ -f (loop)/live/initrd1 ]; then
229 vt_linux_specify_initrd_file /live/initrd1
234 function ventoy_get_ghostbsd_ver {
236 # vt_parse_iso_create_date $1/${chosen_path} vt_create_date
237 # if regexp "^202005" "$vt_create_date"; then
238 # set vt_freebsd_ver=12.x
241 set vt_freebsd_ver=12.x
244 function ventoy_get_freenas_ver {
245 set vt_freebsd_ver=11.x
247 if [ -e (loop)/FreeNAS-MANIFEST ]; then
248 vt_parse_freenas_ver (loop)/FreeNAS-MANIFEST vt_freenas_ver
249 if regexp "^13\.[0-9]" "$vt_freenas_ver"; then
250 set vt_freebsd_ver=13.x
251 elif regexp "^12\.[0-9]" "$vt_freenas_ver"; then
252 set vt_freebsd_ver=12.x
253 elif regexp "^11\.[0-9]" "$vt_freenas_ver"; then
254 set vt_freebsd_ver=11.x
259 function ventoy_freebsd_proc {
260 if vt_strstr "$vt_volume_id" "GHOSTBSD"; then
261 ventoy_get_ghostbsd_ver $1 ${chosen_path}
262 elif vt_strstr "$vt_volume_id" "FREENAS"; then
263 ventoy_get_freenas_ver $1 ${chosen_path}
264 elif regexp "^13_[0-9]" "$vt_volume_id"; then
265 set vt_freebsd_ver=13.x
266 elif regexp "^12_[0-9]" "$vt_volume_id"; then
267 set vt_freebsd_ver=12.x
268 elif regexp "^11_[0-9]" "$vt_volume_id"; then
269 set vt_freebsd_ver=11.x
270 elif regexp "^10_[0-9]" "$vt_volume_id"; then
271 set vt_freebsd_ver=10.x
272 elif regexp "^9_[0-9]" "$vt_volume_id"; then
273 set vt_freebsd_ver=9.x
274 elif [ -e (loop)/bin/freebsd-version ]; then
275 vt_unix_parse_freebsd_ver (loop)/bin/freebsd-version vt_userland_ver
276 if regexp "\"13\.[0-9]-" "$vt_userland_ver"; then
277 set vt_freebsd_ver=13.x
278 elif regexp "\"12\.[0-9]-" "$vt_userland_ver"; then
279 set vt_freebsd_ver=12.x
280 elif regexp "\"11\.[0-9]-" "$vt_userland_ver"; then
281 set vt_freebsd_ver=11.x
282 elif regexp "\"10\.[0-9]-" "$vt_userland_ver"; then
283 set vt_freebsd_ver=10.x
284 elif regexp "\"9\.[0-9]-" "$vt_userland_ver"; then
285 set vt_freebsd_ver=9.x
287 elif [ -e (loop)/README.TXT ]; then
288 vt_1st_line (loop)/README.TXT vt_freebsd_line1
289 if regexp "FreeBSD 13\.[0-9]-" "$vt_freebsd_line1"; then
290 set vt_freebsd_ver=13.x
291 elif regexp "FreeBSD 12\.[0-9]-" "$vt_freebsd_line1"; then
292 set vt_freebsd_ver=12.x
293 elif regexp "FreeBSD 11\.[0-9]-" "$vt_freebsd_line1"; then
294 set vt_freebsd_ver=11.x
295 elif regexp "FreeBSD 10\.[0-9]-" "$vt_freebsd_line1"; then
296 set vt_freebsd_ver=10.x
297 elif regexp "FreeBSD 9\.[0-9]-" "$vt_freebsd_line1"; then
298 set vt_freebsd_ver=9.x
300 elif vt_strstr "${chosen_path}" "MidnightBSD"; then
301 set vt_freebsd_ver=9.x
303 set vt_freebsd_ver=12.x
306 set vt_freebsd_bit=64
307 for file in "/boot/kernel/kernel" "/boot/kernel/kernel.gz"; do
308 if [ -e (loop)/$file ]; then
309 if file --is-i386-kfreebsd (loop)/$file; then
310 set vt_freebsd_bit=32
316 if [ -n "${vtdebug_flag}" ]; then
317 echo "This is FreeBSD $vt_freebsd_ver ${vt_freebsd_bit}bit"
320 unset vt_unix_mod_path
321 for file in "/COPYRIGHT" "/FreeNAS-MANIFEST" "/version"; do
322 if [ -e (loop)${file} ]; then
323 set vt_unix_mod_path=${file}
328 vt_unix_replace_ko $vt_unix_mod_path (vtunix)/ventoy_unix/FreeBSD/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
329 vt_unix_replace_conf FreeBSD ${1}${chosen_path}
332 function ventoy_unix_comm_proc {
335 if [ "$ventoy_compatible" = "NO" ]; then
336 loopback vtunix $vtoy_efi_part/ventoy/ventoy_unix.cpio
338 if [ "$vt_unix_type" = "FreeBSD" ]; then
339 ventoy_freebsd_proc $1 ${chosen_path}
340 elif [ "$vt_unix_type" = "NetBSD" ]; then
341 echo "NetBSD not supported"
346 if [ -n "${vtdebug_flag}" ]; then
347 echo "Unknown unix type"
352 vt_unix_chain_data ${1}${chosen_path}
357 function uefi_windows_menu_func {
360 if [ "$ventoy_compatible" = "NO" ]; then
362 if [ "$ventoy_fs_probe" = "iso9660" ]; then
364 vt_iso9660_nojoliet 1
368 for file in "efi/microsoft/boot/bcd"; do
369 vt_windows_collect_wim_patch bcd (loop)/$file
372 vt_windows_count_wim_patch vt_wim_cnt
373 if [ $vt_wim_cnt -eq 0 ]; then
374 distro_specify_wim_patch_phase2
381 vt_windows_chain_data ${1}${chosen_path}
384 if [ -n "$vtoy_chain_mem_addr" ]; then
386 chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
389 echo "chain empty failed"
394 function uefi_linux_menu_func {
395 if [ "$ventoy_compatible" = "NO" ]; then
397 if [ "$ventoy_fs_probe" = "udf" ]; then
399 set ventoy_fs_probe=iso9660
403 vt_load_cpio ${vtoy_path}/ventoy.cpio $2 $1
405 vt_linux_clear_initrd
407 if [ -d (loop)/pmagic ]; then
408 vt_linux_specify_initrd_file /pmagic/initrd.img
410 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
411 if [ -e (loop)/$file ]; then
412 vt_linux_parse_initrd_grub file (loop)/$file
417 # special process for special distros
418 if [ -d (loop)/loader/entries ]; then
419 vt_linux_parse_initrd_grub dir (loop)/loader/entries/
420 elif [ -d (loop)/boot/grub ]; then
421 vt_linux_parse_initrd_grub dir (loop)/boot/grub/
424 distro_specify_initrd_file
426 vt_linux_initrd_count vtcount
427 if [ $vtcount -eq 0 ]; then
428 distro_specify_initrd_file_phase2
430 if [ "$vt_efi_dir" = "NO" ]; then
431 if [ -f (loop)/efi.img ]; then
432 vt_add_replace_file 0 "initrd"
439 if [ -d (loop)/loader/entries ]; then
440 vt_linux_get_main_initrd_index vtindex
442 if [ -d (loop)/arch ]; then
443 if [ -f (loop)/arch/boot/x86_64/archiso.img ]; then
444 vt_add_replace_file $vtindex "EFI\\archiso\\archiso.img"
445 elif [ -f (loop)/boot/initramfs_x86_64.img ]; then
446 vt_add_replace_file $vtindex "boot\\initramfs_x86_64.img"
448 elif [ -f (loop)/EFI/BOOT/initrd.gz ]; then
449 vt_add_replace_file $vtindex "EFI\\BOOT\\initrd.gz"
450 elif [ -f (loop)/loader/entries/thinstation.conf ]; then
451 vt_add_replace_file $vtindex "boot\\initrd"
453 elif [ -d (loop)/EFI/boot/entries ]; then
454 if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
455 vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
457 elif [ -e (loop)/syslinux/alt0/full.cz ]; then
458 vt_add_replace_file 0 "EFI\\BOOT\\full.cz"
459 set FirstTryBootFile='@EFI@BOOT@grubx64.efi'
464 vt_linux_chain_data ${1}${chosen_path}
466 if [ -n "$vtoy_chain_mem_addr" ]; then
468 chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
471 echo "chain empty failed"
476 function uefi_unix_menu_func {
477 ventoy_unix_comm_proc $1 ${chosen_path}
479 if [ -n "$vtoy_chain_mem_addr" ]; then
481 chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
484 echo "chain empty failed"
489 function uefi_iso_menu_func {
491 if [ -d (loop)/ ]; then
495 if [ -n "$vtisouefi" ]; then
496 set LoadIsoEfiDriver=on
498 elif vt_check_mode 2; then
499 set LoadIsoEfiDriver=on
501 unset LoadIsoEfiDriver
504 vt_chosen_img_path chosen_path
505 vt_select_auto_install ${chosen_path}
506 vt_select_persistence ${chosen_path}
508 if vt_is_udf ${1}${chosen_path}; then
509 set ventoy_fs_probe=udf
511 set ventoy_fs_probe=iso9660
512 vt_iso9660_nojoliet 0
515 loopback loop ${1}${chosen_path}
516 vt_parse_iso_volume ${1}${chosen_path} vt_system_id vt_volume_id
519 if [ -d (loop)/EFI ]; then
521 elif [ -d (loop)/efi ]; then
527 if [ -n "$vtcompat" ]; then
528 set ventoy_compatible=YES
530 elif vt_check_mode 1; then
531 set ventoy_compatible=YES
533 vt_check_compatible (loop)
536 vt_img_sector ${1}${chosen_path}
538 if [ "$vtoy_os" = "Windows" ]; then
539 vt_check_compatible_pe (loop)
540 uefi_windows_menu_func $1 ${chosen_path}
541 elif [ "$vtoy_os" = "Unix" ]; then
542 uefi_unix_menu_func $1 ${chosen_path}
544 uefi_linux_menu_func $1 ${chosen_path}
550 function uefi_iso_memdisk {
551 vt_chosen_img_path chosen_path
553 echo 'Loading ISO file to memory ...'
554 vt_load_iso_to_mem ${1}${chosen_path} vtoy_iso_buf
557 chainloader ${vtoy_path}/ventoy_x64.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_iso_buf_addr}:size:${vtoy_iso_buf_size}
564 function legacy_windows_menu_func {
567 if [ "$ventoy_compatible" = "NO" ]; then
569 if [ "$ventoy_fs_probe" = "iso9660" ]; then
571 vt_iso9660_nojoliet 1
575 for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD"; do
576 vt_windows_collect_wim_patch bcd (loop)/$file
579 distro_specify_wim_patch
581 vt_windows_count_wim_patch vt_wim_cnt
582 if [ $vt_wim_cnt -eq 0 ]; then
583 distro_specify_wim_patch_phase2
590 vt_windows_chain_data ${1}${chosen_path}
593 if [ -n "$vtoy_chain_mem_addr" ]; then
594 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
597 echo "chain empty failed"
602 function legacy_linux_menu_func {
603 if [ "$ventoy_compatible" = "NO" ]; then
605 if [ "$ventoy_fs_probe" = "udf" ]; then
607 set ventoy_fs_probe=iso9660
611 vt_load_cpio $vtoy_path/ventoy.cpio $2 $1
613 vt_linux_clear_initrd
615 if [ -d (loop)/pmagic ]; then
616 vt_linux_specify_initrd_file /pmagic/initrd.img
618 for dir in "isolinux" "boot/isolinux" "boot/x86_64/loader" "syslinux" "boot/syslinux"; do
619 if [ -d (loop)/$dir ]; then
620 vt_linux_parse_initrd_isolinux (loop)/$dir/
625 # special process for special distros
627 if [ -d (loop)/arch/boot/syslinux ]; then
628 vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/
629 vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/boot/syslinux/
632 elif [ -d (loop)/manjaro ]; then
633 if [ -e (loop)/boot/grub/kernels.cfg ]; then
634 vt_linux_parse_initrd_grub file (loop)/boot/grub/kernels.cfg
636 elif [ -e (loop)/boot/grub/grub.cfg ]; then
637 vt_linux_parse_initrd_grub file (loop)/boot/grub/grub.cfg
640 distro_specify_initrd_file
642 vt_linux_initrd_count vtcount
643 if [ $vtcount -eq 0 ]; then
644 distro_specify_initrd_file_phase2
650 vt_linux_chain_data ${1}${chosen_path}
653 if [ -n "$vtoy_chain_mem_addr" ]; then
654 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
657 echo "chain empty failed"
663 function legacy_unix_menu_func {
664 ventoy_unix_comm_proc $1 ${chosen_path}
666 if [ -n "$vtoy_chain_mem_addr" ]; then
667 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
670 echo "chain empty failed"
676 function legacy_iso_menu_func {
678 if [ -d (loop)/ ]; then
682 vt_chosen_img_path chosen_path
683 vt_select_auto_install ${chosen_path}
684 vt_select_persistence ${chosen_path}
686 if vt_is_udf ${1}${chosen_path}; then
687 set ventoy_fs_probe=udf
689 set ventoy_fs_probe=iso9660
690 vt_iso9660_nojoliet 0
693 loopback loop ${1}${chosen_path}
694 vt_parse_iso_volume ${1}${chosen_path} vt_system_id vt_volume_id
697 if [ -n "$vtcompat" ]; then
698 set ventoy_compatible=YES
700 elif vt_check_mode 1; then
701 set ventoy_compatible=YES
703 vt_check_compatible (loop)
706 vt_img_sector ${1}${chosen_path}
708 if [ "$vtoy_os" = "Windows" ]; then
709 vt_check_compatible_pe (loop)
710 legacy_windows_menu_func $1 ${chosen_path}
711 elif [ "$vtoy_os" = "Unix" ]; then
712 legacy_unix_menu_func $1 ${chosen_path}
714 legacy_linux_menu_func $1 ${chosen_path}
718 function legacy_iso_memdisk {
719 vt_chosen_img_path chosen_path
721 linux16 $vtoy_path/memdisk iso raw
722 echo "Loading ISO file to memory ..."
723 initrd16 ${1}${chosen_path}
727 function iso_common_menuentry {
731 if [ "$grub_platform" = "pc" ]; then
732 if vt_check_mode 0; then
733 legacy_iso_memdisk $vtoy_iso_part
735 legacy_iso_menu_func $vtoy_iso_part
738 if vt_check_mode 0; then
739 uefi_iso_memdisk $vtoy_iso_part
741 uefi_iso_menu_func $vtoy_iso_part
746 function common_unsupport_menuentry {
747 echo -e "\n The name of the iso file could NOT contain space or non-ascii characters. \n"
748 echo -e " 文件名中不能有中文或空格 \n"
749 echo -e "\npress ENTER to exit (请按 回车 键返回) ..."
753 function iso_unsupport_menuentry {
754 common_unsupport_menuentry
757 function wim_common_menuentry {
758 vt_chosen_img_path chosen_path
759 vt_wim_chain_data ${vtoy_iso_part}${chosen_path}
763 if [ -n "$vtoy_chain_mem_addr" ]; then
764 if [ "$grub_platform" = "pc" ]; then
765 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
768 chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
773 echo "chain empty failed"
778 function wim_unsupport_menuentry {
779 common_unsupport_menuentry
782 function efi_common_menuentry {
783 vt_chosen_img_path chosen_path
786 chainloader ${vtoy_iso_part}${chosen_path}
791 function efi_unsupport_menuentry {
792 common_unsupport_menuentry
797 #############################################################
798 #############################################################
799 #############################################################
800 ####### Main Process ###########
801 #############################################################
802 #############################################################
803 #############################################################
805 set VENTOY_VERSION="1.0.18"
807 # Default menu display mode, you can change it as you want.
810 set VTOY_DEFAULT_MENU_MODE=0
812 set VTOY_MEM_DISK_STR="[Memdisk]"
813 set VTOY_ISO_RAW_STR="Compatible Mode"
814 set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
816 set VTOY_F2_CMD="ventoy_power"
817 set VTOY_F4_CMD="ventoy_localboot"
818 set VTOY_F5_CMD="ventoy_diagnosis"
819 set VTOY_F6_CMD="ventoy_ext_menu"
821 if [ "$grub_platform" = "pc" ]; then
822 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net"
824 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION UEFI www.ventoy.net"
827 vt_device $root vtoy_dev
829 if [ "$vtoy_dev" = "tftp" ]; then
830 set vtoy_path=($root)
831 for vtid in 0 1 2 3; do
832 if [ -d (hd$vtid,2)/ventoy ]; then
833 set vtoy_iso_part=(hd$vtid,1)
834 set vtoy_efi_part=(hd$vtid,2)
840 if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
841 set vt_plugin_path=$vtoy_iso_part
843 set vt_plugin_path=$prefix
844 vt_load_plugin $vt_plugin_path
847 if [ "$prefix" = "(ventoydisk)/grub" ]; then
848 set vtoy_path=(ventoydisk)/ventoy
850 set vtoy_path=($root)/ventoy
853 set vtoy_iso_part=($vtoy_dev,1)
854 set vtoy_efi_part=($vtoy_dev,2)
856 set vt_plugin_path=$vtoy_iso_part
861 if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
862 vt_load_plugin $vtoy_iso_part
865 if [ -n "$VTOY_MENU_TIMEOUT" ]; then
866 set timeout=$VTOY_MENU_TIMEOUT
871 if [ -f $vtoy_iso_part/ventoy/ventoy_wimboot.img ]; then
872 vt_load_wimboot $vtoy_iso_part/ventoy/ventoy_wimboot.img
873 elif [ -f $vtoy_efi_part/ventoy/ventoy_wimboot.img ]; then
874 vt_load_wimboot $vtoy_efi_part/ventoy/ventoy_wimboot.img
878 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
879 set VTOY_F3_CMD="vt_dynamic_menu 1 1"
880 set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:TreeView F4:Localboot F5:Debug F6:ExMenu"
882 set VTOY_F3_CMD="vt_dynamic_menu 1 0"
883 set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:ListView F4:Localboot F5:Debug F6:ExMenu"
887 if [ -n "$vtoy_gfxmode" ]; then
888 set gfxmode=$vtoy_gfxmode
890 set gfxmode=1920x1080,1366x768,1024x768
893 if [ "$vtoy_display_mode" = "CLI" ]; then
894 terminal_output console
896 if [ -n "$vtoy_theme" ]; then
897 set theme=$vtoy_theme
899 set theme=$prefix/themes/ventoy/theme.txt
901 terminal_output gfxterm
904 #export necessary variable
910 export VENTOY_VERSION
915 #colect all image files (iso files)
916 set ventoy_img_count=0
917 vt_list_img $vtoy_iso_part ventoy_img_count
920 if [ $ventoy_img_count -gt 0 ]; then
921 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
927 if [ -n "$VTOY_NO_ISO_TIP" ]; then
928 NO_ISO_MENU="No ISO files found, $VTOY_NO_ISO_TIP"
929 elif [ -n "$VTOY_DEFAULT_SEARCH_ROOT" ]; then
930 NO_ISO_MENU="No ISO files found, please check VTOY_DEFAULT_SEARCH_ROOT"
932 NO_ISO_MENU="No ISO files found"
934 menuentry "$NO_ISO_MENU (Press enter to reboot ...)" {
935 echo -e "\n Rebooting ... "