]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/grub/grub.cfg
Update tr_TR.json (#2018)
[Ventoy.git] / INSTALL / grub / grub.cfg
1 #************************************************************************************
2 # Copyright (c) 2020, longpanda <admin@ventoy.net>
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, see <http://www.gnu.org/licenses/>.
16 #
17 #************************************************************************************
18
19 function ventoy_pause {
20 echo "press Enter to continue ......"
21 read vtTmpPause
22 }
23
24 function ventoy_debug_pause {
25 if [ -n "${vtdebug_flag}" ]; then
26 echo "press Enter to continue ......"
27 read vtTmpPause
28 fi
29 }
30
31 function ventoy_cli_console {
32 if [ -z "$vtoy_display_mode" ]; then
33 terminal_output console
34 elif [ "$vtoy_display_mode" = "GUI" ]; then
35 terminal_output console
36 fi
37 }
38
39 function ventoy_gui_console {
40 if [ -z "$vtoy_display_mode" ]; then
41 terminal_output gfxterm
42 elif [ "$vtoy_display_mode" = "GUI" ]; then
43 terminal_output gfxterm
44 fi
45 }
46
47 function ventoy_acpi_param {
48 if [ "$VTOY_PARAM_NO_ACPI" != "1" ]; then
49 vt_acpi_param "$1" "$2"
50 fi
51 }
52
53 function ventoy_vcfg_proc {
54 if vt_check_custom_boot "${1}" vt_vcfg; then
55 set vtoy_chosen_path="${1}"
56 vt_file_basefile "${vtoy_chosen_path}" vtoy_chosen_file
57
58 export vtoy_chosen_path
59 export vtoy_chosen_file
60 ventoy_debug_pause
61 configfile "${vtoy_iso_part}${vt_vcfg}"
62 true
63 else
64 false
65 fi
66 }
67
68 function ventoy_language {
69 configfile $prefix/menulang.cfg
70 }
71
72 function ventoy_diagnosis {
73 vt_enum_video_mode
74 configfile $prefix/debug.cfg
75 }
76
77 function ventoy_localboot {
78 configfile $prefix/localboot.cfg
79 }
80
81 function ventoy_ext_menu {
82 if [ -e $vt_plugin_path/ventoy/ventoy_grub.cfg ]; then
83 set ventoy_new_context=1
84 configfile $vt_plugin_path/ventoy/ventoy_grub.cfg
85 unset ventoy_new_context
86 else
87 echo "ventoy_grub.cfg NOT exist."
88 echo -e "\npress ENTER to exit ..."
89 read vtInputKey
90 fi
91 }
92
93 function ventoy_checksum {
94 if [ -f "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}" ]; then
95 configfile $prefix/checksum.cfg
96 fi
97 }
98
99 function ventoy_show_help {
100 if [ -f $prefix/help.tar.gz ]; then
101 if [ -z "$vtoy_help_txt_mem_addr" ]; then
102 vt_load_file_to_mem "auto" $prefix/help.tar.gz vtoy_help_txt_mem
103 fi
104
105 loopback vt_help_tarfs mem:${vtoy_help_txt_mem_addr}:size:${vtoy_help_txt_mem_size}
106 vt_cur_menu_lang vtCurLang
107 if [ -f "(vt_help_tarfs)/help/${vtCurLang}.txt" ]; then
108 cat "(vt_help_tarfs)/help/${vtCurLang}.txt"
109 else
110 cat "(vt_help_tarfs)/help/en_US.txt"
111 fi
112 loopback -d vt_help_tarfs
113 fi
114 }
115
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}
119 }
120
121 function get_os_type {
122 set vtoy_os=Linux
123
124 if vt_str_begin "$vt_volume_id" "DLC Boot"; then
125 if [ -f (loop)/DLCBoot.exe ]; then
126 set vtoy_os=Windows
127 fi
128 else
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
131 set vtoy_os=Windows
132 break
133 fi
134 done
135 fi
136
137 if [ "$vtoy_os" = "Linux" ]; then
138 if vt_strstr "$vt_system_id" "FreeBSD"; then
139 set vtoy_os=Unix
140 set vt_unix_type=FreeBSD
141 elif [ -e (loop)/bin/freebsd-version ]; then
142 set vtoy_os=Unix
143 set vt_unix_type=FreeBSD
144 elif [ -e (loop)/boot/kernel/geom_ventoy.ko ]; then
145 set vtoy_os=Unix
146 set vt_unix_type=FreeBSD
147 elif vt_str_begin "$vt_system_id" "DragonFly"; then
148 set vtoy_os=Unix
149 set vt_unix_type=DragonFly
150
151
152 elif [ -e (loop)/boot/kernel/kernel ]; then
153 if file --is-x86-kfreebsd (loop)/boot/kernel/kernel; then
154 set vtoy_os=Unix
155 set vt_unix_type=FreeBSD
156 elif file --is-x86-knetbsd (loop)/boot/kernel/kernel; then
157 set vtoy_os=Unix
158 set vt_unix_type=NetBSD
159 fi
160 fi
161 fi
162
163 if [ -n "${vtdebug_flag}" ]; then
164 echo ISO is "$vtoy_os"
165 fi
166 }
167
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
173 fi
174
175 return
176 }
177
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
183 fi
184
185 return
186 }
187
188 function locate_initrd {
189 vt_linux_locate_initrd
190
191 if [ -n "${vtdebug_flag}" ]; then
192 vt_linux_dump_initrd
193 ventoy_debug_pause
194 fi
195 }
196
197 function locate_wim {
198 vt_windows_locate_wim_patch (loop) "$1"
199
200 if [ -n "${vtdebug_flag}" ]; then
201 echo '###############################################'
202 vt_dump_wim_patch
203 echo '###############################################'
204 ventoy_debug_pause
205 fi
206 }
207
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
218 fi
219 }
220
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
224 fi
225
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
230 fi
231 done
232 fi
233
234 }
235
236
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
243 fi
244 elif [ -d (loop)/casper ]; then
245 if [ -e (loop)/casper/initrd ]; then
246 vt_linux_specify_initrd_file /casper/initrd
247 fi
248 if [ -e (loop)/casper/initrd.gz ]; then
249 vt_linux_specify_initrd_file /casper/initrd.gz
250 fi
251 if [ -e (loop)/casper/initrd-oem ]; then
252 vt_linux_specify_initrd_file /casper/initrd-oem
253 fi
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
278
279 fi
280
281 if [ -f (loop)/isolinux/initrd.gz ]; then
282 vt_linux_specify_initrd_file /isolinux/initrd.gz
283 fi
284
285 if vt_str_begin "$vt_volume_id" "QUBES"; then
286 vt_linux_specify_initrd_file /images/pxeboot/initrd.img
287 fi
288
289 if [ "$vt_chosen_size" = "1133375488" ]; then
290 if [ -d (loop)/boot/grub/x86_64-efi ]; then
291 vt_cpio_busybox64 "64h"
292 fi
293 fi
294 }
295
296
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
320 fi
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
325 fi
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
330 fi
331 elif [ -f (loop)/EFI/BOOT/initrd.img ]; then
332 #Qubes
333 vt_linux_specify_initrd_file /EFI/BOOT/initrd.img
334 if [ "$grub_platform" != "pc" ]; then
335 vt_add_replace_file 0 "initrd.img"
336 fi
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"
353 fi
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"
358 fi
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
363
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"
374 fi
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
379 fi
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
396
397 fi
398 }
399
400 function ventoy_get_ghostbsd_ver {
401 # fallback to parse version from elf /boot/kernel/kernel
402 set vt_freebsd_ver=xx
403 }
404
405 function ventoy_get_furybsd_ver {
406 if regexp "13\.[0-9]" "$2"; then
407 set vt_freebsd_ver=13.x
408 else
409 set vt_freebsd_ver=12.x
410 fi
411 }
412
413 function ventoy_get_freenas_ver {
414 set vt_freebsd_ver=11.x
415
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
424 fi
425 fi
426 }
427
428 function ventoy_get_truenas_ver {
429 set vt_freebsd_ver=12.x
430
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
439 fi
440 fi
441 }
442
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
450 fi
451 }
452
453 function ventoy_freebsd_proc {
454 set vtFreeBsdDistro=FreeBSD
455 set vt_freebsd_ver=xx
456
457 if [ -e (loop)/boot/kernel/geom_ventoy.ko ]; then
458 vt_unix_ko_fillmap /boot/kernel/geom_ventoy.ko
459 return
460 fi
461
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
495 fi
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
508 fi
509 elif vt_strstr "${chosen_path}" "MidnightBSD"; then
510 set vt_freebsd_ver=9.x
511 fi
512
513
514 if [ -e (loop)/usr/freebsd-dist/cloninst.sh ]; then
515 set vtFreeBsdDistro=ClonOS
516 fi
517
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
523 fi
524 break
525 fi
526 done
527
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
533 fi
534
535 if [ "$vt_freebsd_ver" = "xx" ]; then
536 set vt_freebsd_ver=13.x
537 fi
538 fi
539
540 if [ -n "${vtdebug_flag}" ]; then
541 echo "This is $vtFreeBsdDistro $vt_freebsd_ver ${vt_freebsd_bit}bit"
542 fi
543
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}
548 break
549 fi
550 done
551
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"
559 else
560 vt_unix_replace_conf FreeBSD "${1}${chosen_path}" "cd9"
561 fi
562 fi
563 }
564
565 function ventoy_dragonfly_proc {
566
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}
571 break
572 fi
573 done
574
575 vt_unix_replace_ko $vt_unix_mod_path ${vtoy_path}/dragonfly.mfs.xz
576 vt_unix_fill_image_desc
577 vt_unix_gzip_new_ko
578 vt_unix_replace_conf DragonFly "${1}${chosen_path}"
579 }
580
581 function ventoy_unix_comm_proc {
582 vt_unix_reset
583
584 vt_unix_check_vlnk "${1}${chosen_path}"
585
586 if [ "$ventoy_compatible" = "NO" ]; then
587 loopback vtunix $vtoy_efi_part/ventoy/ventoy_unix.cpio
588
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"
595
596
597 else
598 if [ -n "${vtdebug_flag}" ]; then
599 echo "Unknown unix type"
600 fi
601 fi
602 fi
603
604 vt_unix_chain_data "${1}${chosen_path}"
605 ventoy_debug_pause
606 }
607
608
609 function uefi_windows_menu_func {
610 vt_windows_reset
611
612 unset vt_cur_wimboot_mode
613 if vt_check_mode 4 "$vt_chosen_name"; then
614 set vt_cur_wimboot_mode=1
615 fi
616
617 if [ "$ventoy_compatible" = "NO" -o "$vt_cur_wimboot_mode" = "1" ]; then
618 if [ "$ventoy_fs_probe" = "iso9660" ]; then
619 loopback -d loop
620 vt_iso9660_nojoliet 1
621 loopback loop "$1$2"
622 fi
623
624 for file in "efi/microsoft/boot/bcd"; do
625 vt_windows_collect_wim_patch bcd (loop)/$file
626 done
627
628 vt_windows_count_wim_patch vt_wim_cnt
629 if [ $vt_wim_cnt -eq 0 ]; then
630 distro_specify_wim_patch_phase2
631 fi
632
633 ventoy_debug_pause
634 locate_wim "${chosen_path}"
635 fi
636
637 vt_windows_chain_data "${1}${chosen_path}"
638 ventoy_debug_pause
639
640 if [ "$vt_cur_wimboot_mode" = "1" ]; then
641 vtoy_wimboot_func
642 fi
643
644 if [ -n "$vtoy_chain_mem_addr" ]; then
645 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
646 ventoy_cli_console
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}
648 boot
649 else
650 echo "chain empty failed"
651 ventoy_pause
652 fi
653 }
654
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}"
658
659 unset vt_rp_initrd
660 vt_search_replace_initrd (vtefivdisk) vt_rp_initrd
661
662 if [ -n "$vt_rp_initrd" ]; then
663 vt_add_replace_file $3 "$vt_rp_initrd"
664 fi
665
666 loopback -d vtefivdisk
667 ventoy_debug_pause
668 fi
669 }
670
671 function uefi_linux_menu_func {
672
673 if [ "$ventoy_compatible" = "NO" ]; then
674
675 if [ "$ventoy_fs_probe" = "udf" ]; then
676 loopback -d loop
677 set ventoy_fs_probe=iso9660
678 loopback loop "$1$2"
679 fi
680
681 vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver"
682
683 vt_linux_clear_initrd
684
685 if [ -d (loop)/pmagic ]; then
686 vt_linux_specify_initrd_file /pmagic/initrd.img
687 else
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
691 fi
692 done
693 fi
694
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/
700 fi
701
702 distro_specify_initrd_file
703
704 vt_linux_initrd_count vtcount
705
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
709 fi
710 distro_specify_initrd_file_phase2
711
712 if [ "$vt_efi_dir" = "NO" ]; then
713 if [ -f (loop)/efi.img ]; then
714 vt_add_replace_file 0 "initrd"
715 fi
716 fi
717 fi
718
719 locate_initrd
720
721 if [ -d (loop)/loader/entries ]; then
722 vt_linux_get_main_initrd_index vtindex
723
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"
731 fi
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"
737 fi
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"
741 fi
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"
747 fi
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"
754 fi
755
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
759 fi
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"
765 fi
766 elif [ -d (loop)/EFI/BOOT/entries ]; then
767 vt_linux_get_main_initrd_index vtindex
768
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"
773 fi
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'
777
778 elif vt_str_begin "$vt_volume_id" "SolusLive"; then
779 vt_add_replace_file 0 "initrd"
780
781 fi
782
783 fi
784
785 vt_linux_chain_data "${1}${chosen_path}"
786
787 if [ -n "$LoadIsoEfiDriver" -a $vt_chosen_size -LT 104857600 ]; then
788 if [ -f (loop)/efi/clover/cloverx64.efi ]; then
789 unset LoadIsoEfiDriver
790 fi
791 fi
792
793 if [ -n "$vtoy_chain_mem_addr" ]; then
794 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
795 ventoy_cli_console
796
797 unset vtGrub2Mode
798 if vt_check_mode 3 "$vt_chosen_name"; then
799 set vtGrub2Mode=1
800 elif vt_str_begin "$vt_volume_id" "HOLO_"; then
801 if [ -d (loop)/loader/entries ]; then
802 set vtGrub2Mode=1
803 fi
804 elif vt_str_begin "$vt_volume_id" "KRD"; then
805 if [ -f (loop)/boot/grub/grub.cfg.sig ]; then
806 set vtGrub2Mode=1
807 fi
808 fi
809
810 if [ -n "$vtGrub2Mode" ]; then
811 ventoy_debug_pause
812 else
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}
815 boot
816 fi
817 fi
818
819 # fallback
820 set vtback_root=$root
821 vt_push_last_entry
822 set vtback_theme=$theme
823 unset theme
824
825 vt_trailer_cpio "$vtoy_iso_part" "$vt_chosen_path" noinit
826 vt_set_boot_opt rdinit=/vtoy/vtoy
827
828 set root=(loop)
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
833 configfile "$cfg"
834 break
835 fi
836 done
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
840 set root=(loop,2)
841 vt_systemd_menu (loop,2) vt_sys_menu_mem
842 else
843 vt_systemd_menu (loop) vt_sys_menu_mem
844 fi
845 set vtback_cfg_find=1
846 configfile "mem:${vt_sys_menu_mem_addr}:size:${vt_sys_menu_mem_size}"
847 fi
848 fi
849
850 if [ "$vtback_cfg_find" = "0" ]; then
851 echo " "
852 echo "No bootfile found for UEFI!"
853 echo "Maybe the image does not support $VTOY_EFI_ARCH UEFI"
854 echo " "
855 sleep 30
856 fi
857
858 vt_unset_boot_opt
859 set root=$vtback_root
860 set theme=$vtback_theme
861 vt_pop_last_entry
862 ventoy_gui_console
863 else
864 echo "chain empty failed"
865 ventoy_pause
866 fi
867 }
868
869 function uefi_unix_menu_func {
870 ventoy_unix_comm_proc $1 "${chosen_path}"
871
872 if [ -n "$vtoy_chain_mem_addr" ]; then
873 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
874 ventoy_cli_console
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}
876 boot
877 else
878 echo "chain empty failed"
879 ventoy_pause
880 fi
881 }
882
883 function ventoy_reset_nojoliet {
884 if vt_str_begin "$vt_volume_id" "ARCARESCUE"; then
885 vt_iso9660_nojoliet 1
886 else
887 vt_iso9660_nojoliet 0
888 fi
889
890 vt_append_extra_sector 0
891 }
892
893 function uefi_iso_menu_func {
894
895 if [ -d (loop)/ ]; then
896 loopback -d loop
897 fi
898
899 if [ -n "$vtisouefi" ]; then
900 set LoadIsoEfiDriver=on
901 unset vtisouefi
902 elif vt_check_mode 2 "$vt_chosen_name"; then
903 set LoadIsoEfiDriver=on
904 else
905 unset LoadIsoEfiDriver
906 fi
907
908 set chosen_path="$2"
909 vt_select_auto_install "${chosen_path}"
910 vt_select_persistence "${chosen_path}"
911
912 if vt_is_udf "${1}${chosen_path}"; then
913 set ventoy_fs_probe=udf
914 else
915 set ventoy_fs_probe=iso9660
916 ventoy_reset_nojoliet
917
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
922 fi
923 fi
924
925 loopback loop "${1}${chosen_path}"
926 get_os_type (loop)
927
928 if [ -d (loop)/EFI ]; then
929 set vt_efi_dir=YES
930 elif [ -d (loop)/efi ]; then
931 set vt_efi_dir=YES
932 else
933 set vt_efi_dir=NO
934 fi
935
936 if [ -n "$vtcompat" ]; then
937 set ventoy_compatible=YES
938 unset vtcompat
939 elif vt_check_mode 1 "$vt_chosen_name"; then
940 set ventoy_compatible=YES
941 else
942 vt_check_compatible (loop)
943 fi
944
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
950 return
951 fi
952 fi
953
954 vt_img_sector "${1}${chosen_path}"
955
956 if [ "$ventoy_fs_probe" = "iso9660" ]; then
957 vt_select_conf_replace "${1}" "${chosen_path}"
958 fi
959
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}"
965 else
966 vt_check_compatible_linux (loop)
967 uefi_linux_menu_func "$1" "${chosen_path}"
968 fi
969
970 ventoy_gui_console
971 vt_secondary_recover_mode
972 }
973
974 function uefi_iso_memdisk {
975 echo 'Loading ISO file to memory ...'
976 vt_load_img_memdisk "${1}${2}" vtoy_iso_buf
977
978 ventoy_cli_console
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}
980 boot
981
982 ventoy_gui_console
983 }
984
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
990 else
991 set vtoy_wimboot_prefix=(loop)/x64
992 fi
993 else
994 set vtoy_wimboot_prefix=(loop)
995 if vt_is_pe64 $vtoy_wimboot_prefix/setup.exe; then
996 set vtoy_wimboot_bit=64
997 else
998 set vtoy_wimboot_bit=32
999 fi
1000 fi
1001
1002 if [ -n "${vtdebug_flag}" ]; then
1003 echo vtoy_wimboot_prefix=$vtoy_wimboot_prefix vtoy_wimboot_bit=$vtoy_wimboot_bit vt_wimkernel=$vt_wimkernel
1004 fi
1005
1006 vt_windows_wimboot_data "$vtoy_wimboot_prefix/sources/boot.wim" vtoy_init_exe vtoy_wim_bit
1007
1008 if [ "$grub_platform" = "pc" ]; then
1009 linux16 "$vtoy_path/$vt_wimkernel" quiet
1010 ventoy_debug_pause
1011
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
1019 boot
1020 else
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
1024
1025 if [ $? -eq 0 ]; then
1026 set vtoy_wimfile_path=mem:${vtoy_wimfile_mem_addr}:size:${vtoy_wimfile_mem_size}
1027 else
1028 set vtoy_wimfile_path=$vtoy_wimboot_prefix/sources/boot.wim
1029 fi
1030
1031 ventoy_cli_console
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
1040 boot
1041 ventoy_gui_console
1042 fi
1043 }
1044
1045 function vtoy_winpe_wimboot {
1046 unset vtoy_boot_sdi_legacy
1047 unset vtoy_boot_sdi_efi
1048
1049 set vtoy_wimboot_prefix=(loop)
1050 set vtoy_wim_path="$1"
1051
1052 if [ -n "${vtdebug_flag}" ]; then
1053 echo "winpe_wimboot $1 $2 $3"
1054 fi
1055
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"
1059 fi
1060
1061 vt_windows_wimboot_data $vtoy_wimboot_prefix/$vtoy_wim_path vtoy_init_exe vtoy_wim_bit
1062
1063 if [ "$grub_platform" = "pc" ]; then
1064 linux16 "$vtoy_path/$vt_wimkernel" quiet
1065 ventoy_debug_pause
1066
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
1075 boot
1076 else
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"
1080 fi
1081
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
1085
1086 if [ $? -eq 0 ]; then
1087 set vtoy_wimfile_path=mem:${vtoy_wimfile_mem_addr}:size:${vtoy_wimfile_mem_size}
1088 else
1089 set vtoy_wimfile_path=$vtoy_wimboot_prefix/$vtoy_wim_path
1090 fi
1091
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"
1095 fi
1096
1097 ventoy_cli_console
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
1107 boot
1108 ventoy_gui_console
1109 fi
1110 }
1111
1112 function vtoy_wimboot_func {
1113 if [ "$grub_platform" = "pc" ]; then
1114 set vt_wimkernel=wimboot.x86_64.xz
1115 else
1116 if [ "$grub_cpu" = "i386" ]; then
1117 set vt_wimkernel=wimboot.i386.efi.xz
1118 else
1119 set vt_wimkernel=wimboot.x86_64.xz
1120 fi
1121 fi
1122
1123 if vt_is_standard_winiso (loop); then
1124 echo -e "\n==================== VENTOY WIMBOOT ==================\n"
1125 vtoy_windows_wimboot
1126 else
1127 vt_sel_winpe_wim (loop)
1128 if [ -n "$vtoy_pe_wim_path" ]; then
1129 echo -e "\n==================== VENTOY WIMBOOT ==================\n"
1130
1131 vt_fs_ignore_case 1
1132 vt_load_file_to_mem "auto" $vtoy_path/common_bcd.xz vtoy_pe_bcd_mem
1133
1134 set vt_sdi_path=0
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
1139 break
1140 fi
1141 done
1142
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
1146 else
1147 vtoy_winpe_wimboot "$vtoy_pe_wim_path" "$vt_sdi_path" 0
1148 fi
1149
1150 vt_fs_ignore_case 0
1151 fi
1152 fi
1153 }
1154
1155 function legacy_windows_menu_func {
1156 vt_windows_reset
1157
1158 unset vt_cur_wimboot_mode
1159 if vt_check_mode 4 "$vt_chosen_name"; then
1160 set vt_cur_wimboot_mode=1
1161 fi
1162
1163 if [ "$ventoy_compatible" = "NO" -o "$vt_cur_wimboot_mode" = "1" ]; then
1164 if [ "$ventoy_fs_probe" = "iso9660" ]; then
1165 loopback -d loop
1166 vt_iso9660_nojoliet 1
1167 loopback loop "$1$2"
1168 fi
1169
1170 for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD" "boot/bce"; do
1171 vt_windows_collect_wim_patch bcd (loop)/$file
1172 done
1173
1174 distro_specify_wim_patch
1175
1176 vt_windows_count_wim_patch vt_wim_cnt
1177 if [ $vt_wim_cnt -eq 0 ]; then
1178 distro_specify_wim_patch_phase2
1179 fi
1180
1181 ventoy_debug_pause
1182 if [ -z "$vt_cur_wimboot_mode" ]; then
1183 locate_wim "${chosen_path}"
1184 fi
1185 fi
1186
1187 vt_windows_chain_data "${1}${chosen_path}"
1188 ventoy_debug_pause
1189
1190 if [ "$vt_cur_wimboot_mode" = "1" ]; then
1191 vtoy_wimboot_func
1192 fi
1193
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}
1198 else
1199 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1200 fi
1201 boot
1202 else
1203 echo "chain empty failed"
1204 ventoy_pause
1205 fi
1206 }
1207
1208 function legacy_linux_menu_func {
1209 if [ "$ventoy_compatible" = "NO" ]; then
1210
1211 if [ "$ventoy_fs_probe" = "udf" ]; then
1212 loopback -d loop
1213 set ventoy_fs_probe=iso9660
1214 loopback loop "$1$2"
1215 fi
1216
1217
1218 if vt_syslinux_need_nojoliet "$1$2"; then
1219 vt_iso9660_nojoliet 1
1220 loopback -d loop
1221 loopback loop "$1$2"
1222 fi
1223
1224 vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver"
1225
1226 vt_linux_clear_initrd
1227
1228 if [ -d (loop)/pmagic ]; then
1229 vt_linux_specify_initrd_file /pmagic/initrd.img
1230 else
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/
1234 fi
1235 done
1236 fi
1237
1238 # special process for special distros
1239 #archlinux
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/
1245
1246 #manjaro
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
1250 fi
1251 elif [ -e (loop)/boot/grub/grub.cfg ]; then
1252 vt_linux_parse_initrd_grub file (loop)/boot/grub/grub.cfg
1253 fi
1254
1255 distro_specify_initrd_file
1256
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/
1261 fi
1262
1263 distro_specify_initrd_file_phase2
1264 fi
1265
1266 locate_initrd
1267 fi
1268
1269 vt_linux_chain_data "${1}${chosen_path}"
1270 ventoy_debug_pause
1271
1272 if [ -n "$vtoy_chain_mem_addr" ]; then
1273 unset vtGrub2Mode
1274 if vt_check_mode 3 "$vt_chosen_name"; then
1275 set vtGrub2Mode=1
1276 elif vt_str_begin "$vt_volume_id" "HOLO_"; then
1277 if [ -d (loop)/loader/entries ]; then
1278 set vtGrub2Mode=1
1279 fi
1280 fi
1281
1282 if [ -n "$vtGrub2Mode" ]; then
1283 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
1284 ventoy_cli_console
1285
1286 # fallback
1287 set vtback_root=$root
1288 vt_push_last_entry
1289 set vtback_theme=$theme
1290 unset theme
1291
1292 vt_trailer_cpio "$vtoy_iso_part" "$vt_chosen_path" noinit
1293 vt_set_boot_opt rdinit=/vtoy/vtoy
1294
1295 set root=(loop)
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
1300 configfile "$cfg"
1301 break
1302 fi
1303 done
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
1307 set root=(loop,2)
1308 vt_systemd_menu (loop,2) vt_sys_menu_mem
1309 else
1310 vt_systemd_menu (loop) vt_sys_menu_mem
1311 fi
1312 set vtback_cfg_find=1
1313 configfile "mem:${vt_sys_menu_mem_addr}:size:${vt_sys_menu_mem_size}"
1314 fi
1315 fi
1316
1317 vt_unset_boot_opt
1318 set root=$vtback_root
1319 set theme=$vtback_theme
1320 vt_pop_last_entry
1321 ventoy_gui_console
1322 else
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}
1325 boot
1326 fi
1327 else
1328 echo "chain empty failed"
1329 ventoy_pause
1330 fi
1331 }
1332
1333
1334 function legacy_unix_menu_func {
1335 ventoy_unix_comm_proc $1 "${chosen_path}"
1336
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}
1340 boot
1341 else
1342 echo "chain empty failed"
1343 ventoy_pause
1344 fi
1345 }
1346
1347
1348 function legacy_iso_menu_func {
1349
1350 if [ -d (loop)/ ]; then
1351 loopback -d loop
1352 fi
1353
1354 set chosen_path="$2"
1355
1356 vt_select_auto_install "${chosen_path}"
1357 vt_select_persistence "${chosen_path}"
1358
1359 if vt_is_udf "${1}${chosen_path}"; then
1360 set ventoy_fs_probe=udf
1361 else
1362 set ventoy_fs_probe=iso9660
1363 ventoy_reset_nojoliet
1364 fi
1365
1366 loopback loop "${1}${chosen_path}"
1367
1368 get_os_type (loop)
1369
1370 if [ -n "$vtcompat" ]; then
1371 set ventoy_compatible=YES
1372 unset vtcompat
1373 elif vt_check_mode 1 "$vt_chosen_name"; then
1374 set ventoy_compatible=YES
1375 else
1376 vt_check_compatible (loop)
1377 fi
1378
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
1384 return
1385 fi
1386 fi
1387
1388 vt_img_sector "${1}${chosen_path}"
1389
1390 if [ "$ventoy_fs_probe" = "iso9660" ]; then
1391 vt_select_conf_replace "${1}" "${chosen_path}"
1392 fi
1393
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}"
1399 else
1400 vt_check_compatible_linux (loop)
1401 legacy_linux_menu_func "$1" "${chosen_path}"
1402 fi
1403 vt_secondary_recover_mode
1404 }
1405
1406 function legacy_iso_memdisk {
1407
1408 linux16 $vtoy_path/memdisk iso raw
1409 echo "Loading ISO file to memory ..."
1410 initrd16 "${1}${2}"
1411 boot
1412 }
1413
1414
1415 function iso_endless_os_proc {
1416 if [ -d (loop)/ ]; then
1417 loopback -d loop
1418 fi
1419
1420 loopback loop "${1}${2}"
1421 vt_img_sector "${1}${2}"
1422
1423 vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver"
1424 vt_trailer_cpio "$1" "$2" noinit
1425
1426 ventoy_debug_pause
1427
1428 vt_set_boot_opt '@kparams' rdinit=/vtoy/vtoy
1429
1430 set eosimage=loop
1431 set ventoy_bls_bootdev=/boot
1432 set ventoy_loading_tip="Loading files ......"
1433
1434 export eosimage
1435 configfile (loop)/endless/grub/grub.cfg
1436
1437 unset eosimage
1438 unset ventoy_bls_bootdev
1439 unset ventoy_loading_tip
1440
1441 vt_unset_boot_opt
1442 }
1443
1444
1445 function ventoy_iso_busybox_ver {
1446
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
1451 else
1452 set ventoy_busybox_ver=32
1453
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
1458 fi
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
1465
1466 fi
1467 fi
1468 }
1469
1470
1471 function iso_common_menuentry {
1472 unset vt_system_id
1473 unset vt_volume_id
1474
1475 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
1476
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 (请按 回车 键继续) ..."
1485 read vtInputKey
1486 fi
1487 fi
1488
1489 if vt_check_password "${vt_chosen_path}"; then
1490 return
1491 fi
1492
1493 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1494 return
1495 fi
1496
1497 if vt_str_begin "$vt_volume_id" "Avira"; then
1498 vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}"
1499 fi
1500
1501 ventoy_iso_busybox_ver
1502
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
1507 set vtcompat=1
1508 fi
1509
1510
1511 # auto memdisk mode for some special ISO files
1512 vt_iso_vd_id_parse "${vtoy_iso_part}${vt_chosen_path}"
1513 unset vtMemDiskBoot
1514 if vt_check_mode 0 "$vt_chosen_name"; then
1515 set vtMemDiskBoot=1
1516 else
1517 if [ "$grub_platform" = "pc" ]; then
1518 if vt_iso_vd_id_begin 1 0 "Memtest86+"; then
1519 set vtMemDiskBoot=1
1520 elif vt_iso_vd_id_begin 0 1 "KolibriOS"; then
1521 set vtMemDiskBoot=1
1522 fi
1523 fi
1524
1525 #For iKuai8 (<64MB)
1526 if [ $vt_chosen_size -LE 67108864 ]; then
1527 if vt_str_begin "$vt_chosen_name" "iKuai"; then
1528 set vtMemDiskBoot=1
1529 fi
1530 fi
1531 fi
1532 vt_iso_vd_id_clear
1533
1534
1535 if [ "$grub_platform" = "pc" ]; then
1536 if [ -n "$vtMemDiskBoot" ]; then
1537 legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1538 else
1539 legacy_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
1540 fi
1541 else
1542 if [ -n "$vtMemDiskBoot" ]; then
1543 uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1544 else
1545 uefi_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
1546 fi
1547 fi
1548 }
1549
1550 function miso_common_menuentry {
1551 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
1552
1553 if vt_check_password "${vt_chosen_path}"; then
1554 return
1555 fi
1556
1557 echo "memdisk mode boot for $vt_chosen_path"
1558 echo ""
1559 ventoy_debug_pause
1560
1561 if [ "$grub_platform" = "pc" ]; then
1562 legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1563 else
1564 uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
1565 fi
1566 }
1567
1568
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 (请按 回车 键返回) ..."
1573 read vtInputKey
1574 }
1575
1576 function miso_unsupport_menuentry {
1577 common_unsupport_menuentry
1578 }
1579
1580 function iso_unsupport_menuentry {
1581 common_unsupport_menuentry
1582 }
1583
1584 function wim_common_menuentry {
1585 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
1586
1587 if vt_check_password "${vt_chosen_path}"; then
1588 return
1589 fi
1590
1591 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1592 return
1593 fi
1594
1595 if vt_wim_check_bootable "${vtoy_iso_part}${vt_chosen_path}"; then
1596 vt_wim_chain_data "${vtoy_iso_part}${vt_chosen_path}"
1597 else
1598 echo -e "\n This is NOT a bootable WIM file. \n"
1599 echo -e " 这不是一个可启动的 WIM 文件。\n"
1600 fi
1601
1602 ventoy_debug_pause
1603
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}
1607 else
1608 ventoy_cli_console
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}
1610 ventoy_gui_console
1611 fi
1612 boot
1613 else
1614 echo "chain empty failed"
1615 ventoy_pause
1616 fi
1617 }
1618
1619 function wim_unsupport_menuentry {
1620 common_unsupport_menuentry
1621 }
1622
1623 function efi_common_menuentry {
1624 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
1625
1626 if vt_check_password "${vt_chosen_path}"; then
1627 return
1628 fi
1629
1630 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1631 return
1632 fi
1633
1634 unset vt_vlnk_dst
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"
1639 ventoy_pause
1640 return
1641 fi
1642 else
1643 vt_vlnk_dst="${vtoy_iso_part}${vt_chosen_path}"
1644 fi
1645
1646 ventoy_debug_pause
1647
1648 ventoy_cli_console
1649
1650 #first try with chainload
1651 set vtOldRoot=$root
1652 set root=$vtoy_iso_part
1653 chainloader "${vt_vlnk_dst}"
1654 boot
1655
1656 #retry with isoboot
1657 set root=$vtOldRoot
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}
1660 boot
1661
1662 ventoy_gui_console
1663 }
1664
1665 function efi_unsupport_menuentry {
1666 common_unsupport_menuentry
1667 }
1668
1669 function vhdboot_common_func {
1670 vt_patch_vhdboot "$1"
1671
1672 ventoy_debug_pause
1673
1674 if [ -n "$vtoy_vhd_buf_addr" ]; then
1675 if [ "$grub_platform" = "pc" ]; then
1676 ventoy_cli_console
1677 linux16 $vtoy_path/memdisk iso raw
1678 initrd16 mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size}
1679 boot
1680 ventoy_gui_console
1681 else
1682 ventoy_cli_console
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}
1684 boot
1685 ventoy_gui_console
1686 fi
1687 else
1688 echo "Please put the right ventoy_vhdboot.img file to the 1st partition"
1689 ventoy_pause
1690 fi
1691 }
1692
1693 function vhd_common_menuentry {
1694 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
1695
1696 if vt_check_password "${vt_chosen_path}"; then
1697 return
1698 fi
1699
1700 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1701 return
1702 fi
1703
1704 unset vt_vlnk_dst
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"
1709 ventoy_pause
1710 return
1711 fi
1712 else
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 (请按 回车 键继续) ..."
1720 read vtInputKey
1721 fi
1722 fi
1723 fi
1724
1725 vhdboot_common_func "${vt_vlnk_dst}"
1726 }
1727
1728 function vhd_unsupport_menuentry {
1729 common_unsupport_menuentry
1730 }
1731
1732 function vtoyboot_common_func {
1733 set AltBootPart=0
1734 set vtoysupport=0
1735
1736 vt_get_vtoy_type "${1}" vtoytype parttype AltBootPart
1737
1738 if vt_str_begin $vtoytype vhd; then
1739 set vtoysupport=1
1740 elif [ "$vtoytype" = "raw" ]; then
1741 set vtoysupport=1
1742 elif [ "$vtoytype" = "vdi" ]; then
1743 set vtoysupport=1
1744 fi
1745
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模式,可能无法正常启动。"
1751 ventoy_pause
1752 fi
1753 else
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模式,可能无法正常启动。"
1757 ventoy_pause
1758 fi
1759 fi
1760
1761 vt_img_sector "${1}"
1762 vt_raw_chain_data "${1}"
1763
1764 ventoy_debug_pause
1765
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}
1770 boot
1771 else
1772 if vt_check_secureboot_var; then
1773 vt_acpi_param ${vtoy_chain_mem_addr} 512
1774 fi
1775 ventoy_cli_console
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}
1777 boot
1778 ventoy_gui_console
1779 fi
1780 else
1781 echo "chain empty failed!"
1782 ventoy_pause
1783 fi
1784 else
1785 echo "Unsupported vtoy type $vtoytype"
1786 ventoy_pause
1787 fi
1788 }
1789
1790 function vtoy_common_menuentry {
1791 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
1792
1793 if vt_check_password "${vt_chosen_path}"; then
1794 return
1795 fi
1796
1797 if ventoy_vcfg_proc "${vt_chosen_path}"; then
1798 return
1799 fi
1800
1801 unset vt_vlnk_dst
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"
1806 ventoy_pause
1807 return
1808 fi
1809 else
1810 vt_vlnk_dst="${vtoy_iso_part}${vt_chosen_path}"
1811 fi
1812
1813 vtoyboot_common_func "${vt_vlnk_dst}"
1814 }
1815
1816 function vtoy_unsupport_menuentry {
1817 common_unsupport_menuentry
1818 }
1819
1820 #
1821 #============================================================#
1822 # IMG file boot process #
1823 #============================================================#
1824 #
1825
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 ..."
1829 read vtInputKey
1830 }
1831
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
1835
1836 loopback easysfs (vtimghd,1)/easy.sfs
1837 vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver
1838
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
1843 fi
1844 done
1845 fi
1846
1847 ventoy_debug_pause
1848
1849 #boot image file
1850 vt_set_boot_opt rdinit=/vtoy/vtoy
1851 vt_img_hook_root
1852
1853 syslinux_configfile (vtimghd,1)/syslinux.cfg
1854
1855 vt_img_unhook_root
1856 vt_unset_boot_opt
1857 loopback -d easysfs
1858 }
1859
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
1863
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
1869 fi
1870
1871 vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver
1872
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
1877 fi
1878 done
1879 fi
1880
1881 ventoy_debug_pause
1882
1883 #boot image file
1884 vt_set_boot_opt rdinit=/vtoy/vtoy
1885 vt_img_hook_root
1886
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}"
1889
1890 vt_img_unhook_root
1891 vt_unset_boot_opt
1892 loopback -d easysfs
1893 }
1894
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
1898
1899 ventoy_debug_pause
1900
1901 #boot image file
1902 vt_set_boot_opt rdinit=/vtoy/vtoy imgpart=/dev/ventoy2 bootpart=/dev/ventoy1
1903 vt_img_hook_root
1904
1905 syslinux_configfile (vtimghd,1)/syslinux.cfg
1906
1907 vt_img_unhook_root
1908 vt_unset_boot_opt
1909 }
1910
1911 function ventoy_img_openelec {
1912 elec_ver=$1
1913
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
1916
1917 loopback vtloopex $vtoy_efi_part/ventoy/vtloopex.cpio
1918 vt_img_extra_initrd_append (vtloopex)/$elec_ver/vtloopex.tar.xz
1919
1920 ventoy_debug_pause
1921
1922 #boot image file
1923 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=$elec_ver
1924 vt_img_hook_root
1925
1926 set root=(vtimghd,1)
1927 syslinux_configfile (vtimghd,1)/syslinux.cfg
1928
1929 vt_img_unhook_root
1930 vt_unset_boot_opt
1931 loopback -d vtloopex
1932 }
1933
1934
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
1938
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
1942 fi
1943
1944 ventoy_debug_pause
1945
1946 #boot image file
1947 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=freedombox
1948 vt_img_hook_root
1949
1950 configfile (vtimghd,1)/boot/grub/grub.cfg
1951
1952 vt_img_unhook_root
1953 vt_unset_boot_opt
1954 }
1955
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
1959
1960 ventoy_debug_pause
1961
1962 #boot image file
1963 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=paldo
1964 vt_img_hook_root
1965
1966 vt_fs_enum_1st_file (vtimghd,1) /loader/entries/ vt_paldo_entry_conf
1967 vt_file_basename $vt_paldo_entry_conf vtPaldoVer
1968
1969 echo loading file...
1970 linux (vtimghd,1)/linux-${vtPaldoVer} root=/dev/ventoy1 rootfstype=vfat
1971 initrd (vtimghd,1)/initramfs-${vtPaldoVer}
1972 boot
1973
1974 vt_img_unhook_root
1975 vt_unset_boot_opt
1976 }
1977
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
1981
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
1985 fi
1986
1987 ventoy_debug_pause
1988
1989 #boot image file
1990 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=ubos
1991 vt_img_hook_root
1992
1993 echo loading file...
1994 linux (vtimghd,2)/vmlinuz-linux root=/dev/ventoy3 rw
1995 initrd (vtimghd,2)/initramfs-linux.img
1996 boot
1997
1998 vt_img_unhook_root
1999 vt_unset_boot_opt
2000 }
2001
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"
2005 ventoy_pause
2006 return
2007 fi
2008
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
2011
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
2017 fi
2018 fi
2019
2020 ventoy_debug_pause
2021
2022 #boot image file
2023 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=recalbox
2024 vt_img_hook_root
2025
2026 set root=(vtimghd,1)
2027 configfile (vtimghd,1)/boot/grub/grub.cfg
2028
2029 vt_img_unhook_root
2030 vt_unset_boot_opt
2031 }
2032
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
2036
2037 ventoy_debug_pause
2038
2039 #boot image file
2040 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=esysrescue
2041 vt_img_hook_root
2042
2043 set root=(vtimghd,1)
2044 configfile (vtimghd,1)/boot/grub/grub.cfg
2045
2046 vt_img_unhook_root
2047 vt_unset_boot_opt
2048 }
2049
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
2053
2054 ventoy_debug_pause
2055
2056 #boot image file
2057 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=batocera
2058 vt_img_hook_root
2059
2060 set root=(vtimghd,1)
2061 syslinux_configfile (vtimghd,1)/boot/syslinux/syslinux.cfg
2062
2063 vt_img_unhook_root
2064 vt_unset_boot_opt
2065 }
2066
2067 function ventoy_img_openwrt {
2068 if [ -e (vtimghd,2)/lib64 ]; then
2069 set ventoy_busybox_ver=64
2070 fi
2071
2072 vt_fs_enum_1st_dir (vtimghd,2) /lib/modules/ vt_dir_name
2073
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
2079 fi
2080 else
2081 set openwrt_plugin_need=1
2082 if [ ! -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
2083 ventoy_gui_console
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 (请按 回车 键返回) ..."
2087 read vtInputKey
2088 ventoy_cli_console
2089 return
2090 fi
2091 fi
2092
2093 if vt_img_check_range "${vtoy_iso_part}${vt_chosen_path}"; then
2094 ventoy_debug_pause
2095 else
2096 ventoy_gui_console
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 (请按 回车 键返回) ..."
2100 read vtInputKey
2101 ventoy_cli_console
2102 return
2103 fi
2104
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
2107
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
2111 fi
2112 fi
2113
2114 #boot image file
2115 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=openwrt
2116 vt_img_hook_root
2117
2118 set root=(vtimghd,1)
2119 configfile (vtimghd,1)/boot/grub/grub.cfg
2120
2121 vt_img_unhook_root
2122 vt_unset_boot_opt
2123 }
2124
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
2128
2129 ventoy_debug_pause
2130
2131 #boot image file
2132 vt_set_boot_opt rdinit=/vtoy/vtoy live-media=/dev/dm-1 ventoyos=tails
2133 vt_img_hook_root
2134
2135 set root=(vtimghd,1)
2136 configfile (vtimghd,1)/efi/debian/grub.cfg
2137
2138 vt_img_unhook_root
2139 vt_unset_boot_opt
2140 }
2141
2142 function ventoy_img_fydeos {
2143 if [ "$grub_platform" = "pc" ]; then
2144 only_uefi_tip
2145 return
2146 fi
2147
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
2150
2151 ventoy_debug_pause
2152
2153 #boot image file
2154 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=fydeos
2155 vt_img_hook_root
2156
2157 set grubdisk=vtimghd
2158 set grubpartA=(vtimghd,3)
2159 set grubpartB=(vtimghd,5)
2160 set linuxpartA=(sda,3)
2161 set linuxpartB=(sda,5)
2162
2163 set root=(vtimghd,12)
2164 configfile (vtimghd,12)/efi/boot/grub.cfg
2165
2166 vt_img_unhook_root
2167 vt_unset_boot_opt
2168
2169 unset grubdisk
2170 unset grubpartA
2171 unset grubpartB
2172 unset linuxpartA
2173 unset linuxpartB
2174 }
2175
2176 function ventoy_img_cloudready {
2177 if [ "$grub_platform" = "pc" ]; then
2178 only_uefi_tip
2179 return
2180 fi
2181
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
2184
2185 ventoy_debug_pause
2186
2187 #boot image file
2188 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=cloudready
2189 vt_img_hook_root
2190
2191 set grubdisk=vtimghd
2192 set grubpartA=(vtimghd,3)
2193 set grubpartB=(vtimghd,5)
2194 set linuxpartA=(sda,3)
2195 set linuxpartB=(sda,5)
2196
2197 set root=(vtimghd,12)
2198 configfile (vtimghd,12)/efi/boot/grub.cfg
2199
2200 vt_img_unhook_root
2201 vt_unset_boot_opt
2202
2203 unset grubdisk
2204 unset grubpartA
2205 unset grubpartB
2206 unset linuxpartA
2207 unset linuxpartB
2208 }
2209
2210 function ventoy_img_memtest86 {
2211 chainloader (vtimghd,1)/efi/boot/BOOTX64.efi
2212 boot
2213 }
2214
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 (请按 回车 键返回) ..."
2219 read vtInputKey
2220 }
2221
2222 function legacy_img_memdisk {
2223 linux16 $vtoy_path/memdisk
2224 echo "Loading img file to memory ..."
2225 initrd16 "${1}${2}"
2226
2227 ventoy_cli_console
2228 boot
2229 }
2230
2231 function img_common_menuentry {
2232 set ventoy_compatible=YES
2233 set ventoy_busybox_ver=32
2234 unset LoadIsoEfiDriver
2235
2236 vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
2237
2238 if vt_check_password "${vt_chosen_path}"; then
2239 return
2240 fi
2241
2242 if ventoy_vcfg_proc "${vt_chosen_path}"; then
2243 return
2244 fi
2245
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"
2249 return
2250 fi
2251 fi
2252
2253 loopback vtimghd "${vtoy_iso_part}${vt_chosen_path}"
2254 vt_img_sector "${vtoy_iso_part}${vt_chosen_path}"
2255
2256 vt_img_part_info (vtimghd)
2257
2258 set vtback_root=$root
2259 ventoy_cli_console
2260 vt_push_last_entry
2261 set vtback_theme=$theme
2262 unset theme
2263
2264 vt_img_extra_initrd_reset
2265
2266
2267 vt_get_fs_label (vtimghd,1) vtImgHd1Label
2268
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
2273 fi
2274
2275 if [ -e (vtimghd,1)/etc/hostname ]; then
2276 vt_1st_line (vtimghd,1)/etc/hostname vtImgHostname
2277 fi
2278
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
2283 ventoy_img_fydeos
2284 else
2285 ventoy_img_cloudready
2286 fi
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
2291 fi
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
2297 ventoy_img_paldo
2298 elif vt_str_begin "$vtImgHostname" "freedombox"; then
2299 ventoy_img_freedombox
2300 elif vt_str_begin "$vtImgHd1Label" "BATOCERA"; then
2301 ventoy_img_batocera
2302 elif vt_str_begin "$vtImgHd1Label" "Tails"; then
2303 ventoy_img_tails
2304 elif [ "$vtImgHd2Label" = "RECALBOX" -o "$vtImgHd1Label" = "RECALBOX" ]; then
2305 ventoy_img_recalbox
2306 elif [ "$vtImgHd1Label" = "ESYSRESCUE" ]; then
2307 ventoy_img_esysrescue
2308 elif [ -e (vtimghd,1)/easy.sfs ]; then
2309 ventoy_img_easyos
2310 elif [ -d (vtimghd,2)/easyos ]; then
2311 ventoy_img_easyos2
2312 elif [ -e (vtimghd,1)/volumio.initrd ]; then
2313 ventoy_img_volumio
2314 elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then
2315 ventoy_img_ubos
2316 elif [ -f (vtimghd,2)/etc/openwrt_version ]; then
2317 ventoy_img_openwrt
2318 elif [ -f (vtimghd,1)/efi/boot/mt86.png ]; then
2319 if [ "$grub_platform" = "pc" ]; then
2320 img_unsupport_tip
2321 else
2322 ventoy_img_memtest86
2323 fi
2324 else
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}
2329 boot
2330 else
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}
2332 boot
2333 fi
2334 fi
2335
2336 loopback -d vtimghd
2337
2338 set root=$vtback_root
2339 vt_pop_last_entry
2340 set theme=$vtback_theme
2341 ventoy_gui_console
2342 set ventoy_compatible=NO
2343 }
2344
2345 function img_unsupport_menuentry {
2346 common_unsupport_menuentry
2347 }
2348
2349 #############################################################
2350 #############################################################
2351 #############################################################
2352 ####### Main Process ###########
2353 #############################################################
2354 #############################################################
2355 #############################################################
2356
2357 set VENTOY_VERSION="1.0.83"
2358
2359 #ACPI not compatible with Window7/8, so disable by default
2360 set VTOY_PARAM_NO_ACPI=1
2361
2362 # Default menu display mode, you can change it as you want.
2363 # 0: List mode
2364 # 1: TreeView mode
2365 set VTOY_DEFAULT_MENU_MODE=0
2366
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"
2372
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"
2382
2383
2384 if [ "$grub_platform" = "pc" ]; then
2385 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net"
2386 else
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"
2396 else
2397 set VTOY_EFI_ARCH=x64
2398 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION UEFI www.ventoy.net"
2399 fi
2400 fi
2401
2402 vt_device $root vtoy_dev
2403
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)
2410 set vtoydev=hd$vtid
2411 break
2412 fi
2413 done
2414 loadfont ascii
2415
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}
2419 fi
2420
2421 if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
2422 set vt_plugin_path=$vtoy_iso_part
2423 else
2424 set vt_plugin_path=$prefix
2425 vt_load_plugin $vt_plugin_path
2426 fi
2427 else
2428 if [ "$prefix" = "(ventoydisk)/grub" ]; then
2429 set vtoy_path=(ventoydisk)/ventoy
2430 else
2431 set vtoy_path=($root)/ventoy
2432 fi
2433
2434 set vtoydev=$vtoy_dev
2435 set vtoy_iso_part=($vtoy_dev,1)
2436 set vtoy_efi_part=($vtoy_dev,2)
2437
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}
2440
2441 set vt_plugin_path=$vtoy_iso_part
2442 fi
2443
2444 #Load Partition Table
2445 vt_load_part_table $vtoydev
2446
2447 #Load menu lang file
2448 ventoy_load_menu_lang_file
2449
2450 #Load Plugin
2451 if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
2452 clear
2453 vt_load_plugin $vtoy_iso_part
2454 clear
2455 else
2456 vt_check_json_path_case $vtoy_iso_part
2457 fi
2458
2459
2460 if [ -n "$VTOY_MENU_TIMEOUT" ]; then
2461 set timeout=$VTOY_MENU_TIMEOUT
2462 else
2463 unset timeout
2464 fi
2465
2466 if [ -f $vtoy_iso_part/ventoy/ventoy_wimboot.img ]; then
2467 vt_load_wimboot $vtoy_iso_part/ventoy/ventoy_wimboot.img
2468 elif [ -f $vtoy_efi_part/ventoy/ventoy_wimboot.img ]; then
2469 vt_load_wimboot $vtoy_efi_part/ventoy/ventoy_wimboot.img
2470 fi
2471
2472 if [ -f $vtoy_iso_part/ventoy/ventoy_vhdboot.img ]; then
2473 vt_load_vhdboot $vtoy_iso_part/ventoy/ventoy_vhdboot.img
2474 elif [ -f $vtoy_efi_part/ventoy/ventoy_vhdboot.img ]; then
2475 vt_load_vhdboot $vtoy_efi_part/ventoy/ventoy_vhdboot.img
2476 fi
2477
2478
2479 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
2480 set VTOY_F3_CMD="vt_dynamic_menu 1 1"
2481 else
2482 set VTOY_F3_CMD="vt_dynamic_menu 1 0"
2483 fi
2484
2485 terminal_output console
2486
2487 if [ -n "$vtoy_gfxmode" ]; then
2488 set gfxmode=$vtoy_gfxmode
2489 set gfxpayload=keep
2490 else
2491 set gfxmode=1024x768
2492 set gfxpayload=keep
2493 fi
2494
2495
2496 if [ "$vtoy_display_mode" = "CLI" ]; then
2497 terminal_output console
2498 elif [ "$vtoy_display_mode" = "serial" ]; then
2499 if [ -n "$vtoy_serial_param" ]; then
2500 serial $vtoy_serial_param
2501 fi
2502 terminal_input serial
2503 terminal_output serial
2504 elif [ "$vtoy_display_mode" = "serial_console" ]; then
2505 if [ -n "$vtoy_serial_param" ]; then
2506 serial $vtoy_serial_param
2507 fi
2508 terminal_input serial console
2509 terminal_output serial console
2510 else
2511 if [ -n "$vtoy_theme" ]; then
2512 vt_set_theme
2513 else
2514 set theme=$prefix/themes/ventoy/theme.txt
2515 fi
2516 terminal_output gfxterm
2517 fi
2518
2519 if [ "$grub_platform" = "efi" ]; then
2520 set mouse_delta=4000
2521 # terminal_input --append mouse
2522 fi
2523
2524 if [ -n "$VTOY_DEFAULT_KBD_LAYOUT" ]; then
2525 set_keyboard_layout "$VTOY_DEFAULT_KBD_LAYOUT"
2526 fi
2527
2528 if [ -n "$VTOY_PLUGIN_PATH_CASE_MISMATCH" ]; then
2529 clear
2530 echo "$VTOY_PLUGIN_PATH_CASE_MISMATCH"
2531 echo -e "\n\nPath case does not match! ventoy directory and ventoy.json MUST be all lowercase!"
2532 echo -e "\n路径大小写不匹配!ventoy 目录和 ventoy.json 文件的名字必须是全部小写,请修正!"
2533 echo -e "\n\npress ENTER to continue (请按回车键继续) ..."
2534 read vtInputKey
2535 fi
2536
2537 if [ -n "$VTOY_PLUGIN_SYNTAX_ERROR" ]; then
2538 clear
2539 if [ -n "$VTOY_PLUGIN_ENCODE_ERROR" ]; then
2540 echo -e "\n Encoding type for ventoy.json is not supported, please convert to UTF-8.\n"
2541 echo -e " ventoy.json 文件编码格式不支持,请转换为 UTF-8 编码格式!\n"
2542 else
2543 echo -e "\n Syntax error detected in ventoy.json, please check! \n"
2544 echo -e " ventoy.json 文件中有语法错误,所有配置都不会生效,请检查!\n"
2545 fi
2546
2547 echo -e "\n press ENTER to continue (请按 回车 键继续) ..."
2548 read vtInputKey
2549 fi
2550
2551
2552 for vtTFile in ventoy.json ventoy_grub.cfg; do
2553 if [ -f $vtoy_efi_part/ventoy/$vtTFile ]; then
2554 clear
2555 echo -e "\n You need to put $vtTFile in the 1st partition which hold the ISO files.\n"
2556 echo -e " $vtTFile 放错分区了,请放到镜像分区里的 ventoy 目录下(此目录需要手动创建)!\n"
2557 echo -e "\n press ENTER to continue (请按 回车 键继续) ..."
2558 read vtInputKey
2559 fi
2560 done
2561
2562 #clear all input key before show main menu
2563 vt_clear_key
2564
2565 #export necessary variable
2566 export theme
2567 export gfxmode
2568 export gfxpayload
2569 export vtoydev
2570 export vtoy_path
2571 export vtdebug_flag
2572 export vtoy_iso_fs
2573 export vtoy_iso_part
2574 export vtoy_efi_part
2575 export VENTOY_VERSION
2576 export VTOY_CUR_VIDEO_MODE
2577 export VTOY_EFI_ARCH
2578 export VTOY_MEM_DISK_STR
2579 export VTOY_ISO_RAW_STR
2580 export VTOY_GRUB2_MODE_STR
2581 export VTOY_WIMBOOT_MODE_STR
2582 export VTOY_ISO_UEFI_DRV_STR
2583 export VTOY_F2_CMD
2584 export VTOY_F4_CMD
2585 export VTOY_F5_CMD
2586 export VTOY_F6_CMD
2587 export VTOY_HELP_CMD
2588 export VTOY_CHKSUM_CMD
2589 export VTOY_HELP_TXT_LANGUAGE
2590 export VTOY_CHKSUM_FILE_PATH
2591 export VTOY_LANG_CMD
2592
2593
2594 #colect all image files (iso files)
2595 set ventoy_img_count=0
2596 vt_list_img $vtoy_iso_part ventoy_img_count
2597
2598 #Main menu
2599 if [ $ventoy_img_count -gt 0 ]; then
2600 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
2601 vt_dynamic_menu 0 0
2602 else
2603 vt_dynamic_menu 0 1
2604 fi
2605 else
2606 if [ -n "$VTOY_NO_ISO_TIP" ]; then
2607 NO_ISO_MENU="No ISO or supported IMG files found, $VTOY_NO_ISO_TIP"
2608 elif [ -n "$VTOY_DEFAULT_SEARCH_ROOT" ]; then
2609 NO_ISO_MENU="No ISO or supported IMG files found, please check VTOY_DEFAULT_SEARCH_ROOT"
2610 else
2611 NO_ISO_MENU="No ISO or supported IMG files found"
2612 fi
2613 menuentry "$NO_ISO_MENU (Press enter to reboot ...)" {
2614 echo -e "\n Rebooting ... "
2615 reboot
2616 }
2617 fi
2618
2619
2620 #special VTOY_DEFAULT_IMAGE process
2621 if [ -n "$VTOY_DEFAULT_IMAGE" ]; then
2622 if regexp --set 1:vtHotkey --set 2:vtDefault "(F[2-9])>(.*)" "$VTOY_DEFAULT_IMAGE"; then
2623
2624 set default="$vtDefault"
2625 if [ -z "$VTOY_MENU_TIMEOUT" ]; then
2626 set timeout=0
2627 else
2628 set timeout=$VTOY_MENU_TIMEOUT
2629 fi
2630
2631 export timeout
2632 export default
2633
2634 vt_fn_mutex_lock 1
2635
2636 if [ "$vtHotkey" = "F2" ]; then
2637 unset timeout
2638 vt_browser_disk
2639 elif [ "$vtHotkey" = "F4" ]; then
2640 ventoy_localboot
2641 elif [ "$vtHotkey" = "F5" ]; then
2642 ventoy_diagnosis
2643 elif [ "$vtHotkey" = "F6" ]; then
2644 ventoy_ext_menu
2645 fi
2646
2647 vt_fn_mutex_lock 0
2648
2649 unset timeout
2650 unset default
2651 fi
2652 fi
2653