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_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
58 export vtoy_chosen_path
59 export vtoy_chosen_file
61 configfile "${vtoy_iso_part}${vt_vcfg}"
68 function ventoy_language {
69 configfile $prefix/menulang.cfg
72 function ventoy_diagnosis {
74 configfile $prefix/debug.cfg
77 function ventoy_localboot {
78 configfile $prefix/localboot.cfg
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
87 echo "ventoy_grub.cfg NOT exist."
88 echo -e "\npress ENTER to exit ..."
93 function ventoy_checksum {
94 if [ -f "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}" ]; then
95 configfile $prefix/checksum.cfg
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
105 loopback vt_help_tarfs mem:${vtoy_help_txt_mem_addr}:size:${vtoy_help_txt_mem_size}
106 vt_cur_menu_lang vtCurLang
107 if [ -f "(vt_help_tarfs)/help/${vtCurLang}.txt" ]; then
108 cat "(vt_help_tarfs)/help/${vtCurLang}.txt"
110 cat "(vt_help_tarfs)/help/en_US.txt"
112 loopback -d vt_help_tarfs
116 function ventoy_load_menu_lang_file {
117 vt_load_file_to_mem "auto" $vtoy_efi_part/grub/menu.tar.gz vtoy_menu_lang_mem
118 loopback vt_menu_tarfs mem:${vtoy_menu_lang_mem_addr}:size:${vtoy_menu_lang_mem_size}
121 function get_os_type {
124 if vt_str_begin "$vt_volume_id" "DLC Boot"; then
125 if [ -f (loop)/DLCBoot.exe ]; then
129 for file in "efi/microsoft/boot/bcd" "sources/boot.wim" "boot/bcd" "bootmgr.efi" "boot/etfsboot.com" ; do
130 if vt_file_exist_nocase (loop)/$file; then
137 if [ "$vtoy_os" = "Linux" ]; then
138 if vt_strstr "$vt_system_id" "FreeBSD"; then
140 set vt_unix_type=FreeBSD
141 elif [ -e (loop)/bin/freebsd-version ]; then
143 set vt_unix_type=FreeBSD
144 elif [ -e (loop)/boot/kernel/geom_ventoy.ko ]; then
146 set vt_unix_type=FreeBSD
147 elif vt_str_begin "$vt_system_id" "DragonFly"; then
149 set vt_unix_type=DragonFly
152 elif [ -e (loop)/boot/kernel/kernel ]; then
153 if file --is-x86-kfreebsd (loop)/boot/kernel/kernel; then
155 set vt_unix_type=FreeBSD
156 elif file --is-x86-knetbsd (loop)/boot/kernel/kernel; then
158 set vt_unix_type=NetBSD
163 if [ -n "${vtdebug_flag}" ]; then
164 echo ISO is "$vtoy_os"
168 function vt_check_compatible_pe {
169 #Check for PE without external tools
170 #set compatible if ISO file is less than 80MB
171 if [ $vt_chosen_size -GT 33554432 -a $vt_chosen_size -LE 83886080 ]; then
172 set ventoy_compatible=YES
178 function vt_check_compatible_linux {
179 if vt_str_begin "$vt_volume_id" "embootkit"; then
180 set ventoy_compatible=YES
181 elif [ -e "$1/casper/tinycore.gz" ]; then
182 set ventoy_compatible=YES
188 function locate_initrd {
189 vt_linux_locate_initrd
191 if [ -n "${vtdebug_flag}" ]; then
197 function locate_wim {
198 vt_windows_locate_wim_patch (loop) "$1"
200 if [ -n "${vtdebug_flag}" ]; then
201 echo '###############################################'
203 echo '###############################################'
208 function distro_specify_wim_patch {
209 if [ -d (loop)/h3pe ]; then
210 vt_windows_collect_wim_patch wim /BOOT/H3_10PE.WIM
211 vt_windows_collect_wim_patch wim /BOOT/H3_7PE.WIM
212 vt_windows_collect_wim_patch wim /BOOT/H3_8PE.WIM
213 vt_windows_collect_wim_patch wim /BOOT/H3_81PE.WIM
214 elif [ -d (loop)/2k10/winpe ]; then
215 vt_windows_collect_wim_patch wim /2k10/winpe/w1086pe.wim
216 vt_windows_collect_wim_patch wim /2k10/winpe/w8x86pe.wim
217 vt_windows_collect_wim_patch wim /2k10/winpe/w7x86pe.wim
221 function distro_specify_wim_patch_phase2 {
222 if [ -f (loop)/boot/boot.wim ]; then
223 vt_windows_collect_wim_patch wim /boot/boot.wim
226 if vt_str_begin "$vt_volume_id" "DLC Boot"; then
227 for vwfile in "/DLC1/WinPE/W11x64.wim" "/DLC1/WinPE/W10x64.wim" "/DLC1/WinPE/W10x86.wim"; do
228 if [ -f (loop)/$vwfile ]; then
229 vt_windows_collect_wim_patch wim $vwfile
237 function distro_specify_initrd_file {
238 if [ -e (loop)/boot/all.rdz ]; then
239 vt_linux_specify_initrd_file /boot/all.rdz
240 elif [ -e (loop)/boot/xen.gz ]; then
241 if [ -e (loop)/install.img ]; then
242 vt_linux_specify_initrd_file /install.img
244 elif [ -d (loop)/casper ]; then
245 if [ -e (loop)/casper/initrd ]; then
246 vt_linux_specify_initrd_file /casper/initrd
248 if [ -e (loop)/casper/initrd.gz ]; then
249 vt_linux_specify_initrd_file /casper/initrd.gz
251 if [ -e (loop)/casper/initrd-oem ]; then
252 vt_linux_specify_initrd_file /casper/initrd-oem
254 elif [ -e (loop)/boot/grub/initrd.xz ]; then
255 vt_linux_specify_initrd_file /boot/grub/initrd.xz
256 elif [ -e (loop)/initrd.gz ]; then
257 vt_linux_specify_initrd_file /initrd.gz
258 elif [ -e (loop)/slax/boot/initrfs.img ]; then
259 vt_linux_specify_initrd_file /slax/boot/initrfs.img
260 elif [ -e (loop)/minios/boot/initrfs.img ]; then
261 vt_linux_specify_initrd_file /minios/boot/initrfs.img
262 elif [ -e (loop)/pmagic/initrd.img ]; then
263 vt_linux_specify_initrd_file /pmagic/initrd.img
264 elif [ -e (loop)/boot/initrd.xz ]; then
265 vt_linux_specify_initrd_file /boot/initrd.xz
266 elif [ -e (loop)/boot/initrd.gz ]; then
267 vt_linux_specify_initrd_file /boot/initrd.gz
268 elif [ -f (loop)/boot/initrd ]; then
269 vt_linux_specify_initrd_file /boot/initrd
270 elif [ -f (loop)/boot/x86_64/loader/initrd ]; then
271 vt_linux_specify_initrd_file /boot/x86_64/loader/initrd
272 elif [ -f (loop)/boot/initramfs-x86_64.img ]; then
273 vt_linux_specify_initrd_file /boot/initramfs-x86_64.img
274 elif [ -f (loop)/boot/isolinux/initramfs_data64.cpio.gz ]; then
275 vt_linux_specify_initrd_file /boot/isolinux/initramfs_data64.cpio.gz
276 elif [ -f (loop)/boot/initrd.img ]; then
277 vt_linux_specify_initrd_file /boot/initrd.img
281 if [ -f (loop)/isolinux/initrd.gz ]; then
282 vt_linux_specify_initrd_file /isolinux/initrd.gz
285 if vt_str_begin "$vt_volume_id" "QUBES"; then
286 vt_linux_specify_initrd_file /images/pxeboot/initrd.img
289 if [ "$vt_chosen_size" = "1133375488" ]; then
290 if [ -d (loop)/boot/grub/x86_64-efi ]; then
291 vt_cpio_busybox64 "64h"
297 function distro_specify_initrd_file_phase2 {
298 if [ -f (loop)/boot/initrd.img ]; then
299 vt_linux_specify_initrd_file /boot/initrd.img
300 elif [ -f (loop)/Setup/initrd.gz ]; then
301 vt_linux_specify_initrd_file /Setup/initrd.gz
302 elif [ -f (loop)/isolinux/initramfs ]; then
303 vt_linux_specify_initrd_file /isolinux/initramfs
304 elif [ -f (loop)/boot/iniramfs.igz ]; then
305 vt_linux_specify_initrd_file /boot/iniramfs.igz
306 elif [ -f (loop)/initrd-x86_64 ]; then
307 vt_linux_specify_initrd_file /initrd-x86_64
308 elif [ -f (loop)/live/initrd.img ]; then
309 vt_linux_specify_initrd_file /live/initrd.img
310 elif [ -f (loop)/initrd.img ]; then
311 vt_linux_specify_initrd_file /initrd.img
312 elif [ -f (loop)/sysresccd/boot/x86_64/sysresccd.img ]; then
313 vt_linux_specify_initrd_file /sysresccd/boot/x86_64/sysresccd.img
314 elif [ -f (loop)/CDlinux/initrd ]; then
315 vt_linux_specify_initrd_file /CDlinux/initrd
316 elif [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
317 vt_linux_specify_initrd_file /parabola/boot/x86_64/parabolaiso.img
318 if [ -f (loop)/parabola/boot/i686/parabolaiso.img ]; then
319 vt_linux_specify_initrd_file /parabola/boot/i686/parabolaiso.img
321 elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then
322 vt_linux_specify_initrd_file /parabola/boot/x86_64/initramfs-linux-libre.img
323 if [ -f (loop)/parabola/boot/i686/initramfs-linux-libre.img ]; then
324 vt_linux_specify_initrd_file /parabola/boot/i686/initramfs-linux-libre.img
326 elif [ -f (loop)/hyperbola/boot/x86_64/hyperiso.img ]; then
327 vt_linux_specify_initrd_file /hyperbola/boot/x86_64/hyperiso.img
328 if [ -f (loop)/hyperbola/boot/i686/hyperiso.img ]; then
329 vt_linux_specify_initrd_file /hyperbola/boot/i686/hyperiso.img
331 elif [ -f (loop)/EFI/BOOT/initrd.img ]; then
333 vt_linux_specify_initrd_file /EFI/BOOT/initrd.img
334 if [ "$grub_platform" != "pc" ]; then
335 vt_add_replace_file 0 "initrd.img"
337 elif [ -f (loop)/initrd ]; then
338 vt_linux_specify_initrd_file /initrd
339 elif [ -f (loop)/live/initrd1 ]; then
340 vt_linux_specify_initrd_file /live/initrd1
341 elif [ -f (loop)/isolinux/initrd.img ]; then
342 vt_linux_specify_initrd_file /isolinux/initrd.img
343 elif [ -f (loop)/isolinux/initrd.gz ]; then
344 vt_linux_specify_initrd_file /isolinux/initrd.gz
345 elif [ -f (loop)/syslinux/kernel/initramfs.gz ]; then
346 vt_linux_specify_initrd_file /syslinux/kernel/initramfs.gz
347 elif vt_strstr "$vt_volume_id" "Daphile"; then
348 vt_linux_parse_initrd_isolinux (loop)/isolinux/
349 elif [ -f (loop)/boot/rootfs.xz ]; then
350 vt_linux_specify_initrd_file /boot/rootfs.xz
351 if [ "$grub_platform" != "pc" ]; then
352 vt_add_replace_file 0 "minimal\\x86_64\\rootfs.xz"
354 elif [ -f (loop)/arch/boot/x86_64/archiso.img ]; then
355 vt_linux_specify_initrd_file /arch/boot/x86_64/archiso.img
356 if [ "$grub_platform" != "pc" ]; then
357 vt_add_replace_file 0 "EFI\\archiso\\archiso.img"
359 elif [ -f (loop)/blackarch/boot/x86_64/archiso.img ]; then
360 vt_linux_specify_initrd_file /blackarch/boot/x86_64/archiso.img
361 elif [ -f (loop)/blackarch/boot/x86_64/initramfs-linux.img ]; then
362 vt_linux_specify_initrd_file /blackarch/boot/x86_64/initramfs-linux.img
364 elif [ -f (loop)/install.amd/initrd.gz ]; then
365 vt_linux_specify_initrd_file /live/initrd2.img
366 vt_linux_specify_initrd_file /install.amd/initrd.gz
367 vt_linux_specify_initrd_file /install.amd/gtk/initrd.gz
368 elif [ -f (loop)/boot/grub/kernels.cfg ]; then
369 vt_linux_parse_initrd_grub file (loop)/boot/grub/kernels.cfg
370 elif [ -f (loop)/austrumi/initrd.gz ]; then
371 vt_linux_specify_initrd_file /austrumi/initrd.gz
372 if [ -f (loop)/EFI/BOOT/bootx64.efi ]; then
373 vt_cpio_busybox64 "64h"
375 elif [ -f (loop)/boot/initfs.x86_64-efi ]; then
376 vt_linux_specify_initrd_file /boot/initfs.x86_64-efi
377 if [ -f (loop)/boot/initfs.i386-pc ]; then
378 vt_linux_specify_initrd_file /boot/initfs.i386-pc
380 elif [ -f (loop)/antiX/initrd.gz ]; then
381 vt_linux_specify_initrd_file /antiX/initrd.gz
382 elif [ -f (loop)/360Disk/initrd.gz ]; then
383 vt_linux_specify_initrd_file /360Disk/initrd.gz
384 elif [ -f (loop)/porteus/initrd.xz ]; then
385 vt_linux_specify_initrd_file /porteus/initrd.xz
386 elif [ -f (loop)/pyabr/boot/initrfs.img ]; then
387 vt_linux_specify_initrd_file /pyabr/boot/initrfs.img
388 elif [ -f (loop)/initrd0.img ]; then
389 vt_linux_specify_initrd_file /initrd0.img
390 elif [ -f (loop)/sysresccd/boot/i686/sysresccd.img ]; then
391 vt_linux_specify_initrd_file /sysresccd/boot/i686/sysresccd.img
392 elif [ -f (loop)/boot/full.cz ]; then
393 vt_linux_specify_initrd_file /boot/full.cz
394 elif [ -f (loop)/images/pxeboot/initrd.img ]; then
395 vt_linux_specify_initrd_file /images/pxeboot/initrd.img
400 function ventoy_get_ghostbsd_ver {
401 # fallback to parse version from elf /boot/kernel/kernel
402 set vt_freebsd_ver=xx
405 function ventoy_get_furybsd_ver {
406 if regexp "13\.[0-9]" "$2"; then
407 set vt_freebsd_ver=13.x
409 set vt_freebsd_ver=12.x
413 function ventoy_get_freenas_ver {
414 set vt_freebsd_ver=11.x
416 if [ -e (loop)/FreeNAS-MANIFEST ]; then
417 vt_parse_freenas_ver (loop)/FreeNAS-MANIFEST vt_freenas_ver
418 if regexp "^13\.[0-9]" "$vt_freenas_ver"; then
419 set vt_freebsd_ver=13.x
420 elif regexp "^12\.[0-9]" "$vt_freenas_ver"; then
421 set vt_freebsd_ver=12.x
422 elif regexp "^11\.[0-9]" "$vt_freenas_ver"; then
423 set vt_freebsd_ver=11.x
428 function ventoy_get_truenas_ver {
429 set vt_freebsd_ver=12.x
431 if [ -e (loop)/TrueNAS-MANIFEST ]; then
432 vt_parse_freenas_ver (loop)/TrueNAS-MANIFEST vt_truenas_ver
433 if regexp "^13\.[0-9]" "$vt_truenas_ver"; then
434 set vt_freebsd_ver=13.x
435 elif regexp "^12\.[0-9]" "$vt_truenas_ver"; then
436 set vt_freebsd_ver=12.x
437 elif regexp "^11\.[0-9]" "$vt_truenas_ver"; then
438 set vt_freebsd_ver=11.x
443 function ventoy_get_midnightbsd_ver {
444 if vt_str_begin "$vt_volume_id" "1_"; then
445 set vt_freebsd_ver=11.x
446 elif vt_str_begin "$vt_volume_id" "2_"; then
447 set vt_freebsd_ver=2.x
448 elif vt_str_begin "$vt_volume_id" "3_"; then
449 set vt_freebsd_ver=3.x
453 function ventoy_freebsd_proc {
454 set vtFreeBsdDistro=FreeBSD
455 set vt_freebsd_ver=xx
457 if [ -e (loop)/boot/kernel/geom_ventoy.ko ]; then
458 vt_unix_ko_fillmap /boot/kernel/geom_ventoy.ko
462 if vt_strstr "$vt_volume_id" "GHOSTBSD"; then
463 ventoy_get_ghostbsd_ver "$1" "${chosen_path}"
464 elif vt_strstr "$vt_volume_id" "FREENAS"; then
465 ventoy_get_freenas_ver "$1" "${chosen_path}"
466 elif vt_strstr "$vt_volume_id" "TRUENAS"; then
467 ventoy_get_truenas_ver "$1" "${chosen_path}"
468 elif vt_strstr "$vt_volume_id" "FURYBSD"; then
469 ventoy_get_furybsd_ver "$1" "${chosen_path}"
470 elif regexp "^13_[0-9]" "$vt_volume_id"; then
471 set vt_freebsd_ver=13.x
472 elif regexp "^12_[0-9]" "$vt_volume_id"; then
473 set vt_freebsd_ver=12.x
474 elif regexp "^11_[0-9]" "$vt_volume_id"; then
475 set vt_freebsd_ver=11.x
476 elif regexp "^10_[0-9]" "$vt_volume_id"; then
477 set vt_freebsd_ver=10.x
478 elif regexp "^9_[0-9]" "$vt_volume_id"; then
479 set vt_freebsd_ver=9.x
480 elif [ -d (loop)/usr/midnightbsd-dist ]; then
481 ventoy_get_midnightbsd_ver "$1" "${chosen_path}"
482 set vtFreeBsdDistro=MidnightBSD
483 elif [ -e (loop)/bin/freebsd-version ]; then
484 vt_unix_parse_freebsd_ver (loop)/bin/freebsd-version vt_userland_ver
485 if regexp "\"13\.[0-9]-" "$vt_userland_ver"; then
486 set vt_freebsd_ver=13.x
487 elif regexp "\"12\.[0-9]-" "$vt_userland_ver"; then
488 set vt_freebsd_ver=12.x
489 elif regexp "\"11\.[0-9]-" "$vt_userland_ver"; then
490 set vt_freebsd_ver=11.x
491 elif regexp "\"10\.[0-9]-" "$vt_userland_ver"; then
492 set vt_freebsd_ver=10.x
493 elif regexp "\"9\.[0-9]-" "$vt_userland_ver"; then
494 set vt_freebsd_ver=9.x
496 elif [ -e (loop)/README.TXT ]; then
497 vt_1st_line (loop)/README.TXT vt_freebsd_line1
498 if regexp "FreeBSD 13\.[0-9]-" "$vt_freebsd_line1"; then
499 set vt_freebsd_ver=13.x
500 elif regexp "FreeBSD 12\.[0-9]-" "$vt_freebsd_line1"; then
501 set vt_freebsd_ver=12.x
502 elif regexp "FreeBSD 11\.[0-9]-" "$vt_freebsd_line1"; then
503 set vt_freebsd_ver=11.x
504 elif regexp "FreeBSD 10\.[0-9]-" "$vt_freebsd_line1"; then
505 set vt_freebsd_ver=10.x
506 elif regexp "FreeBSD 9\.[0-9]-" "$vt_freebsd_line1"; then
507 set vt_freebsd_ver=9.x
509 elif vt_strstr "${chosen_path}" "MidnightBSD"; then
510 set vt_freebsd_ver=9.x
514 if [ -e (loop)/usr/freebsd-dist/cloninst.sh ]; then
515 set vtFreeBsdDistro=ClonOS
518 set vt_freebsd_bit=64
519 for file in "/boot/kernel/kernel" "/boot/kernel/kernel.gz"; do
520 if [ -e (loop)/$file ]; then
521 if file --is-i386-kfreebsd (loop)/$file; then
522 set vt_freebsd_bit=32
528 if [ "$vt_freebsd_ver" = "xx" ]; then
529 if [ -e (loop)/boot/kernel/kernel ]; then
530 vt_unix_parse_freebsd_ver_elf (loop)/boot/kernel/kernel $vt_freebsd_bit vt_freebsd_ver
531 elif [ -e (loop)/boot/kernel/kernel.gz ]; then
532 vt_unix_parse_freebsd_ver_elf (loop)/boot/kernel/kernel.gz $vt_freebsd_bit vt_freebsd_ver
535 if [ "$vt_freebsd_ver" = "xx" ]; then
536 set vt_freebsd_ver=13.x
540 if [ -n "${vtdebug_flag}" ]; then
541 echo "This is $vtFreeBsdDistro $vt_freebsd_ver ${vt_freebsd_bit}bit"
544 unset vt_unix_mod_path
545 for file in "/COPYRIGHT" "/FreeNAS-MANIFEST" "/TrueNAS-MANIFEST" "/version" "/etc/fstab"; do
546 if [ -e (loop)${file} ]; then
547 set vt_unix_mod_path=${file}
552 if [ -n "$vt_unix_mod_path" ]; then
553 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
554 vt_unix_replace_conf FreeBSD "${1}${chosen_path}"
555 elif [ -e (loop)/easyre.ufs.uzip ]; then
556 vt_unix_replace_ko "/boot/grub/i386-pc/linux.mod" (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
557 if [ "$grub_platform" = "pc" ]; then
558 vt_unix_replace_grub_conf "/boot/grub/i386-pc/linux.mod" "cd9"
560 vt_unix_replace_conf FreeBSD "${1}${chosen_path}" "cd9"
565 function ventoy_dragonfly_proc {
567 unset vt_unix_mod_path
568 for file in "/boot/kernel/initrd.img.gz"; do
569 if [ -e (loop)${file} ]; then
570 set vt_unix_mod_path=${file}
575 vt_unix_replace_ko $vt_unix_mod_path ${vtoy_path}/dragonfly.mfs.xz
576 vt_unix_fill_image_desc
578 vt_unix_replace_conf DragonFly "${1}${chosen_path}"
581 function ventoy_unix_comm_proc {
584 vt_unix_check_vlnk "${1}${chosen_path}"
586 if [ "$ventoy_compatible" = "NO" ]; then
587 loopback vtunix $vtoy_efi_part/ventoy/ventoy_unix.cpio
589 if [ "$vt_unix_type" = "FreeBSD" ]; then
590 ventoy_freebsd_proc "$1" "${chosen_path}"
591 elif [ "$vt_unix_type" = "DragonFly" ]; then
592 ventoy_dragonfly_proc "$1" "${chosen_path}"
593 elif [ "$vt_unix_type" = "NetBSD" ]; then
594 echo "NetBSD not supported"
598 if [ -n "${vtdebug_flag}" ]; then
599 echo "Unknown unix type"
604 vt_unix_chain_data "${1}${chosen_path}"
609 function uefi_windows_menu_func {
612 unset vt_cur_wimboot_mode
613 if vt_check_mode 4 "$vt_chosen_name"; then
614 set vt_cur_wimboot_mode=1
617 if [ "$ventoy_compatible" = "NO" -o "$vt_cur_wimboot_mode" = "1" ]; then
618 if [ "$ventoy_fs_probe" = "iso9660" ]; then
620 vt_iso9660_nojoliet 1
624 for file in "efi/microsoft/boot/bcd"; do
625 vt_windows_collect_wim_patch bcd (loop)/$file
628 vt_windows_count_wim_patch vt_wim_cnt
629 if [ $vt_wim_cnt -eq 0 ]; then
630 distro_specify_wim_patch_phase2
634 locate_wim "${chosen_path}"
637 vt_windows_chain_data "${1}${chosen_path}"
640 if [ "$vt_cur_wimboot_mode" = "1" ]; then
644 if [ -n "$vtoy_chain_mem_addr" ]; then
645 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
647 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}
650 echo "chain empty failed"
655 function uefi_find_replace_initrd {
656 if vt_get_efi_vdisk_offset "${1}${2}" vt_efivdisk_offset; then
657 loopback -s $vt_efivdisk_offset vtefivdisk "${1}${2}"
660 vt_search_replace_initrd (vtefivdisk) vt_rp_initrd
662 if [ -n "$vt_rp_initrd" ]; then
663 vt_add_replace_file $3 "$vt_rp_initrd"
666 loopback -d vtefivdisk
671 function uefi_linux_menu_func {
673 if [ "$ventoy_compatible" = "NO" ]; then
675 if [ "$ventoy_fs_probe" = "udf" ]; then
677 set ventoy_fs_probe=iso9660
681 vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver"
683 vt_linux_clear_initrd
685 if [ -d (loop)/pmagic ]; then
686 vt_linux_specify_initrd_file /pmagic/initrd.img
688 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
689 if [ -e (loop)/$file ]; then
690 vt_linux_parse_initrd_grub file (loop)/$file
695 # special process for special distros
696 if [ -d (loop)/loader/entries ]; then
697 vt_linux_parse_initrd_grub dir (loop)/loader/entries/
698 elif [ -d (loop)/boot/grub ]; then
699 vt_linux_parse_initrd_grub dir (loop)/boot/grub/
702 distro_specify_initrd_file
704 vt_linux_initrd_count vtcount
706 if [ $vtcount -eq 0 ]; then
707 if [ -e (loop)/EFI/boot/livegrub.cfg ]; then
708 vt_linux_parse_initrd_grub file (loop)/EFI/boot/livegrub.cfg
710 distro_specify_initrd_file_phase2
712 if [ "$vt_efi_dir" = "NO" ]; then
713 if [ -f (loop)/efi.img ]; then
714 vt_add_replace_file 0 "initrd"
721 if [ -d (loop)/loader/entries ]; then
722 vt_linux_get_main_initrd_index vtindex
724 if [ -d (loop)/arch ]; then
725 if [ -f (loop)/arch/boot/x86_64/archiso.img ]; then
726 vt_add_replace_file $vtindex "EFI\\archiso\\archiso.img"
727 elif [ -f (loop)/arch/boot/x86_64/initramfs-linux.img ]; then
728 vt_add_replace_file $vtindex "arch\\boot\\x86_64\\initramfs-linux.img"
729 elif [ -f (loop)/boot/initramfs_x86_64.img ]; then
730 vt_add_replace_file $vtindex "boot\\initramfs_x86_64.img"
732 elif [ -d (loop)/blackarch ]; then
733 if [ -f (loop)/blackarch/boot/x86_64/archiso.img ]; then
734 vt_add_replace_file $vtindex "EFI\\archiso\\archiso.img"
735 elif [ -f (loop)/blackarch/boot/x86_64/initramfs-linux.img ]; then
736 vt_add_replace_file $vtindex "blackarch\\boot\\x86_64\\initramfs-linux.img"
738 elif [ -d (loop)/anarchy ]; then
739 if [ -f (loop)/anarchy/boot/x86_64/initramfs-linux.img ]; then
740 vt_add_replace_file $vtindex "anarchy\\boot\\x86_64\\initramfs-linux.img"
742 elif [ -d (loop)/parabola ]; then
743 if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
744 vt_add_replace_file $vtindex "EFI\\parabolaiso\\parabolaiso.img"
745 elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then
746 vt_add_replace_file $vtindex "parabola\\boot\\x86_64\\initramfs-linux-libre.img"
748 elif [ -f (loop)/EFI/BOOT/initrd.gz ]; then
749 vt_add_replace_file $vtindex "EFI\\BOOT\\initrd.gz"
750 elif [ -f (loop)/loader/entries/thinstation.conf ]; then
751 vt_add_replace_file $vtindex "boot\\initrd"
752 elif [ -f (loop)/loader/entries/pisi-efi-x86_64.conf ]; then
753 vt_add_replace_file $vtindex "EFI\\pisi\\initrd.img"
756 vt_get_replace_file_cnt vt_replace_cnt
757 if [ $vt_replace_cnt -eq 0 ]; then
758 uefi_find_replace_initrd "$1" "$2" $vtindex
760 elif [ -d (loop)/EFI/boot/entries ]; then
761 if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
762 vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
763 elif [ -f (loop)/hyperbola/boot/x86_64/hyperiso.img ]; then
764 vt_add_replace_file 0 "EFI\\hyperiso\\hyperiso.img"
766 elif [ -d (loop)/EFI/BOOT/entries ]; then
767 vt_linux_get_main_initrd_index vtindex
769 if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
770 vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
771 elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then
772 vt_add_replace_file $vtindex "parabola\\boot\\x86_64\\initramfs-linux-libre.img"
774 elif [ -e (loop)/syslinux/alt0/full.cz ]; then
775 vt_add_replace_file 0 "EFI\\BOOT\\full.cz"
776 set FirstTryBootFile='@EFI@BOOT@grubx64.efi'
778 elif vt_str_begin "$vt_volume_id" "SolusLive"; then
779 vt_add_replace_file 0 "initrd"
785 vt_linux_chain_data "${1}${chosen_path}"
787 if [ -n "$LoadIsoEfiDriver" -a $vt_chosen_size -LT 104857600 ]; then
788 if [ -f (loop)/efi/clover/cloverx64.efi ]; then
789 unset LoadIsoEfiDriver
793 if [ -n "$vtoy_chain_mem_addr" ]; then
794 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
798 if vt_check_mode 3 "$vt_chosen_name"; then
800 elif vt_str_begin "$vt_volume_id" "HOLO_"; then
801 if [ -d (loop)/loader/entries ]; then
804 elif vt_str_begin "$vt_volume_id" "KRD"; then
805 if [ -f (loop)/boot/grub/grub.cfg.sig ]; then
810 if [ -n "$vtGrub2Mode" ]; then
813 if [ "$VTOY_EFI_ARCH" != "mips" ]; then
814 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}
820 set vtback_root=$root
822 set vtback_theme=$theme
825 vt_trailer_cpio "$vtoy_iso_part" "$vt_chosen_path" noinit
826 vt_set_boot_opt rdinit=/vtoy/vtoy
829 set vtback_cfg_find=0
830 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
831 if [ -e "$cfg" ]; then
832 set vtback_cfg_find=1
837 if [ $vtback_cfg_find -eq 0 ]; then
838 if [ -f (loop)/loader/loader.conf -a -d (loop)/loader/entries ]; then
839 if vt_str_begin "$vt_volume_id" "HOLO_"; then
841 vt_systemd_menu (loop,2) vt_sys_menu_mem
843 vt_systemd_menu (loop) vt_sys_menu_mem
845 set vtback_cfg_find=1
846 configfile "mem:${vt_sys_menu_mem_addr}:size:${vt_sys_menu_mem_size}"
850 if [ "$vtback_cfg_find" = "0" ]; then
852 echo "No bootfile found for UEFI!"
853 echo "Maybe the image does not support $VTOY_EFI_ARCH UEFI"
859 set root=$vtback_root
860 set theme=$vtback_theme
864 echo "chain empty failed"
869 function uefi_unix_menu_func {
870 ventoy_unix_comm_proc $1 "${chosen_path}"
872 if [ -n "$vtoy_chain_mem_addr" ]; then
873 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
875 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}
878 echo "chain empty failed"
883 function ventoy_reset_nojoliet {
884 if vt_str_begin "$vt_volume_id" "ARCARESCUE"; then
885 vt_iso9660_nojoliet 1
887 vt_iso9660_nojoliet 0
890 vt_append_extra_sector 0
893 function uefi_iso_menu_func {
895 if [ -d (loop)/ ]; then
899 if [ -n "$vtisouefi" ]; then
900 set LoadIsoEfiDriver=on
902 elif vt_check_mode 2 "$vt_chosen_name"; then
903 set LoadIsoEfiDriver=on
905 unset LoadIsoEfiDriver
909 vt_select_auto_install "${chosen_path}"
910 vt_select_persistence "${chosen_path}"
912 if vt_is_udf "${1}${chosen_path}"; then
913 set ventoy_fs_probe=udf
915 set ventoy_fs_probe=iso9660
916 ventoy_reset_nojoliet
918 # Lenovo EasyStartup need an addional sector for boundary check
919 if vt_str_begin "$vt_volume_id" "EasyStartup"; then
920 vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}"
921 vt_append_extra_sector 1
925 loopback loop "${1}${chosen_path}"
928 if [ -d (loop)/EFI ]; then
930 elif [ -d (loop)/efi ]; then
936 if [ -n "$vtcompat" ]; then
937 set ventoy_compatible=YES
939 elif vt_check_mode 1 "$vt_chosen_name"; then
940 set ventoy_compatible=YES
942 vt_check_compatible (loop)
945 if vt_need_secondary_menu "$vt_chosen_name"; then
946 vt_show_secondary_menu "$vt_chosen_path" "$vtoy_os" $vt_chosen_size
947 if vt_check_mode 0 "$vt_chosen_name"; then
948 uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
949 vt_secondary_recover_mode
954 vt_img_sector "${1}${chosen_path}"
956 if [ "$ventoy_fs_probe" = "iso9660" ]; then
957 vt_select_conf_replace "${1}" "${chosen_path}"
960 if [ "$vtoy_os" = "Windows" ]; then
961 vt_check_compatible_pe (loop)
962 uefi_windows_menu_func "$1" "${chosen_path}"
963 elif [ "$vtoy_os" = "Unix" ]; then
964 uefi_unix_menu_func "$1" "${chosen_path}"
966 vt_check_compatible_linux (loop)
967 uefi_linux_menu_func "$1" "${chosen_path}"
971 vt_secondary_recover_mode
974 function uefi_iso_memdisk {
975 echo 'Loading ISO file to memory ...'
976 vt_load_img_memdisk "${1}${2}" vtoy_iso_buf
979 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}
985 function vtoy_windows_wimboot {
986 if [ -f (loop)/x86/sources/boot.wim -a -f (loop)/x64/sources/boot.wim ]; then
987 vt_sel_wimboot vtoy_wimboot_bit
988 if [ "$vtoy_wimboot_bit" = "32" ]; then
989 set vtoy_wimboot_prefix=(loop)/x86
991 set vtoy_wimboot_prefix=(loop)/x64
994 set vtoy_wimboot_prefix=(loop)
995 if vt_is_pe64 $vtoy_wimboot_prefix/setup.exe; then
996 set vtoy_wimboot_bit=64
998 set vtoy_wimboot_bit=32
1002 if [ -n "${vtdebug_flag}" ]; then
1003 echo vtoy_wimboot_prefix=$vtoy_wimboot_prefix vtoy_wimboot_bit=$vtoy_wimboot_bit vt_wimkernel=$vt_wimkernel
1006 vt_windows_wimboot_data "$vtoy_wimboot_prefix/sources/boot.wim" vtoy_init_exe vtoy_wim_bit
1008 if [ "$grub_platform" = "pc" ]; then
1009 linux16 "$vtoy_path/$vt_wimkernel" quiet
1012 vt_set_wim_load_prompt 1 "Loading files......"
1013 initrd16 newc:winpeshl.exe:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size} \
1014 newc:vtoy_wimboot:$vtoy_wimboot_prefix/boot/bcd \
1015 newc:bcd:$vtoy_wimboot_prefix/boot/bcd \
1016 newc:boot.sdi:$vtoy_wimboot_prefix/boot/boot.sdi \
1017 newc:boot.wim:$vtoy_wimboot_prefix/sources/boot.wim
1018 vt_set_wim_load_prompt 0
1021 vt_set_wim_load_prompt 1 "Loading files......"
1022 vt_load_file_to_mem "nodecompress" $vtoy_wimboot_prefix/sources/boot.wim vtoy_wimfile_mem
1023 vt_set_wim_load_prompt 0
1025 if [ $? -eq 0 ]; then
1026 set vtoy_wimfile_path=mem:${vtoy_wimfile_mem_addr}:size:${vtoy_wimfile_mem_size}
1028 set vtoy_wimfile_path=$vtoy_wimboot_prefix/sources/boot.wim
1032 chainloader "$vtoy_path/$vt_wimkernel" quiet \
1033 "vf=winpeshl.exe:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size}" \
1034 "vf=vtoy_wimboot:$vtoy_wimboot_prefix/boot/bcd" \
1035 "vf=bcd:$vtoy_wimboot_prefix/boot/bcd" \
1036 "vf=boot.sdi:$vtoy_wimboot_prefix/boot/boot.sdi" \
1037 "vf=boot.wim:$vtoy_wimfile_path" \
1038 pfsize=$vtoy_chain_file_size \
1039 pfread=$vtoy_chain_file_read
1045 function vtoy_winpe_wimboot {
1046 unset vtoy_boot_sdi_legacy
1047 unset vtoy_boot_sdi_efi
1049 set vtoy_wimboot_prefix=(loop)
1050 set vtoy_wim_path="$1"
1052 if [ -n "${vtdebug_flag}" ]; then
1053 echo "winpe_wimboot $1 $2 $3"
1056 if [ "$2" != "0" ]; then
1057 set vtoy_boot_sdi_legacy="newc:boot.sdi:$vtoy_wimboot_prefix/$2"
1058 set vtoy_boot_sdi_efi="vf=boot.sdi:$vtoy_wimboot_prefix/$2"
1061 vt_windows_wimboot_data $vtoy_wimboot_prefix/$vtoy_wim_path vtoy_init_exe vtoy_wim_bit
1063 if [ "$grub_platform" = "pc" ]; then
1064 linux16 "$vtoy_path/$vt_wimkernel" quiet
1067 vt_set_wim_load_prompt 1 "Loading files......"
1068 initrd16 newc:$vtoy_init_exe:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size} \
1069 newc:vtoy_wimboot:$vtoy_path/$vt_wimkernel \
1070 newc:bootmgr.exe:mem:${vtoy_pe_bootmgr_mem_addr}:size:${vtoy_pe_bootmgr_mem_size} \
1071 newc:bcd:mem:${vtoy_pe_bcd_mem_addr}:size:${vtoy_pe_bcd_mem_size} \
1072 $vtoy_boot_sdi_legacy \
1073 newc:boot.wim:$vtoy_wimboot_prefix/$vtoy_wim_path
1074 vt_set_wim_load_prompt 0
1077 if [ "$VTOY_EFI_ARCH" = "x64" -a "$vtoy_wim_bit" = "32" ]; then
1078 echo -e "\nThis is 32bit Windows and does NOT support x86_64 UEFI firmware.\n"
1079 echo -e "这是32位的 Windows 系统,不支持当前的64位 UEFI 环境。\n"
1082 vt_set_wim_load_prompt 1 "Loading files......"
1083 vt_load_file_to_mem "nodecompress" $vtoy_wimboot_prefix/$vtoy_wim_path vtoy_wimfile_mem
1084 vt_set_wim_load_prompt 0
1086 if [ $? -eq 0 ]; then
1087 set vtoy_wimfile_path=mem:${vtoy_wimfile_mem_addr}:size:${vtoy_wimfile_mem_size}
1089 set vtoy_wimfile_path=$vtoy_wimboot_prefix/$vtoy_wim_path
1092 unset vtoy_boot_efi_path
1093 if [ -F (loop)/efi/boot/boot${VTOY_EFI_ARCH}.efi ]; then
1094 set vtoy_boot_efi_path="vf=bootx64.efi:(loop)/efi/boot/boot${VTOY_EFI_ARCH}.efi"
1098 chainloader "$vtoy_path/$vt_wimkernel" quiet \
1099 "vf=$vtoy_init_exe:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size}" \
1100 "vf=vtoy_wimboot:$vtoy_path/$vt_wimkernel" \
1101 "vf=bcd:mem:${vtoy_pe_bcd_mem_addr}:size:${vtoy_pe_bcd_mem_size}" \
1102 "$vtoy_boot_sdi_efi" \
1103 "$vtoy_boot_efi_path" \
1104 "vf=boot.wim:$vtoy_wimfile_path" \
1105 pfsize=$vtoy_chain_file_size \
1106 pfread=$vtoy_chain_file_read
1112 function vtoy_wimboot_func {
1113 if [ "$grub_platform" = "pc" ]; then
1114 set vt_wimkernel=wimboot.x86_64.xz
1116 if [ "$grub_cpu" = "i386" ]; then
1117 set vt_wimkernel=wimboot.i386.efi.xz
1119 set vt_wimkernel=wimboot.x86_64.xz
1123 if vt_is_standard_winiso (loop); then
1124 echo -e "\n==================== VENTOY WIMBOOT ==================\n"
1125 vtoy_windows_wimboot
1127 vt_sel_winpe_wim (loop)
1128 if [ -n "$vtoy_pe_wim_path" ]; then
1129 echo -e "\n==================== VENTOY WIMBOOT ==================\n"
1132 vt_load_file_to_mem "auto" $vtoy_path/common_bcd.xz vtoy_pe_bcd_mem
1135 for vsdi in "boot/boot.sdi" "2K10/FONTS/boot.sdi" "SSTR/boot.sdi" "ISPE/BOOT.SDI" \
1136 "boot/uqi.sdi" "ISYL/boot.sdi" "WEPE/WEPE.SDI" ; do
1137 if [ -F "(loop)/$vsdi" ]; then
1138 set vt_sdi_path=$vsdi
1143 if [ "$grub_platform" = "pc" ]; then
1144 vt_load_file_to_mem "auto" $vtoy_path/common_bootmgr.xz vtoy_pe_bootmgr_mem
1145 vtoy_winpe_wimboot "$vtoy_pe_wim_path" "$vt_sdi_path" 1
1147 vtoy_winpe_wimboot "$vtoy_pe_wim_path" "$vt_sdi_path" 0
1155 function legacy_windows_menu_func {
1158 unset vt_cur_wimboot_mode
1159 if vt_check_mode 4 "$vt_chosen_name"; then
1160 set vt_cur_wimboot_mode=1
1163 if [ "$ventoy_compatible" = "NO" -o "$vt_cur_wimboot_mode" = "1" ]; then
1164 if [ "$ventoy_fs_probe" = "iso9660" ]; then
1166 vt_iso9660_nojoliet 1
1167 loopback loop "$1$2"
1170 for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD" "boot/bce"; do
1171 vt_windows_collect_wim_patch bcd (loop)/$file
1174 distro_specify_wim_patch
1176 vt_windows_count_wim_patch vt_wim_cnt
1177 if [ $vt_wim_cnt -eq 0 ]; then
1178 distro_specify_wim_patch_phase2
1182 if [ -z "$vt_cur_wimboot_mode" ]; then
1183 locate_wim "${chosen_path}"
1187 vt_windows_chain_data "${1}${chosen_path}"
1190 if [ "$vt_cur_wimboot_mode" = "1" ]; then
1194 if [ -n "$vtoy_chain_mem_addr" ]; then
1195 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
1196 if [ "$ventoy_compatible" = "NO" ]; then
1197 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1199 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1203 echo "chain empty failed"
1208 function legacy_linux_menu_func {
1209 if [ "$ventoy_compatible" = "NO" ]; then
1211 if [ "$ventoy_fs_probe" = "udf" ]; then
1213 set ventoy_fs_probe=iso9660
1214 loopback loop "$1$2"
1218 if vt_syslinux_need_nojoliet "$1$2"; then
1219 vt_iso9660_nojoliet 1
1221 loopback loop "$1$2"
1224 vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver"
1226 vt_linux_clear_initrd
1228 if [ -d (loop)/pmagic ]; then
1229 vt_linux_specify_initrd_file /pmagic/initrd.img
1231 for dir in "isolinux" "boot/isolinux" "boot/x86_64/loader" "syslinux" "boot/syslinux"; do
1232 if [ -d (loop)/$dir ]; then
1233 vt_linux_parse_initrd_isolinux (loop)/$dir/
1238 # special process for special distros
1240 if [ -d (loop)/arch/boot/syslinux ]; then
1241 vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/
1242 vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/boot/syslinux/
1243 elif [ -d (loop)/anarchy/boot/syslinux ]; then
1244 vt_linux_parse_initrd_isolinux (loop)/anarchy/boot/syslinux/ /anarchy/
1247 elif [ -d (loop)/manjaro ]; then
1248 if [ -e (loop)/boot/grub/kernels.cfg ]; then
1249 vt_linux_parse_initrd_grub file (loop)/boot/grub/kernels.cfg
1251 elif [ -e (loop)/boot/grub/grub.cfg ]; then
1252 vt_linux_parse_initrd_grub file (loop)/boot/grub/grub.cfg
1255 distro_specify_initrd_file
1257 vt_linux_initrd_count vtcount
1258 if [ $vtcount -eq 0 ]; then
1259 if [ -d (loop)/rancheros ]; then
1260 vt_linux_parse_initrd_isolinux (loop)/boot/ /boot/isolinux/
1263 distro_specify_initrd_file_phase2
1269 vt_linux_chain_data "${1}${chosen_path}"
1272 if [ -n "$vtoy_chain_mem_addr" ]; then
1274 if vt_check_mode 3 "$vt_chosen_name"; then
1276 elif vt_str_begin "$vt_volume_id" "HOLO_"; then
1277 if [ -d (loop)/loader/entries ]; then
1282 if [ -n "$vtGrub2Mode" ]; then
1283 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
1287 set vtback_root=$root
1289 set vtback_theme=$theme
1292 vt_trailer_cpio "$vtoy_iso_part" "$vt_chosen_path" noinit
1293 vt_set_boot_opt rdinit=/vtoy/vtoy
1296 set vtback_cfg_find=0
1297 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
1298 if [ -e "$cfg" ]; then
1299 set vtback_cfg_find=1
1304 if [ $vtback_cfg_find -eq 0 ]; then
1305 if [ -f (loop)/loader/loader.conf -a -d (loop)/loader/entries ]; then
1306 if vt_str_begin "$vt_volume_id" "HOLO_"; then
1308 vt_systemd_menu (loop,2) vt_sys_menu_mem
1310 vt_systemd_menu (loop) vt_sys_menu_mem
1312 set vtback_cfg_find=1
1313 configfile "mem:${vt_sys_menu_mem_addr}:size:${vt_sys_menu_mem_size}"
1318 set root=$vtback_root
1319 set theme=$vtback_theme
1323 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
1324 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1328 echo "chain empty failed"
1334 function legacy_unix_menu_func {
1335 ventoy_unix_comm_proc $1 "${chosen_path}"
1337 if [ -n "$vtoy_chain_mem_addr" ]; then
1338 #ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
1339 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1342 echo "chain empty failed"
1348 function legacy_iso_menu_func {
1350 if [ -d (loop)/ ]; then
1354 set chosen_path="$2"
1356 vt_select_auto_install "${chosen_path}"
1357 vt_select_persistence "${chosen_path}"
1359 if vt_is_udf "${1}${chosen_path}"; then
1360 set ventoy_fs_probe=udf
1362 set ventoy_fs_probe=iso9660
1363 ventoy_reset_nojoliet
1366 loopback loop "${1}${chosen_path}"
1370 if [ -n "$vtcompat" ]; then
1371 set ventoy_compatible=YES
1373 elif vt_check_mode 1 "$vt_chosen_name"; then
1374 set ventoy_compatible=YES
1376 vt_check_compatible (loop)
1379 if vt_need_secondary_menu "$vt_chosen_name"; then
1380 vt_show_secondary_menu "$vt_chosen_path" "$vtoy_os" $vt_chosen_size
1381 if vt_check_mode 0 "$vt_chosen_name"; then
1382 legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1383 vt_secondary_recover_mode
1388 vt_img_sector "${1}${chosen_path}"
1390 if [ "$ventoy_fs_probe" = "iso9660" ]; then
1391 vt_select_conf_replace "${1}" "${chosen_path}"
1394 if [ "$vtoy_os" = "Windows" ]; then
1395 vt_check_compatible_pe (loop)
1396 legacy_windows_menu_func "$1" "${chosen_path}"
1397 elif [ "$vtoy_os" = "Unix" ]; then
1398 legacy_unix_menu_func "$1" "${chosen_path}"
1400 vt_check_compatible_linux (loop)
1401 legacy_linux_menu_func "$1" "${chosen_path}"
1403 vt_secondary_recover_mode
1406 function legacy_iso_memdisk {
1408 linux16 $vtoy_path/memdisk iso raw
1409 echo "Loading ISO file to memory ..."
1415 function iso_endless_os_proc {
1416 if [ -d (loop)/ ]; then
1420 loopback loop "${1}${2}"
1421 vt_img_sector "${1}${2}"
1423 vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver"
1424 vt_trailer_cpio "$1" "$2" noinit
1428 vt_set_boot_opt '@kparams' rdinit=/vtoy/vtoy
1431 set ventoy_bls_bootdev=/boot
1432 set ventoy_loading_tip="Loading files ......"
1435 configfile (loop)/endless/grub/grub.cfg
1438 unset ventoy_bls_bootdev
1439 unset ventoy_loading_tip
1445 function ventoy_iso_busybox_ver {
1447 if [ "$VTOY_EFI_ARCH" = "aa64" ]; then
1448 set ventoy_busybox_ver=a64
1449 elif [ "$VTOY_EFI_ARCH" = "mips" ]; then
1450 set ventoy_busybox_ver=m64
1452 set ventoy_busybox_ver=32
1454 #special process for deepin-live iso
1455 if [ "$vt_chosen_size" = "403701760" ]; then
1456 if vt_str_str "$vt_chosen_path" "/deepin-live"; then
1457 set ventoy_busybox_ver=64
1459 elif vt_str_begin "$vt_volume_id" "PHOTON_"; then
1460 set ventoy_busybox_ver=64
1461 elif vt_str_begin "$vt_volume_id" "smgl-test-quinq-x86_64"; then
1462 set ventoy_busybox_ver=64
1463 elif vt_str_begin "$vt_volume_id" "LDiagBootable"; then
1464 set ventoy_busybox_ver=64
1471 function iso_common_menuentry {
1475 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
1477 vt_parse_iso_volume "${vtoy_iso_part}${vt_chosen_path}" vt_system_id vt_volume_id vt_volume_space
1478 if [ $vt_volume_space -NE $vt_chosen_size ]; then
1479 vt_mod $vt_chosen_size 2048 vt_chosen_size_mod
1480 if [ $vt_chosen_size_mod -ne 0 ]; then
1481 echo -e "\n $vt_volume_space $vt_chosen_size $vt_chosen_size_mod\n"
1482 echo -e "\n The size of the iso file \"$vt_chosen_size\" is invalid. File corrupted ?\n"
1483 echo -e " 此ISO文件的大小 \"$vt_chosen_size\" 有问题,请确认文件是否损坏。\n"
1484 echo -e "\n press ENTER to continue (请按 回车 键继续) ..."
1489 if vt_check_password "${vt_chosen_path}"; then
1493 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1497 if vt_str_begin "$vt_volume_id" "Avira"; then
1498 vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}"
1501 ventoy_iso_busybox_ver
1503 #special process for Endless OS
1504 if vt_str_begin "$vt_volume_id" "Endless-OS"; then
1505 iso_endless_os_proc $vtoy_iso_part "$vt_chosen_path"
1506 elif vt_str_begin "$vt_volume_id" "TENS-Public"; then
1511 # auto memdisk mode for some special ISO files
1512 vt_iso_vd_id_parse "${vtoy_iso_part}${vt_chosen_path}"
1514 if vt_check_mode 0 "$vt_chosen_name"; then
1517 if [ "$grub_platform" = "pc" ]; then
1518 if vt_iso_vd_id_begin 1 0 "Memtest86+"; then
1520 elif vt_iso_vd_id_begin 0 1 "KolibriOS"; then
1526 if [ $vt_chosen_size -LE 67108864 ]; then
1527 if vt_str_begin "$vt_chosen_name" "iKuai"; then
1535 if [ "$grub_platform" = "pc" ]; then
1536 if [ -n "$vtMemDiskBoot" ]; then
1537 legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1539 legacy_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
1542 if [ -n "$vtMemDiskBoot" ]; then
1543 uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1545 uefi_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
1550 function miso_common_menuentry {
1551 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
1553 if vt_check_password "${vt_chosen_path}"; then
1557 echo "memdisk mode boot for $vt_chosen_path"
1561 if [ "$grub_platform" = "pc" ]; then
1562 legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1564 uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1569 function common_unsupport_menuentry {
1570 echo -e "\n The name of the iso file could NOT contain space or non-ascii characters. \n"
1571 echo -e " 文件名中不能有中文或空格 \n"
1572 echo -e "\npress ENTER to exit (请按 回车 键返回) ..."
1576 function miso_unsupport_menuentry {
1577 common_unsupport_menuentry
1580 function iso_unsupport_menuentry {
1581 common_unsupport_menuentry
1584 function wim_common_menuentry {
1585 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
1587 if vt_check_password "${vt_chosen_path}"; then
1591 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1595 if vt_wim_check_bootable "${vtoy_iso_part}${vt_chosen_path}"; then
1596 vt_wim_chain_data "${vtoy_iso_part}${vt_chosen_path}"
1598 echo -e "\n This is NOT a bootable WIM file. \n"
1599 echo -e " 这不是一个可启动的 WIM 文件。\n"
1604 if [ -n "$vtoy_chain_mem_addr" ]; then
1605 if [ "$grub_platform" = "pc" ]; then
1606 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1609 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}
1614 echo "chain empty failed"
1619 function wim_unsupport_menuentry {
1620 common_unsupport_menuentry
1623 function efi_common_menuentry {
1624 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
1626 if vt_check_password "${vt_chosen_path}"; then
1630 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1635 if vt_is_vlnk_name "${vt_chosen_path}"; then
1636 vt_get_vlnk_dst "${vtoy_iso_part}${vt_chosen_path}" vt_vlnk_dst
1637 if [ -z "$vt_vlnk_dst" ]; then
1638 echo -e "\n### VLNK FILE NOT FOUND ###\n### VLNK 文件不存在 ###\n"
1643 vt_vlnk_dst="${vtoy_iso_part}${vt_chosen_path}"
1650 #first try with chainload
1652 set root=$vtoy_iso_part
1653 chainloader "${vt_vlnk_dst}"
1658 vt_concat_efi_iso "${vt_vlnk_dst}" vtoy_iso_buf
1659 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}
1665 function efi_unsupport_menuentry {
1666 common_unsupport_menuentry
1669 function vhdboot_common_func {
1670 vt_patch_vhdboot "$1"
1674 if [ -n "$vtoy_vhd_buf_addr" ]; then
1675 if [ "$grub_platform" = "pc" ]; then
1677 linux16 $vtoy_path/memdisk iso raw
1678 initrd16 mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size}
1683 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}
1688 echo "Please put the right ventoy_vhdboot.img file to the 1st partition"
1693 function vhd_common_menuentry {
1694 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
1696 if vt_check_password "${vt_chosen_path}"; then
1700 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1705 if vt_is_vlnk_name "${vt_chosen_path}"; then
1706 vt_get_vlnk_dst "${vtoy_iso_part}${vt_chosen_path}" vt_vlnk_dst
1707 if [ -z "$vt_vlnk_dst" ]; then
1708 echo -e "\n### VLNK FILE NOT FOUND ###\n### VLNK 文件不存在 ###\n"
1713 vt_vlnk_dst="${vt_chosen_path}"
1714 if [ "$VTOY_VHD_NO_WARNING" != "1" ]; then
1715 if [ "$vtoy_iso_fs" != "ntfs" ]; then
1716 echo -e "!!! WARNING !!!\n"
1717 echo -e "\nPartition1 ($vtoy_iso_fs) is NOT ntfs, the VHD(x) file may not boot normally \n"
1718 echo -e "\nVHD(x) 文件所在分区不是 ntfs 格式, 可能无法正常启动 \n\n"
1719 echo -n "press ENTER to continue boot (请按 回车 键继续) ..."
1725 vhdboot_common_func "${vt_vlnk_dst}"
1728 function vhd_unsupport_menuentry {
1729 common_unsupport_menuentry
1732 function vtoyboot_common_func {
1736 vt_get_vtoy_type "${1}" vtoytype parttype AltBootPart
1738 if vt_str_begin $vtoytype vhd; then
1740 elif [ "$vtoytype" = "raw" ]; then
1742 elif [ "$vtoytype" = "vdi" ]; then
1746 if [ $vtoysupport -eq 1 ]; then
1747 if [ "$grub_platform" = "pc" ]; then
1748 if [ "$parttype" = "gpt" -a $AltBootPart -eq 0 ]; then
1749 echo "The OS in the vdisk was created in UEFI mode, but current is Legacy BIOS mode."
1750 echo "虚拟磁盘内的系统是在UEFI模式下创建的,而当前系统是Legacy BIOS模式,可能无法正常启动。"
1754 if [ "$parttype" = "mbr" -a $AltBootPart -eq 0 ]; then
1755 echo "The OS in the vdisk was created in Legacy BIOS mode, but current is UEFI mode."
1756 echo "虚拟磁盘内的系统是在Legacy BIOS模式下创建的,而当前系统是UEFI模式,可能无法正常启动。"
1761 vt_img_sector "${1}"
1762 vt_raw_chain_data "${1}"
1766 if [ -n "$vtoy_chain_mem_addr" ]; then
1767 if [ "$grub_platform" = "pc" ]; then
1768 vt_acpi_param ${vtoy_chain_mem_addr} 512
1769 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} bios80 sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1772 if vt_check_secureboot_var; then
1773 vt_acpi_param ${vtoy_chain_mem_addr} 512
1776 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}
1781 echo "chain empty failed!"
1785 echo "Unsupported vtoy type $vtoytype"
1790 function vtoy_common_menuentry {
1791 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
1793 if vt_check_password "${vt_chosen_path}"; then
1797 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1802 if vt_is_vlnk_name "${vt_chosen_path}"; then
1803 vt_get_vlnk_dst "${vtoy_iso_part}${vt_chosen_path}" vt_vlnk_dst
1804 if [ -z "$vt_vlnk_dst" ]; then
1805 echo -e "\n### VLNK FILE NOT FOUND ###\n### VLNK 文件不存在 ###\n"
1810 vt_vlnk_dst="${vtoy_iso_part}${vt_chosen_path}"
1813 vtoyboot_common_func "${vt_vlnk_dst}"
1816 function vtoy_unsupport_menuentry {
1817 common_unsupport_menuentry
1821 #============================================================#
1822 # IMG file boot process #
1823 #============================================================#
1826 function only_uefi_tip {
1827 echo -e "\n This IMG file is only supported in UEFI mode. \n"
1828 echo -e "\n press ENTER to exit ..."
1832 function ventoy_img_easyos {
1833 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1834 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1836 loopback easysfs (vtimghd,1)/easy.sfs
1837 vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver
1839 if [ -n "$vt_module_ver" ]; then
1840 for mod in "kernel/drivers/md/dm-mod.ko" "kernel/drivers/dax/dax.ko"; do
1841 if [ -e (easysfs)/lib/modules/$vt_module_ver/$mod ]; then
1842 vt_img_extra_initrd_append (easysfs)/lib/modules/$vt_module_ver/$mod
1850 vt_set_boot_opt rdinit=/vtoy/vtoy
1853 syslinux_configfile (vtimghd,1)/syslinux.cfg
1860 function ventoy_img_easyos2 {
1861 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1862 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1864 if [ -e (vtimghd,2)/easyos/easy.sfs ]; then
1865 loopback easysfs (vtimghd,2)/easyos/easy.sfs
1866 elif [ -d (vtimghd,2)/easyos/releases ]; then
1867 vt_fs_enum_1st_dir (vtimghd,2) /easyos/releases/ vt_dir_name
1868 loopback easysfs (vtimghd,2)/easyos/releases/$vt_dir_name/easy.sfs
1871 vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver
1873 if [ -n "$vt_module_ver" ]; then
1874 for mod in "kernel/drivers/md/dm-mod.ko" "kernel/drivers/dax/dax.ko"; do
1875 if [ -e (easysfs)/lib/modules/$vt_module_ver/$mod ]; then
1876 vt_img_extra_initrd_append (easysfs)/lib/modules/$vt_module_ver/$mod
1884 vt_set_boot_opt rdinit=/vtoy/vtoy
1887 vt_limine_menu (vtimghd,1)/limine.cfg vt_sys_menu_mem
1888 configfile "mem:${vt_sys_menu_mem_addr}:size:${vt_sys_menu_mem_size}"
1895 function ventoy_img_volumio {
1896 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1897 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1902 vt_set_boot_opt rdinit=/vtoy/vtoy imgpart=/dev/ventoy2 bootpart=/dev/ventoy1
1905 syslinux_configfile (vtimghd,1)/syslinux.cfg
1911 function ventoy_img_openelec {
1914 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1915 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1917 loopback vtloopex $vtoy_efi_part/ventoy/vtloopex.cpio
1918 vt_img_extra_initrd_append (vtloopex)/$elec_ver/vtloopex.tar.xz
1923 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=$elec_ver
1926 set root=(vtimghd,1)
1927 syslinux_configfile (vtimghd,1)/syslinux.cfg
1931 loopback -d vtloopex
1935 function ventoy_img_freedombox {
1936 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1937 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1939 vt_get_lib_module_ver (vtimghd,1) /lib/modules/ vt_module_ver
1940 if [ -n "$vt_module_ver" ]; then
1941 vt_img_extra_initrd_append (vtimghd,1)/lib/modules/$vt_module_ver/kernel/drivers/md/dm-mod.ko
1947 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=freedombox
1950 configfile (vtimghd,1)/boot/grub/grub.cfg
1956 function ventoy_img_paldo {
1957 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1958 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1963 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=paldo
1966 vt_fs_enum_1st_file (vtimghd,1) /loader/entries/ vt_paldo_entry_conf
1967 vt_file_basename $vt_paldo_entry_conf vtPaldoVer
1969 echo loading file...
1970 linux (vtimghd,1)/linux-${vtPaldoVer} root=/dev/ventoy1 rootfstype=vfat
1971 initrd (vtimghd,1)/initramfs-${vtPaldoVer}
1978 function ventoy_img_ubos {
1979 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1980 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
1982 vt_get_lib_module_ver (vtimghd,3) /lib/modules/ vt_module_ver
1983 if [ -n "$vt_module_ver" ]; then
1984 vt_img_extra_initrd_append (vtimghd,3)/lib/modules/$vt_module_ver/kernel/drivers/md/dm-mod.ko.xz
1990 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=ubos
1993 echo loading file...
1994 linux (vtimghd,2)/vmlinuz-linux root=/dev/ventoy3 rw
1995 initrd (vtimghd,2)/initramfs-linux.img
2002 function ventoy_img_recalbox {
2003 if [ $vtoy_img_max_part_end -GT $vt_chosen_size ]; then
2004 echo -e "\nPlease extend the img file size before boot it. \n"
2009 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
2010 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
2012 if [ -e (vtimghd,1)/boot/recalbox ]; then
2013 loopback recalbox (vtimghd,1)/boot/recalbox
2014 vt_get_lib_module_ver (recalbox) /lib/modules/ vt_module_ver
2015 if [ -n "$vt_module_ver" ]; then
2016 vt_img_extra_initrd_append (recalbox)/lib/modules/$vt_module_ver/kernel/drivers/md/dm-mod.ko
2023 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=recalbox
2026 set root=(vtimghd,1)
2027 configfile (vtimghd,1)/boot/grub/grub.cfg
2033 function ventoy_img_esysrescue {
2034 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
2035 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
2040 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=esysrescue
2043 set root=(vtimghd,1)
2044 configfile (vtimghd,1)/boot/grub/grub.cfg
2050 function ventoy_img_batocera {
2051 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
2052 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
2057 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=batocera
2060 set root=(vtimghd,1)
2061 syslinux_configfile (vtimghd,1)/boot/syslinux/syslinux.cfg
2067 function ventoy_img_openwrt {
2068 if [ -e (vtimghd,2)/lib64 ]; then
2069 set ventoy_busybox_ver=64
2072 vt_fs_enum_1st_dir (vtimghd,2) /lib/modules/ vt_dir_name
2074 if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko ]; then
2075 set openwrt_plugin_need=0
2076 vt_img_extra_initrd_append (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko
2077 if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko ]; then
2078 vt_img_extra_initrd_append (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko
2081 set openwrt_plugin_need=1
2082 if [ ! -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
2084 echo -e "\n ventoy_openwrt.xz not found. Please refer https://www.ventoy.net/en/doc_openwrt.html.\n"
2085 echo -e " 未找到 ventoy_openwrt.xz 文件。请参考 https://www.ventoy.net/cn/doc_openwrt.html\n"
2086 echo -e "\n press ENTER to exit (请按 回车 键返回) ..."
2093 if vt_img_check_range "${vtoy_iso_part}${vt_chosen_path}"; then
2097 echo -e "\n IMG file need processed. Please refer https://www.ventoy.net/en/doc_openwrt.html.\n"
2098 echo -e " 此 IMG 文件必须处理之后才能支持。请参考 https://www.ventoy.net/cn/doc_openwrt.html\n"
2099 echo -e "\n press ENTER to exit (请按 回车 键返回) ..."
2105 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
2106 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
2108 if [ $openwrt_plugin_need -eq 1 ]; then
2109 if [ -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
2110 vt_img_extra_initrd_append ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz
2115 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=openwrt
2118 set root=(vtimghd,1)
2119 configfile (vtimghd,1)/boot/grub/grub.cfg
2125 function ventoy_img_tails {
2126 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
2127 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
2132 vt_set_boot_opt rdinit=/vtoy/vtoy live-media=/dev/dm-1 ventoyos=tails
2135 set root=(vtimghd,1)
2136 configfile (vtimghd,1)/efi/debian/grub.cfg
2142 function ventoy_img_fydeos {
2143 if [ "$grub_platform" = "pc" ]; then
2148 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=64"
2149 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
2154 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=fydeos
2157 set grubdisk=vtimghd
2158 set grubpartA=(vtimghd,3)
2159 set grubpartB=(vtimghd,5)
2160 set linuxpartA=(sda,3)
2161 set linuxpartB=(sda,5)
2163 set root=(vtimghd,12)
2164 configfile (vtimghd,12)/efi/boot/grub.cfg
2176 function ventoy_img_cloudready {
2177 if [ "$grub_platform" = "pc" ]; then
2182 vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=64"
2183 vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
2188 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=cloudready
2191 set grubdisk=vtimghd
2192 set grubpartA=(vtimghd,3)
2193 set grubpartB=(vtimghd,5)
2194 set linuxpartA=(sda,3)
2195 set linuxpartB=(sda,5)
2197 set root=(vtimghd,12)
2198 configfile (vtimghd,12)/efi/boot/grub.cfg
2210 function ventoy_img_memtest86 {
2211 chainloader (vtimghd,1)/efi/boot/BOOTX64.efi
2215 function img_unsupport_tip {
2216 echo -e "\n This IMG file is NOT supported now. \n"
2217 echo -e " 当前不支持启动此 IMG 文件 \n"
2218 echo -e "\npress ENTER to exit (请按 回车 键返回) ..."
2222 function legacy_img_memdisk {
2223 linux16 $vtoy_path/memdisk
2224 echo "Loading img file to memory ..."
2231 function img_common_menuentry {
2232 set ventoy_compatible=YES
2233 set ventoy_busybox_ver=32
2234 unset LoadIsoEfiDriver
2236 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
2238 if vt_check_password "${vt_chosen_path}"; then
2242 if ventoy_vcfg_proc "${vt_chosen_path}"; then
2246 if [ "$grub_platform" = "pc" ]; then
2247 if vt_check_mode 0 "$vt_chosen_name"; then
2248 legacy_img_memdisk $vtoy_iso_part "$vt_chosen_path"
2253 loopback vtimghd "${vtoy_iso_part}${vt_chosen_path}"
2254 vt_img_sector "${vtoy_iso_part}${vt_chosen_path}"
2256 vt_img_part_info (vtimghd)
2258 set vtback_root=$root
2261 set vtback_theme=$theme
2264 vt_img_extra_initrd_reset
2267 vt_get_fs_label (vtimghd,1) vtImgHd1Label
2269 if [ "$vtImgHd1Label" = "STATE" ]; then
2270 vt_get_fs_label (vtimghd,3) vtImgHd3Label
2271 elif [ -d (vtimghd,2)/lib ]; then
2272 vt_get_fs_label (vtimghd,2) vtImgHd2Label
2275 if [ -e (vtimghd,1)/etc/hostname ]; then
2276 vt_1st_line (vtimghd,1)/etc/hostname vtImgHostname
2279 if vt_str_begin "$vtImgHd3Label" "ROOT-"; then
2280 if [ -f (vtimghd,3)/etc/os-release.d/ID ]; then
2281 vt_1st_line (vtimghd,3)/etc/os-release.d/ID vt_release_line1
2282 if vt_str_begin "$vt_release_line1" "FydeOS"; then
2285 ventoy_img_cloudready
2287 elif [ -f (vtimghd,3)/etc/cloudready-release ]; then
2288 ventoy_img_cloudready
2289 elif [ -f (vtimghd,3)/etc/chrome_dev.conf ]; then
2290 ventoy_img_cloudready
2292 elif vt_str_begin "$vtImgHd1Label" "LAKKA"; then
2293 ventoy_img_openelec lakka
2294 elif vt_str_begin "$vtImgHd1Label" "LIBREELEC"; then
2295 ventoy_img_openelec LibreELEC
2296 elif vt_str_begin "$vtImgHd1Label" "paldo-live"; then
2298 elif vt_str_begin "$vtImgHostname" "freedombox"; then
2299 ventoy_img_freedombox
2300 elif vt_str_begin "$vtImgHd1Label" "BATOCERA"; then
2302 elif vt_str_begin "$vtImgHd1Label" "Tails"; then
2304 elif [ "$vtImgHd2Label" = "RECALBOX" -o "$vtImgHd1Label" = "RECALBOX" ]; then
2306 elif [ "$vtImgHd1Label" = "ESYSRESCUE" ]; then
2307 ventoy_img_esysrescue
2308 elif [ -e (vtimghd,1)/easy.sfs ]; then
2310 elif [ -d (vtimghd,2)/easyos ]; then
2312 elif [ -e (vtimghd,1)/volumio.initrd ]; then
2314 elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then
2316 elif [ -f (vtimghd,2)/etc/openwrt_version ]; then
2318 elif [ -f (vtimghd,1)/efi/boot/mt86.png ]; then
2319 if [ "$grub_platform" = "pc" ]; then
2322 ventoy_img_memtest86
2325 vt_linux_chain_data "${vtoy_iso_part}${vt_chosen_path}"
2326 ventoy_acpi_param ${vtoy_chain_mem_addr} 512
2327 if [ "$grub_platform" = "pc" ]; then
2328 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
2331 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}
2338 set root=$vtback_root
2340 set theme=$vtback_theme
2342 set ventoy_compatible=NO
2345 function img_unsupport_menuentry {
2346 common_unsupport_menuentry
2349 #############################################################
2350 #############################################################
2351 #############################################################
2352 ####### Main Process ###########
2353 #############################################################
2354 #############################################################
2355 #############################################################
2357 set VENTOY_VERSION="1.0.84"
2359 #ACPI not compatible with Window7/8, so disable by default
2360 set VTOY_PARAM_NO_ACPI=1
2362 # Default menu display mode, you can change it as you want.
2365 set VTOY_DEFAULT_MENU_MODE=0
2367 set VTOY_MEM_DISK_STR="[Memdisk]"
2368 set VTOY_ISO_RAW_STR="Compatible Mode"
2369 set VTOY_GRUB2_MODE_STR="GRUB2 Mode"
2370 set VTOY_WIMBOOT_MODE_STR="WIMBOOT Mode"
2371 set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
2373 set VTOY_F2_CMD="vt_browser_disk"
2374 set VTOY_F4_CMD="ventoy_localboot"
2375 set VTOY_F5_CMD="ventoy_diagnosis"
2376 set VTOY_F6_CMD="ventoy_ext_menu"
2377 set VTOY_HELP_CMD="ventoy_show_help"
2378 set VTOY_CHKSUM_CMD="ventoy_checksum"
2379 set VTOY_HELP_TXT_LANGUAGE="en_US"
2380 set VTOY_CHKSUM_FILE_PATH="X"
2381 set VTOY_LANG_CMD="ventoy_language"
2384 if [ "$grub_platform" = "pc" ]; then
2385 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net"
2387 if [ "$grub_cpu" = "i386" ]; then
2388 set VTOY_EFI_ARCH=ia32
2389 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION IA32 www.ventoy.net"
2390 elif [ "$grub_cpu" = "arm64" ]; then
2391 set VTOY_EFI_ARCH=aa64
2392 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION AA64 www.ventoy.net"
2393 elif [ "$grub_cpu" = "mips64el" ]; then
2394 set VTOY_EFI_ARCH=mips
2395 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION MIPS www.ventoy.net"
2397 set VTOY_EFI_ARCH=x64
2398 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION UEFI www.ventoy.net"
2402 vt_device $root vtoy_dev
2404 if [ "$vtoy_dev" = "tftp" ]; then
2405 set vtoy_path=($root)
2406 for vtid in 0 1 2 3; do
2407 if [ -f (hd$vtid,2)/ventoy/ventoy.cpio ]; then
2408 set vtoy_iso_part=(hd$vtid,1)
2409 set vtoy_efi_part=(hd$vtid,2)
2416 if [ -n "$vtoy_efi_part" ]; then
2417 vt_load_file_to_mem "auto" $vtoy_efi_part/grub/fonts/unicode.pf2 vtoy_font_mem
2418 loadfont mem:${vtoy_font_mem_addr}:size:${vtoy_font_mem_size}
2421 if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
2422 set vt_plugin_path=$vtoy_iso_part
2424 set vt_plugin_path=$prefix
2425 vt_load_plugin $vt_plugin_path
2428 if [ "$prefix" = "(ventoydisk)/grub" ]; then
2429 set vtoy_path=(ventoydisk)/ventoy
2431 set vtoy_path=($root)/ventoy
2434 set vtoydev=$vtoy_dev
2435 set vtoy_iso_part=($vtoy_dev,1)
2436 set vtoy_efi_part=($vtoy_dev,2)
2438 vt_load_file_to_mem "auto" $prefix/fonts/unicode.pf2 vtoy_font_mem
2439 loadfont mem:${vtoy_font_mem_addr}:size:${vtoy_font_mem_size}
2441 set vt_plugin_path=$vtoy_iso_part
2444 #Load Partition Table
2445 vt_load_part_table $vtoydev
2447 #Load menu lang file
2448 ventoy_load_menu_lang_file
2451 if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
2453 vt_load_plugin $vtoy_iso_part
2456 vt_check_json_path_case $vtoy_iso_part
2459 if [ -n "$VTOY_MENU_LANGUAGE" ]; then
2460 vt_init_menu_lang "$VTOY_MENU_LANGUAGE"
2462 vt_init_menu_lang en_US
2465 if [ -n "$VTOY_MENU_TIMEOUT" ]; then
2466 set timeout=$VTOY_MENU_TIMEOUT
2471 if [ -f $vtoy_iso_part/ventoy/ventoy_wimboot.img ]; then
2472 vt_load_wimboot $vtoy_iso_part/ventoy/ventoy_wimboot.img
2473 elif [ -f $vtoy_efi_part/ventoy/ventoy_wimboot.img ]; then
2474 vt_load_wimboot $vtoy_efi_part/ventoy/ventoy_wimboot.img
2477 if [ -f $vtoy_iso_part/ventoy/ventoy_vhdboot.img ]; then
2478 vt_load_vhdboot $vtoy_iso_part/ventoy/ventoy_vhdboot.img
2479 elif [ -f $vtoy_efi_part/ventoy/ventoy_vhdboot.img ]; then
2480 vt_load_vhdboot $vtoy_efi_part/ventoy/ventoy_vhdboot.img
2484 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
2485 set VTOY_F3_CMD="vt_dynamic_menu 1 1"
2487 set VTOY_F3_CMD="vt_dynamic_menu 1 0"
2490 terminal_output console
2492 if [ -n "$vtoy_gfxmode" ]; then
2493 set gfxmode=$vtoy_gfxmode
2496 set gfxmode=1024x768
2501 if [ "$vtoy_display_mode" = "CLI" ]; then
2502 terminal_output console
2503 elif [ "$vtoy_display_mode" = "serial" ]; then
2504 if [ -n "$vtoy_serial_param" ]; then
2505 serial $vtoy_serial_param
2507 terminal_input serial
2508 terminal_output serial
2509 elif [ "$vtoy_display_mode" = "serial_console" ]; then
2510 if [ -n "$vtoy_serial_param" ]; then
2511 serial $vtoy_serial_param
2513 terminal_input serial console
2514 terminal_output serial console
2516 if [ -n "$vtoy_theme" ]; then
2519 set theme=$prefix/themes/ventoy/theme.txt
2521 terminal_output gfxterm
2524 if [ "$grub_platform" = "efi" ]; then
2525 set mouse_delta=4000
2526 # terminal_input --append mouse
2529 if [ -n "$VTOY_DEFAULT_KBD_LAYOUT" ]; then
2530 set_keyboard_layout "$VTOY_DEFAULT_KBD_LAYOUT"
2533 if [ -n "$VTOY_PLUGIN_PATH_CASE_MISMATCH" ]; then
2535 echo "$VTOY_PLUGIN_PATH_CASE_MISMATCH"
2536 echo -e "\n\nPath case does not match! ventoy directory and ventoy.json MUST be all lowercase!"
2537 echo -e "\n路径大小写不匹配!ventoy 目录和 ventoy.json 文件的名字必须是全部小写,请修正!"
2538 echo -e "\n\npress ENTER to continue (请按回车键继续) ..."
2542 if [ -n "$VTOY_PLUGIN_SYNTAX_ERROR" ]; then
2544 if [ -n "$VTOY_PLUGIN_ENCODE_ERROR" ]; then
2545 echo -e "\n Encoding type for ventoy.json is not supported, please convert to UTF-8.\n"
2546 echo -e " ventoy.json 文件编码格式不支持,请转换为 UTF-8 编码格式!\n"
2548 echo -e "\n Syntax error detected in ventoy.json, please check! \n"
2549 echo -e " ventoy.json 文件中有语法错误,所有配置都不会生效,请检查!\n"
2552 echo -e "\n press ENTER to continue (请按 回车 键继续) ..."
2557 for vtTFile in ventoy.json ventoy_grub.cfg; do
2558 if [ -f $vtoy_efi_part/ventoy/$vtTFile ]; then
2560 echo -e "\n You need to put $vtTFile in the 1st partition which hold the ISO files.\n"
2561 echo -e " $vtTFile 放错分区了,请放到镜像分区里的 ventoy 目录下(此目录需要手动创建)!\n"
2562 echo -e "\n press ENTER to continue (请按 回车 键继续) ..."
2567 #clear all input key before show main menu
2570 #export necessary variable
2578 export vtoy_iso_part
2579 export vtoy_efi_part
2580 export VENTOY_VERSION
2581 export VTOY_CUR_VIDEO_MODE
2582 export VTOY_EFI_ARCH
2583 export VTOY_MEM_DISK_STR
2584 export VTOY_ISO_RAW_STR
2585 export VTOY_GRUB2_MODE_STR
2586 export VTOY_WIMBOOT_MODE_STR
2587 export VTOY_ISO_UEFI_DRV_STR
2592 export VTOY_HELP_CMD
2593 export VTOY_CHKSUM_CMD
2594 export VTOY_HELP_TXT_LANGUAGE
2595 export VTOY_CHKSUM_FILE_PATH
2596 export VTOY_LANG_CMD
2599 #colect all image files (iso files)
2600 set ventoy_img_count=0
2601 vt_list_img $vtoy_iso_part ventoy_img_count
2604 if [ $ventoy_img_count -gt 0 ]; then
2605 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
2611 if [ -n "$VTOY_NO_ISO_TIP" ]; then
2612 NO_ISO_MENU="No ISO or supported IMG files found, $VTOY_NO_ISO_TIP"
2613 elif [ -n "$VTOY_DEFAULT_SEARCH_ROOT" ]; then
2614 NO_ISO_MENU="No ISO or supported IMG files found, please check VTOY_DEFAULT_SEARCH_ROOT"
2616 NO_ISO_MENU="No ISO or supported IMG files found"
2618 menuentry "$NO_ISO_MENU (Press enter to reboot ...)" {
2619 echo -e "\n Rebooting ... "
2625 #special VTOY_DEFAULT_IMAGE process
2626 if [ -n "$VTOY_DEFAULT_IMAGE" ]; then
2627 if regexp --set 1:vtHotkey --set 2:vtDefault "(F[2-9])>(.*)" "$VTOY_DEFAULT_IMAGE"; then
2629 set default="$vtDefault"
2630 if [ -z "$VTOY_MENU_TIMEOUT" ]; then
2633 set timeout=$VTOY_MENU_TIMEOUT
2641 if [ "$vtHotkey" = "F2" ]; then
2644 elif [ "$vtHotkey" = "F4" ]; then
2646 elif [ "$vtHotkey" = "F5" ]; then
2648 elif [ "$vtHotkey" = "F6" ]; then