]> glassweightruler.freedombox.rocks Git - Ventoy.git/blobdiff - INSTALL/grub/grub.cfg
Optimization for booting openwrt
[Ventoy.git] / INSTALL / grub / grub.cfg
index d62b71df239da21fd320518bbd90fa9009243fbe..a44774744d8b8b087568b9d0b032f317f87bbb7d 100644 (file)
@@ -638,6 +638,8 @@ function uefi_linux_menu_func {
                 vt_add_replace_file 0 "EFI\\hyperiso\\hyperiso.img"
             fi
         elif [ -d (loop)/EFI/BOOT/entries ]; then
+            vt_linux_get_main_initrd_index vtindex
+
             if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
                 vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
             elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then
@@ -848,13 +850,14 @@ function vtoy_windows_wimboot_func {
         linux16  "$vtoy_path/$vt_wimkernel"  quiet
         ventoy_debug_pause
 
-        echo Loading files...... (This may take a few minutes, please wait)
+        vt_set_wim_load_prompt 1 "Loading files......"
         initrd16 newc:vtoyjump.exe:$vtoy_path/vtoyjump${vtoy_wimboot_bit}.exe \
              newc:wimboot.data:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size} \
              newc:winpeshl.ini:mem:${vtoy_winpeshl_ini_addr}:size:${vtoy_winpeshl_ini_size} \
              newc:bcd:$vtoy_wimboot_prefix/boot/bcd \
              newc:boot.sdi:$vtoy_wimboot_prefix/boot/boot.sdi \
              newc:boot.wim:$vtoy_wimboot_prefix/sources/boot.wim
+        vt_set_wim_load_prompt 0
         boot
     else
         if [ "$grub_cpu" = "i386" ]; then
@@ -863,8 +866,10 @@ function vtoy_windows_wimboot_func {
             set vt_wimkernel=wimboot.x86_64.xz
         fi
 
-        echo Loading files...... (This may take a few minutes, please wait)
+        vt_set_wim_load_prompt 1 "Loading files......"
         vt_load_file_to_mem "nodecompress" $vtoy_wimboot_prefix/sources/boot.wim vtoy_wimfile_mem
+        vt_set_wim_load_prompt 0
+
         if [ $? -eq 0 ]; then
             set vtoy_wimfile_path=mem:${vtoy_wimfile_mem_addr}:size:${vtoy_wimfile_mem_size}
         else
@@ -1396,7 +1401,7 @@ function vtoyboot_common_func {
                 ventoy_pause
             fi
         fi
-    
+
         vt_img_sector "${1}"
         vt_raw_chain_data "${1}"
 
@@ -1623,14 +1628,25 @@ function ventoy_img_openwrt {
         set ventoy_busybox_ver=64
     fi
 
-    if [ ! -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
-        ventoy_gui_console
-        echo -e "\n ventoy_openwrt.xz not found. Please refer https://www.ventoy.net/en/doc_openwrt.html.\n"
-        echo -e " 未找到 ventoy_openwrt.xz 文件。请参考 https://www.ventoy.net/cn/doc_openwrt.html\n"
-        echo -e "\n press ENTER to exit (请按 回车 键返回) ..."
-        read vtInputKey
-        ventoy_cli_console
-        return
+    vt_fs_enum_1st_dir (vtimghd,2) /lib/modules/ vt_dir_name
+
+    if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko ]; then
+        set openwrt_plugin_need=0
+        vt_img_extra_initrd_append  (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko
+        if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko ]; then
+            vt_img_extra_initrd_append  (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko
+        fi
+    else
+        set openwrt_plugin_need=1
+        if [ ! -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
+            ventoy_gui_console
+            echo -e "\n ventoy_openwrt.xz not found. Please refer https://www.ventoy.net/en/doc_openwrt.html.\n"
+            echo -e " 未找到 ventoy_openwrt.xz 文件。请参考 https://www.ventoy.net/cn/doc_openwrt.html\n"
+            echo -e "\n press ENTER to exit (请按 回车 键返回) ..."
+            read vtInputKey
+            ventoy_cli_console
+            return
+        fi
     fi
 
     if vt_img_check_range "${vtoy_iso_part}${vt_chosen_path}"; then
@@ -1645,12 +1661,14 @@ function ventoy_img_openwrt {
         return
     fi
     
-
     vt_load_cpio  $vtoy_path  "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
     vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
 
-    vt_img_extra_initrd_append  ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz
-    
+    if [ $openwrt_plugin_need -eq 1 ]; then
+        if [ -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
+            vt_img_extra_initrd_append  ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz
+        fi
+    fi
 
     #boot image file
     vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=openwrt
@@ -1692,6 +1710,15 @@ function img_unsupport_tip {
     read vtInputKey 
 }
 
+function legacy_img_memdisk {
+    linux16   $vtoy_path/memdisk
+    echo "Loading img file to memory ..."
+    initrd16  "${1}${2}"
+    
+    ventoy_cli_console
+    boot
+}
+
 function img_common_menuentry {
     set ventoy_compatible=YES
     set ventoy_busybox_ver=32
@@ -1706,6 +1733,13 @@ function img_common_menuentry {
         return
     fi
 
+    if [ "$grub_platform" = "pc" ]; then
+        if vt_check_mode 0; then
+            legacy_img_memdisk $vtoy_iso_part "$vt_chosen_path"
+            return
+        fi
+    fi
+
     if [ -d (vtimghd)/ ]; then
         loopback -d vtimghd
     fi
@@ -1793,7 +1827,7 @@ function img_unsupport_menuentry {
 #############################################################
 #############################################################
 
-set VENTOY_VERSION="1.0.43"
+set VENTOY_VERSION="1.0.46"
 
 #ACPI not compatible with Window7/8, so disable by default
 set VTOY_PARAM_NO_ACPI=1
@@ -1929,7 +1963,7 @@ elif [ "$vtoy_display_mode" = "serial_console" ]; then
     terminal_output  serial console    
 else    
     if [ -n "$vtoy_theme" ]; then
-        set theme=$vtoy_theme
+        vt_set_theme
     else
         set theme=$prefix/themes/ventoy/theme.txt
     fi
@@ -1974,6 +2008,12 @@ export vtoy_efi_part
 export VENTOY_VERSION
 export VTOY_CUR_VIDEO_MODE
 export VTOY_EFI_ARCH
+export VTOY_MEM_DISK_STR
+export VTOY_ISO_RAW_STR
+export VTOY_GRUB2_MODE_STR
+export VTOY_WIMBOOT_MODE_STR
+export VTOY_ISO_UEFI_DRV_STR
+
 
 #special VTOY_DEFAULT_IMAGE process
 if [ -n "$VTOY_DEFAULT_IMAGE" ]; then