X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/5a7fa0c5654ab475b14dcb88a17f6395bab2108a..4790dedbb19821794c1cf4bfeb671c5be8c19043:/INSTALL/grub/grub.cfg diff --git a/INSTALL/grub/grub.cfg b/INSTALL/grub/grub.cfg index 08eb5d1..346bcbf 100644 --- a/INSTALL/grub/grub.cfg +++ b/INSTALL/grub/grub.cfg @@ -19,7 +19,6 @@ if [ "$grub_platform" = "pc" ]; then insmod setkey insmod regexp - insmod video_fb fi function ventoy_pause { @@ -34,6 +33,21 @@ function ventoy_debug_pause { fi } + +function ventoy_max_resolution { + #Skip this for VirtualBox + smbios -t 1 -s 0x05 --set=system_product; + if vt_str_casebegin "$system_product" "VirtualBox"; then + return + fi + + vt_enum_video_mode + vt_get_video_mode 0 vtCurMode + terminal_output console + set gfxmode=$vtCurMode + terminal_output gfxterm +} + function ventoy_cli_console { if [ -z "$vtoy_display_mode" ]; then terminal_output console @@ -120,13 +134,14 @@ function ventoy_show_help { } function ventoy_load_menu_lang_file { - vt_load_file_to_mem "auto" $vtoy_efi_part/grub/menu.tar.gz vtoy_menu_lang_mem + vt_load_file_to_mem "auto" $prefix/menu.tar.gz vtoy_menu_lang_mem loopback vt_menu_tarfs mem:${vtoy_menu_lang_mem_addr}:size:${vtoy_menu_lang_mem_size} } function get_os_type { set vtoy_os=Linux - + export vtoy_os + if vt_str_begin "$vt_volume_id" "DLC Boot"; then if [ -f (loop)/DLCBoot.exe ]; then set vtoy_os=Windows @@ -401,20 +416,25 @@ function distro_specify_initrd_file_phase2 { vt_linux_specify_initrd_file /boot/full.cz elif [ -f (loop)/images/pxeboot/initrd.img ]; then vt_linux_specify_initrd_file /images/pxeboot/initrd.img - + elif [ -f (loop)/live/initrd ]; then + vt_linux_specify_initrd_file /live/initrd + elif [ -f (loop)/initramfs-linux.img ]; then + vt_linux_specify_initrd_file /initramfs-linux.img + elif [ -f (loop)/boot/isolinux/initrd.gz ]; then + vt_linux_specify_initrd_file /boot/isolinux/initrd.gz fi } + function ventoy_get_ghostbsd_ver { # fallback to parse version from elf /boot/kernel/kernel set vt_freebsd_ver=xx } function ventoy_get_furybsd_ver { - if regexp "13\.[0-9]" "$2"; then - set vt_freebsd_ver=13.x - else - set vt_freebsd_ver=12.x + set vt_freebsd_ver=12.x + if regexp --set 1:vtFuryVer "(14|13)\.[0-9]" "$2"; then + set vt_freebsd_ver=${vtFuryVer}.x fi } @@ -423,12 +443,8 @@ function ventoy_get_freenas_ver { if [ -e (loop)/FreeNAS-MANIFEST ]; then vt_parse_freenas_ver (loop)/FreeNAS-MANIFEST vt_freenas_ver - if regexp "^13\.[0-9]" "$vt_freenas_ver"; then - set vt_freebsd_ver=13.x - elif regexp "^12\.[0-9]" "$vt_freenas_ver"; then - set vt_freebsd_ver=12.x - elif regexp "^11\.[0-9]" "$vt_freenas_ver"; then - set vt_freebsd_ver=11.x + if regexp --set 1:vtNasVer "^(14|13|12|11)\.[0-9]" "$vt_freenas_ver"; then + set vt_freebsd_ver=${vtNasVer}.x fi fi } @@ -438,12 +454,8 @@ function ventoy_get_truenas_ver { if [ -e (loop)/TrueNAS-MANIFEST ]; then vt_parse_freenas_ver (loop)/TrueNAS-MANIFEST vt_truenas_ver - if regexp "^13\.[0-9]" "$vt_truenas_ver"; then - set vt_freebsd_ver=13.x - elif regexp "^12\.[0-9]" "$vt_truenas_ver"; then - set vt_freebsd_ver=12.x - elif regexp "^11\.[0-9]" "$vt_truenas_ver"; then - set vt_freebsd_ver=11.x + if regexp --set 1:vtTNasVer "^(14|13|12|11)\.[0-9]" "$vt_truenas_ver"; then + set vt_freebsd_ver=${vtTNasVer}.x fi fi } @@ -475,49 +487,25 @@ function ventoy_freebsd_proc { ventoy_get_truenas_ver "$1" "${chosen_path}" elif vt_strstr "$vt_volume_id" "FURYBSD"; then ventoy_get_furybsd_ver "$1" "${chosen_path}" - elif regexp "^13_[0-9]" "$vt_volume_id"; then - set vt_freebsd_ver=13.x - elif regexp "^12_[0-9]" "$vt_volume_id"; then - set vt_freebsd_ver=12.x - elif regexp "^11_[0-9]" "$vt_volume_id"; then - set vt_freebsd_ver=11.x - elif regexp "^10_[0-9]" "$vt_volume_id"; then - set vt_freebsd_ver=10.x - elif regexp "^9_[0-9]" "$vt_volume_id"; then - set vt_freebsd_ver=9.x + elif regexp --set 1:vtBsdVerNum "^(14|13|12|11|10|9)_[0-9]" "$vt_volume_id"; then + set vt_freebsd_ver=${vtBsdVerNum}.x elif [ -d (loop)/usr/midnightbsd-dist ]; then ventoy_get_midnightbsd_ver "$1" "${chosen_path}" set vtFreeBsdDistro=MidnightBSD elif [ -e (loop)/bin/freebsd-version ]; then - vt_unix_parse_freebsd_ver (loop)/bin/freebsd-version vt_userland_ver - if regexp "\"13\.[0-9]-" "$vt_userland_ver"; then - set vt_freebsd_ver=13.x - elif regexp "\"12\.[0-9]-" "$vt_userland_ver"; then - set vt_freebsd_ver=12.x - elif regexp "\"11\.[0-9]-" "$vt_userland_ver"; then - set vt_freebsd_ver=11.x - elif regexp "\"10\.[0-9]-" "$vt_userland_ver"; then - set vt_freebsd_ver=10.x - elif regexp "\"9\.[0-9]-" "$vt_userland_ver"; then - set vt_freebsd_ver=9.x - fi + vt_unix_parse_freebsd_ver (loop)/bin/freebsd-version vt_userland_ver + if regexp --set 1:vtBsdVerNum "\"(14|13|12|11|10|9)\.[0-9]-" "$vt_userland_ver"; then + set vt_freebsd_ver=${vtBsdVerNum}.x + fi elif [ -e (loop)/README.TXT ]; then vt_1st_line (loop)/README.TXT vt_freebsd_line1 - if regexp "FreeBSD 13\.[0-9]-" "$vt_freebsd_line1"; then - set vt_freebsd_ver=13.x - elif regexp "FreeBSD 12\.[0-9]-" "$vt_freebsd_line1"; then - set vt_freebsd_ver=12.x - elif regexp "FreeBSD 11\.[0-9]-" "$vt_freebsd_line1"; then - set vt_freebsd_ver=11.x - elif regexp "FreeBSD 10\.[0-9]-" "$vt_freebsd_line1"; then - set vt_freebsd_ver=10.x - elif regexp "FreeBSD 9\.[0-9]-" "$vt_freebsd_line1"; then - set vt_freebsd_ver=9.x + if regexp --set 1:vtBsdVerNum "FreeBSD (14|13|12|11|10|9)\.[0-9]-" "$vt_freebsd_line1"; then + set vt_freebsd_ver=${vtBsdVerNum}.x fi elif vt_strstr "${chosen_path}" "MidnightBSD"; then set vt_freebsd_ver=9.x fi - + if [ -e (loop)/usr/freebsd-dist/cloninst.sh ]; then set vtFreeBsdDistro=ClonOS @@ -541,10 +529,17 @@ function ventoy_freebsd_proc { fi if [ "$vt_freebsd_ver" = "xx" ]; then - set vt_freebsd_ver=13.x + set vt_freebsd_ver=14.x + fi + fi + + if [ "$vt_freebsd_ver" = "14.x" ]; then + if [ -e (loop)/boot/lua/brand-pfSense.lua ]; then + set vtFreeBsdDistro=pfSense fi fi + if [ -n "${vtdebug_flag}" ]; then echo "This is $vtFreeBsdDistro $vt_freebsd_ver ${vt_freebsd_bit}bit" fi @@ -651,7 +646,7 @@ function uefi_windows_menu_func { if [ -n "$vtoy_chain_mem_addr" ]; then ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 - ventoy_cli_console + ventoy_max_resolution 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} boot else @@ -693,7 +688,7 @@ function uefi_linux_menu_func { if [ -d (loop)/pmagic ]; then vt_linux_specify_initrd_file /pmagic/initrd.img else - 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 + 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" "EFI/BOOT/grub/grub.cfg"; do if [ -e (loop)/$file ]; then vt_linux_parse_initrd_grub file (loop)/$file fi @@ -859,6 +854,9 @@ function uefi_linux_menu_func { if [ -f (loop)/boot/isolinux/syslnx64.cfg ]; then syslinux_configfile (loop)/boot/isolinux/syslnx64.cfg set vtback_cfg_find=1 + elif [ -f (loop)/boot/syslinux/porteus.cfg ]; then + syslinux_configfile (loop)/boot/syslinux/porteus.cfg + set vtback_cfg_find=1 fi fi @@ -906,11 +904,6 @@ function ventoy_reset_nojoliet { } function uefi_iso_menu_func { - - if [ -d (loop)/ ]; then - loopback -d loop - fi - if [ -n "$vtisouefi" ]; then set LoadIsoEfiDriver=on unset vtisouefi @@ -924,21 +917,13 @@ function uefi_iso_menu_func { vt_select_auto_install "${chosen_path}" vt_select_persistence "${chosen_path}" - if vt_is_udf "${1}${chosen_path}"; then - set ventoy_fs_probe=udf - else - set ventoy_fs_probe=iso9660 - ventoy_reset_nojoliet - + if ! vt_is_udf "${1}${chosen_path}"; then # Lenovo EasyStartup need an addional sector for boundary check if vt_str_begin "$vt_volume_id" "EasyStartup"; then vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}" vt_append_extra_sector 1 fi fi - - loopback loop "${1}${chosen_path}" - get_os_type (loop) if [ -d (loop)/EFI ]; then set vt_efi_dir=YES @@ -957,15 +942,6 @@ function uefi_iso_menu_func { vt_check_compatible (loop) fi - if vt_need_secondary_menu "$vt_chosen_name"; then - vt_show_secondary_menu "$vt_chosen_path" "$vtoy_os" $vt_chosen_size - if vt_check_mode 0 "$vt_chosen_name"; then - uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path" - vt_secondary_recover_mode - return - fi - fi - vt_img_sector "${1}${chosen_path}" if [ "$ventoy_fs_probe" = "iso9660" ]; then @@ -982,8 +958,7 @@ function uefi_iso_menu_func { uefi_linux_menu_func "$1" "${chosen_path}" fi - ventoy_gui_console - vt_secondary_recover_mode + ventoy_gui_console } function uefi_iso_memdisk { @@ -1333,6 +1308,9 @@ function legacy_linux_menu_func { if [ -f (loop)/boot/isolinux/syslnx64.cfg ]; then syslinux_configfile (loop)/boot/isolinux/syslnx64.cfg set vtback_cfg_find=1 + elif [ -f (loop)/boot/syslinux/porteus.cfg ]; then + syslinux_configfile (loop)/boot/syslinux/porteus.cfg + set vtback_cfg_find=1 fi fi @@ -1368,26 +1346,10 @@ function legacy_unix_menu_func { function legacy_iso_menu_func { - - if [ -d (loop)/ ]; then - loopback -d loop - fi - set chosen_path="$2" vt_select_auto_install "${chosen_path}" vt_select_persistence "${chosen_path}" - - if vt_is_udf "${1}${chosen_path}"; then - set ventoy_fs_probe=udf - else - set ventoy_fs_probe=iso9660 - ventoy_reset_nojoliet - fi - - loopback loop "${1}${chosen_path}" - - get_os_type (loop) if [ -n "$vtcompat" ]; then set ventoy_compatible=YES @@ -1398,15 +1360,6 @@ function legacy_iso_menu_func { vt_check_compatible (loop) fi - if vt_need_secondary_menu "$vt_chosen_name"; then - vt_show_secondary_menu "$vt_chosen_path" "$vtoy_os" $vt_chosen_size - if vt_check_mode 0 "$vt_chosen_name"; then - legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path" - vt_secondary_recover_mode - return - fi - fi - vt_img_sector "${1}${chosen_path}" if [ "$ventoy_fs_probe" = "iso9660" ]; then @@ -1484,6 +1437,8 @@ function ventoy_iso_busybox_ver { set ventoy_busybox_ver=64 elif vt_str_begin "$vt_volume_id" "LDiagBootable"; then set ventoy_busybox_ver=64 + elif vt_str_begin "$vt_volume_id" "KAOS_"; then + set ventoy_busybox_ver=64 fi fi @@ -1515,6 +1470,33 @@ function iso_common_menuentry { if ventoy_vcfg_proc "${vt_chosen_path}"; then return fi + + + + #secondary boot menu + if vt_is_udf "${vtoy_iso_part}${vt_chosen_path}"; then + set ventoy_fs_probe=udf + else + set ventoy_fs_probe=iso9660 + ventoy_reset_nojoliet + fi + + if [ -d (loop)/ ]; then + loopback -d loop + fi + loopback loop "${vtoy_iso_part}${vt_chosen_path}" + + get_os_type (loop) + + ventoy_debug_pause + + if vt_need_secondary_menu "$vt_chosen_name"; then + vt_show_secondary_menu "$vt_chosen_path" "$vtoy_os" $vt_chosen_size + if [ "$VTOY_SECOND_EXIT" = "1" ]; then + return + fi + fi + if vt_str_begin "$vt_volume_id" "Avira"; then vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}" @@ -1566,7 +1548,9 @@ function iso_common_menuentry { else uefi_iso_menu_func $vtoy_iso_part "$vt_chosen_path" fi - fi + fi + + vt_secondary_recover_mode } function miso_common_menuentry { @@ -1933,12 +1917,32 @@ function ventoy_img_volumio { function ventoy_img_openelec { elec_ver=$1 + if [ "$elec_ver" = "LibreELEC" ]; then + if vt_strstr "$vt_chosen_name" "x86_64"; then + set ventoy_busybox_ver=64 + fi + 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 loopback vtloopex $vtoy_efi_part/ventoy/vtloopex.cpio vt_img_extra_initrd_append (vtloopex)/$elec_ver/vtloopex.tar.xz + if [ "$elec_ver" = "LibreELEC" ]; then + if [ -f (vtimghd,1)/system ]; then + loopback elecsfs (vtimghd,1)/system + vt_get_lib_module_ver (elecsfs) /usr/lib/kernel-overlays/base/lib/modules/ vt_module_ver + if [ -n "$vt_module_ver" ]; then + for mod in "kernel/drivers/md/dm-mod.ko"; do + if [ -e (elecsfs)/usr/lib/kernel-overlays/base/lib/modules/$vt_module_ver/$mod ]; then + vt_img_extra_initrd_append (elecsfs)/usr/lib/kernel-overlays/base/lib/modules/$vt_module_ver/$mod + fi + done + fi + fi + fi + ventoy_debug_pause #boot image file @@ -1951,6 +1955,7 @@ function ventoy_img_openelec { vt_img_unhook_root vt_unset_boot_opt loopback -d vtloopex + loopback -d elecsfs } @@ -2229,6 +2234,23 @@ function ventoy_img_cloudready { unset linuxpartB } + +function ventoy_img_fwts { + 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 + + ventoy_debug_pause + + #boot image file + vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=fwts + vt_img_hook_root + + configfile $prefix/distro/fwts.cfg + + vt_img_unhook_root + vt_unset_boot_opt +} + function ventoy_img_memtest86 { chainloader (vtimghd,1)/efi/boot/BOOTX64.efi boot @@ -2294,6 +2316,14 @@ function img_common_menuentry { vt_get_fs_label (vtimghd,2) vtImgHd2Label fi + if [ -z "$vtImgHd1Label" ]; then + if [ -d (vtimghd,2)/efi ]; then + vt_get_fs_label (vtimghd,3) vtImgHd3Label + elif [ -d (vtimghd,12)/efi ]; then + vt_get_fs_label (vtimghd,3) vtImgHd3Label + fi + fi + if [ -e (vtimghd,1)/etc/hostname ]; then vt_1st_line (vtimghd,1)/etc/hostname vtImgHostname fi @@ -2311,6 +2341,8 @@ function img_common_menuentry { elif [ -f (vtimghd,3)/etc/chrome_dev.conf ]; then ventoy_img_cloudready fi + elif vt_str_begin "$vtImgHd3Label" "fwts-result"; then + ventoy_img_fwts elif vt_str_begin "$vtImgHd1Label" "LAKKA"; then ventoy_img_openelec lakka elif vt_str_begin "$vtImgHd1Label" "LIBREELEC"; then @@ -2399,7 +2431,7 @@ function mimg_common_menuentry { ############################################################# ############################################################# -set VENTOY_VERSION="1.0.86" +set VENTOY_VERSION="1.1.05" #ACPI not compatible with Window7/8, so disable by default set VTOY_PARAM_NO_ACPI=1 @@ -2558,9 +2590,18 @@ elif [ "$vtoy_display_mode" = "serial_console" ]; then terminal_input serial console terminal_output serial console else - if [ "$vtoy_res_fit" = "1" ]; then + if [ "$vtoy_gfxmode" = "max" ]; then + set gfxmode=1024x768 terminal_output gfxterm - fi + + vt_enum_video_mode + vt_get_video_mode 0 vtCurMode + terminal_output console + set gfxmode=$vtCurMode + terminal_output gfxterm + elif [ "$vtoy_res_fit" = "1" ]; then + terminal_output gfxterm + fi if [ -n "$vtoy_theme" ]; then vt_set_theme