+function vhd_unsupport_menuentry {
+ common_unsupport_menuentry
+}
+
+#
+#============================================================#
+# IMG file boot process #
+#============================================================#
+#
+
+
+function ventoy_img_easyos {
+ vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
+ vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
+
+ loopback easysfs (vtimghd,1)/easy.sfs
+ vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver
+
+ if [ -n "$vt_module_ver" ]; then
+ for mod in "kernel/drivers/md/dm-mod.ko" "kernel/drivers/dax/dax.ko"; do
+ vt_img_extra_initrd_append (easysfs)/lib/modules/$vt_module_ver/$mod
+ done
+ fi
+
+ ventoy_debug_pause
+
+ #boot image file
+ vt_set_boot_opt rdinit=/vtoy/vtoy
+ vt_img_hook_root
+
+ syslinux_configfile (vtimghd,1)/syslinux.cfg
+
+ vt_img_unhook_root
+ vt_unset_boot_opt
+ loopback -d easysfs
+}
+
+function ventoy_img_volumio {
+ vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
+ vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
+
+ ventoy_debug_pause
+
+ #boot image file
+ vt_set_boot_opt rdinit=/vtoy/vtoy imgpart=/dev/ventoy2 bootpart=/dev/ventoy1
+ vt_img_hook_root
+
+ syslinux_configfile (vtimghd,1)/syslinux.cfg
+
+ vt_img_unhook_root
+ vt_unset_boot_opt
+}
+
+function ventoy_img_openelec {
+ elec_ver=$1
+
+ vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
+ vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
+
+ loopback vtloopex $vtoy_efi_part/ventoy/vtloopex.cpio
+ vt_img_extra_initrd_append (vtloopex)/$elec_ver/vtloopex.tar.xz
+
+ ventoy_debug_pause
+
+ #boot image file
+ vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=$elec_ver
+ vt_img_hook_root
+
+ set root=(vtimghd,1)
+ syslinux_configfile (vtimghd,1)/syslinux.cfg
+
+ vt_img_unhook_root
+ vt_unset_boot_opt
+ loopback -d vtloopex
+}
+
+
+function ventoy_img_freedombox {
+ vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
+ vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
+
+ vt_get_lib_module_ver (vtimghd,1) /lib/modules/ vt_module_ver
+ if [ -n "$vt_module_ver" ]; then
+ vt_img_extra_initrd_append (vtimghd,1)/lib/modules/$vt_module_ver/kernel/drivers/md/dm-mod.ko
+ fi
+
+ ventoy_debug_pause
+
+ #boot image file
+ vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=freedombox
+ vt_img_hook_root
+
+ configfile (vtimghd,1)/boot/grub/grub.cfg
+
+ vt_img_unhook_root
+ vt_unset_boot_opt
+}
+
+function ventoy_img_paldo {
+ vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
+ vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
+
+ ventoy_debug_pause
+
+ #boot image file
+ vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=paldo
+ vt_img_hook_root
+
+ vt_fs_enum_1st_file (vtimghd,1) /loader/entries/ vt_paldo_entry_conf
+ vt_file_basename $vt_paldo_entry_conf vtPaldoVer
+
+ echo loading file...
+ linux (vtimghd,1)/linux-${vtPaldoVer} root=/dev/ventoy1 rootfstype=vfat
+ initrd (vtimghd,1)/initramfs-${vtPaldoVer}
+ boot
+
+ vt_img_unhook_root
+ vt_unset_boot_opt
+}
+
+function ventoy_img_ubos {
+ vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
+ vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
+
+ vt_get_lib_module_ver (vtimghd,3) /lib/modules/ vt_module_ver
+ if [ -n "$vt_module_ver" ]; then
+ vt_img_extra_initrd_append (vtimghd,3)/lib/modules/$vt_module_ver/kernel/drivers/md/dm-mod.ko.xz
+ fi
+
+ ventoy_debug_pause
+
+ #boot image file
+ vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=ubos
+ vt_img_hook_root
+
+ echo loading file...
+ linux (vtimghd,2)/vmlinuz-linux root=/dev/ventoy3 rw
+ initrd (vtimghd,2)/initramfs-linux.img
+ boot
+
+ vt_img_unhook_root
+ vt_unset_boot_opt
+}
+
+function ventoy_img_recalbox {
+ vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
+ vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
+
+ ventoy_debug_pause
+
+ #boot image file
+ vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=recalbox
+ vt_img_hook_root
+
+ set root=(vtimghd,1)
+ configfile (vtimghd,1)/boot/grub/grub.cfg
+
+ vt_img_unhook_root
+ vt_unset_boot_opt
+}
+
+function ventoy_img_batocera {
+ vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
+ vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
+
+ ventoy_debug_pause
+
+ #boot image file
+ vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=batocera
+ vt_img_hook_root
+
+ set root=(vtimghd,1)
+ syslinux_configfile (vtimghd,1)/boot/syslinux/syslinux.cfg
+
+ vt_img_unhook_root
+ vt_unset_boot_opt
+}
+
+function ventoy_img_memtest86 {
+ chainloader (vtimghd,1)/efi/boot/BOOTX64.efi
+ boot
+}
+
+function img_unsupport_tip {
+ echo -e "\n This IMG file is NOT supported now. \n"
+ echo -e " 当前不支持启动此 IMG 文件 \n"
+ echo -e "\npress ENTER to exit (请按 回车 键返回) ..."
+ read vtInputKey
+}
+
+function img_common_menuentry {
+ set ventoy_compatible=YES
+ set ventoy_busybox_ver=32
+
+ vt_chosen_img_path vt_chosen_path vt_chosen_size
+
+ if [ -d (vtimghd)/ ]; then
+ loopback -d vtimghd
+ fi
+
+ loopback vtimghd ${vtoy_iso_part}${vt_chosen_path}
+ vt_img_sector ${vtoy_iso_part}${vt_chosen_path}
+
+ vt_img_part_info (vtimghd)
+
+ set vtback_root=$root
+ ventoy_cli_console
+ vt_push_last_entry
+
+ vt_img_extra_initrd_reset
+
+ vt_get_fs_label (vtimghd,1) vtImgHd1Label
+ if [ -d (vtimghd,2)/lib ]; then
+ vt_get_fs_label (vtimghd,2) vtImgHd2Label
+ fi
+
+ if [ -e (vtimghd,1)/etc/hostname ]; then
+ vt_1st_line (vtimghd,1)/etc/hostname vtImgHostname
+ fi
+
+ if [ -e (vtimghd,1)/easy.sfs ]; then
+ ventoy_img_easyos
+ elif [ -e (vtimghd,1)/volumio.initrd ]; then
+ ventoy_img_volumio
+ elif vt_str_begin $vtImgHd1Label "LAKKA"; then
+ ventoy_img_openelec lakka
+ elif vt_str_begin $vtImgHd1Label "LIBREELEC"; then
+ ventoy_img_openelec LibreELEC
+ elif vt_str_begin $vtImgHd1Label "paldo-live"; then
+ ventoy_img_paldo
+ elif vt_str_begin $vtImgHostname "freedombox"; then
+ ventoy_img_freedombox
+ elif vt_str_begin $vtImgHd1Label "BATOCERA"; then
+ ventoy_img_batocera
+ elif [ "$vtImgHd2Label" = "RECALBOX" ]; then
+ ventoy_img_recalbox
+ elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then
+ ventoy_img_ubos
+ elif [ -f (vtimghd,1)/efi/boot/mt86.png ]; then
+ if [ "$grub_platform" = "pc" ]; then
+ img_unsupport_tip
+ else
+ ventoy_img_memtest86
+ fi
+ else
+ if [ "$grub_platform" = "pc" ]; then
+ img_unsupport_tip
+ else
+ vt_linux_chain_data ${vtoy_iso_part}${vt_chosen_path}
+ chainloader ${vtoy_path}/ventoy_x64.efi sector512 env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
+ boot
+ fi
+ fi
+
+ set root=$vtback_root
+ vt_pop_last_entry
+ ventoy_gui_console
+ set ventoy_compatible=NO
+}
+
+function img_unsupport_menuentry {
+ common_unsupport_menuentry
+}