From 1931a250b330aa02fe9df141c92feb067264c075 Mon Sep 17 00:00:00 2001 From: vasilito Date: Fri, 3 Jul 2026 10:42:35 +0300 Subject: [PATCH] =?UTF-8?q?GRUB=202.12=20port=20=E2=80=94=20Ventoy=20compa?= =?UTF-8?q?t=20layer,=20EFI=20kernel,=20install/update=20targets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build system: - Switch from GRUB 2.04 → 2.12 with Ventoy module via build_grub2_212.sh - New patch_ventoy_212.py: compat typedefs, mem: protocol, VTOY_CMD_CHECK bypass - Fix EFI libstub compile with GCC 16 (cflags -std=gnu11 on X86_64) - Disable busybox CONFIG_TC (broken with modern kernel headers) - New Makefile targets: install, update, rebuild (single-command USB deploy) GRUB 2.12 compat fixes: - Add grub_mem_fs with fs_read/fs_close to kern/file.c (mem: protocol) - Bypass ventoy_check_official_device (hiperiso lacks ventoy.cpio on ESP) - Disable VTOY_CMD_CHECK anti-tamper (ESP size != 33554432) Kernel (hiperiso_defconfig): - Enable CONFIG_EFI, CONFIG_EFI_STUB, CONFIG_FB_EFI (fixes black screen boot) - Add CONFIG_FONT_SUPPORT, CONFIG_FONT_8x16 grub.cfg: - Theme path: try themes/hiperiso/ then themes/ventoy/ (path mismatch fix) - Kernel cmdline: add console=tty0 console=ttyS0 ignore_loglevel earlyprintk=efi - Restore ventoy_* function names (matching modsrc binary) --- Makefile | 45 +- host/kernel/hiperiso_defconfig | 7 +- scripts/build_all.sh | 17 +- scripts/build_grub2_204.sh | 26 +- scripts/build_grub2_212.sh | 118 +++ scripts/package_release.sh | 16 +- scripts/patch_ventoy_212.py | 531 ++++++++++++ src/grub2/grub/grub.cfg | 1387 +++++++++++++++----------------- 8 files changed, 1381 insertions(+), 766 deletions(-) create mode 100755 scripts/build_grub2_212.sh create mode 100644 scripts/patch_ventoy_212.py diff --git a/Makefile b/Makefile index a56c2b0..c8def67 100644 --- a/Makefile +++ b/Makefile @@ -4,14 +4,14 @@ STAGING := $(CURDIR)/$(BUILD_DIR)/staging PAYLOAD := $(CURDIR)/$(BUILD_DIR)/payload SCRIPTS := scripts -.PHONY: all grub2 kernel qemu ovmf busybox initramfs hiperiso-log gui package dist clean distclean help +.PHONY: all grub2 kernel qemu ovmf busybox initramfs hiperiso-log gui package payload dist install update rebuild clean distclean help help: @echo "hiperiso build system" @echo "" @echo "Targets:" @echo " all Build everything (staging artifacts)" - @echo " grub2 Build GRUB2 2.04 with hiperiso module" + @echo " grub2 Build GRUB2 2.12 with Ventoy module" @echo " kernel Build host kernel (KVM built-in)" @echo " qemu Build stripped QEMU system-x86_64" @echo " ovmf Acquire OVMF UEFI firmware" @@ -19,8 +19,12 @@ help: @echo " initramfs Pack initramfs.cpio.gz" @echo " hiperiso-log Build log analysis tool" @echo " gui Build all GUI/web tools (Qt5, GTK3, WebUI, Plugson)" - @echo " package Assemble release payload + ESP disk image (depends on gui)" + @echo " package Build all artifacts and assemble release payload" + @echo " payload Alias for 'package'" @echo " dist Alias for 'package'" + @echo " install Build payload and install to USB=/dev/sdX (destructive)" + @echo " update Build payload and update existing USB=/dev/sdX (keeps ISOs)" + @echo " rebuild clean + all + package (no USB — add USB=/dev/sdX to install)" @echo " download Download source tarballs" @echo " clean Remove build/" @echo " distclean Remove build/ + payload/" @@ -31,13 +35,15 @@ all: kernel qemu ovmf grub2 busybox initramfs hiperiso-log dist: package +payload: package + download: @echo "=== Downloading sources ===" sh $(SCRIPTS)/download_sources.sh $(BUILD_DIR) grub2: - @echo "=== Building GRUB2 2.04 with hiperiso module ===" - sh $(SCRIPTS)/build_grub2_204.sh + @echo "=== Building GRUB2 2.12 with Ventoy module ===" + sh $(SCRIPTS)/build_grub2_212.sh gui: @echo "=== Building all GUI/web tools ===" @@ -48,9 +54,10 @@ kernel: cd $(BUILD_DIR)/linux && \ cp ../../host/kernel/hiperiso_defconfig .config && \ make olddefconfig && \ + sed -i 's/^cflags-\$$(CONFIG_X86_64)[[:space:]]*:= -mcmodel=small/cflags-\$$(CONFIG_X86_64) := -mcmodel=small -std=gnu11/' drivers/firmware/efi/libstub/Makefile && \ make -j$$(nproc) bzImage && \ - mkdir -p $(STAGING)/efi && \ - cp arch/x86/boot/bzImage $(STAGING)/efi/vmlinuz + mkdir -p $(STAGING) && \ + cp arch/x86/boot/bzImage $(STAGING)/vmlinuz qemu: @echo "=== Building QEMU ===" @@ -76,6 +83,7 @@ busybox: cd $(BUILD_DIR)/busybox && \ make defconfig && \ sed -i 's/# CONFIG_STATIC is not set/CONFIG_STATIC=y/' .config && \ + sed -i 's/^CONFIG_TC=y/# CONFIG_TC is not set/' .config && \ yes "" | make oldconfig >/dev/null 2>&1 && \ make -j$$(nproc) && \ cp busybox $(STAGING)/busybox @@ -89,10 +97,31 @@ hiperiso-log: cd logging/hiperiso-log && make && \ cp hiperiso-log $(STAGING)/hiperiso-log -package: gui +package: all gui @echo "=== Assembling release payload + ESP disk image ===" sh $(SCRIPTS)/package_release.sh +install: package + @if [ -z "$(USB)" ]; then echo "Usage: make install USB=/dev/sdX"; exit 1; fi + @echo "=== Installing Hiperiso to $(USB) ===" + @if [ "$$(id -u)" -eq 0 ]; then \ + bash $(PAYLOAD)/Hiperiso2Disk.sh -I -g $(USB); \ + else \ + sudo bash $(PAYLOAD)/Hiperiso2Disk.sh -I -g $(USB); \ + fi + +update: package + @if [ -z "$(USB)" ]; then echo "Usage: make update USB=/dev/sdX"; exit 1; fi + @echo "=== Updating Hiperiso on $(USB) ===" + @if [ "$$(id -u)" -eq 0 ]; then \ + bash $(PAYLOAD)/Hiperiso2Disk.sh -u $(USB); \ + else \ + sudo bash $(PAYLOAD)/Hiperiso2Disk.sh -u $(USB); \ + fi + +rebuild: clean package + @echo "=== Rebuild complete. Run: sudo make install USB=/dev/sdX ===" + clean: rm -rf $(BUILD_DIR) diff --git a/host/kernel/hiperiso_defconfig b/host/kernel/hiperiso_defconfig index fe6be15..3b8ff01 100644 --- a/host/kernel/hiperiso_defconfig +++ b/host/kernel/hiperiso_defconfig @@ -172,8 +172,11 @@ CONFIG_PRINTK_TIME=y CONFIG_EARLY_PRINTK=y CONFIG_DEBUG_INFO_NONE=y -# CONFIG_EFI is not set -# CONFIG_EFI_STUB is not set +CONFIG_EFI=y +CONFIG_EFI_STUB=y +CONFIG_FB_EFI=y +CONFIG_FONT_SUPPORT=y +CONFIG_FONT_8x16=y # ── Kernel features / syscalls (busybox + glibc needs) ────────────────────── CONFIG_MULTIUSER=y diff --git a/scripts/build_all.sh b/scripts/build_all.sh index d8ace91..3d2f679 100755 --- a/scripts/build_all.sh +++ b/scripts/build_all.sh @@ -45,10 +45,11 @@ step 2 10 "Building host kernel (KVM built-in)" cp "$REPO_ROOT/host/kernel/hiperiso_defconfig" .config make olddefconfig sed -i 's/^KBUILD_CFLAGS := -m\$(BITS) -O2/KBUILD_CFLAGS := -m$(BITS) -O2 -std=gnu11/' arch/x86/boot/compressed/Makefile + sed -i 's/^cflags-\$(CONFIG_X86_64)[[:space:]]*:= -mcmodel=small/cflags-\$(CONFIG_X86_64) := -mcmodel=small -std=gnu11/' drivers/firmware/efi/libstub/Makefile make -j"$JOBS" bzImage - cp arch/x86/boot/bzImage "$STAGING/efi/vmlinuz" + cp arch/x86/boot/bzImage "$STAGING/vmlinuz" ) -echo " [ok] $(du -h "$STAGING/efi/vmlinuz" | cut -f1) vmlinuz" +echo " [ok] $(du -h "$STAGING/vmlinuz" | cut -f1) vmlinuz" # ── 3. Build QEMU ─────────────────────────────────────────────────────────── step 3 10 "Building stripped QEMU" @@ -84,16 +85,16 @@ else exit 1 fi -# ── 5. Build GRUB2 (with full hiperiso module) ────────────────────────────── -step 5 10 "Building GRUB2 with hiperiso module" -if [ -f "$SCRIPT_DIR/build_grub2_204.sh" ]; then - bash "$SCRIPT_DIR/build_grub2_204.sh" +# ── 5. Build GRUB2 (with Ventoy module on GRUB 2.12) ──────────────────────── +step 5 10 "Building GRUB2 2.12 with Ventoy module" +if [ -f "$SCRIPT_DIR/build_grub2_212.sh" ]; then + bash "$SCRIPT_DIR/build_grub2_212.sh" cp "$REPO_ROOT/grub2/bin/BOOTX64.EFI" "$STAGING/efi/BOOTX64.EFI" [ -f "$REPO_ROOT/grub2/bin/grubx64_real.efi" ] && cp "$REPO_ROOT/grub2/bin/grubx64_real.efi" "$STAGING/efi/grubx64_real.efi" [ -f "$REPO_ROOT/grub2/bin/grubx64.efi" ] && cp "$REPO_ROOT/grub2/bin/grubx64.efi" "$STAGING/efi/grubx64.efi" echo " [ok] $(du -h "$STAGING/efi/BOOTX64.EFI" | cut -f1) BOOTX64.EFI" else - echo "ERROR: GRUB2 build script not found ($SCRIPT_DIR/build_grub2_204.sh)" + echo "ERROR: GRUB2 build script not found ($SCRIPT_DIR/build_grub2_212.sh)" exit 1 fi @@ -103,8 +104,8 @@ step 6 10 "Building busybox (static)" cd "$BUILD_DIR/busybox" yes "" | make defconfig >/dev/null 2>&1 || [ $? -eq 141 ] sed -i 's/# CONFIG_STATIC is not set/CONFIG_STATIC=y/' .config + sed -i 's/^CONFIG_TC=y/# CONFIG_TC is not set/' .config yes "" | make oldconfig >/dev/null 2>&1 || [ $? -eq 141 ] - sed -i 's/^CONFIG_TC=.*/# CONFIG_TC is not set/' .config make -j"$JOBS" cp busybox "$STAGING/busybox" ) diff --git a/scripts/build_grub2_204.sh b/scripts/build_grub2_204.sh index 90b967e..1fcc27d 100644 --- a/scripts/build_grub2_204.sh +++ b/scripts/build_grub2_204.sh @@ -48,7 +48,31 @@ find "$BUILD_DIR/SRC/grub-2.04/grub-core/ventoy" -type f \ -e 's| Ventoy scanning files| Hiperiso scanning files|g' \ -e 's|Ventoy Secure Policy|Hiperiso Secure Policy|g' \ -e 's|grub_printf("ventoy not ready|grub_printf("hiperiso not ready|g' \ - {} + + {} + + +# Patch kern/efi/mm.c: use fixed 32MB heap (matching GRUB 2.12) to fix +# "alloc magic is broken" heap corruption in QEMU/OVMF. +python3 - "$SRC_DIR/grub-core/kern/efi/mm.c" << 'PATCH_MM' +import re, sys +path = sys.argv[1] +with open(path) as f: + c = f.read() +c = re.sub( + r'/\* By default.*?g_new_required_pages = required_pages;', + '/* Fixed 32MB heap (matching GRUB 2.12) to avoid OVMF heap corruption */\n' + ' total_pages = get_total_pages (filtered_memory_map, desc_size,\n' + '\t\t\t\t filtered_memory_map_end);\n' + ' required_pages = BYTES_TO_PAGES (0x2000000);\n' + ' g_org_required_pages = required_pages;\n' + ' g_total_pages = total_pages;\n' + ' g_new_required_pages = required_pages;', + c, flags=re.DOTALL) +c = c.replace( + 'grub_free (finish_mmap_buf);\n grub_printf', + 'grub_free (finish_mmap_buf);\n finish_mmap_buf = NULL;\n grub_printf') +with open(path, 'w') as f: + f.write(c) +PATCH_MM cp "$HIPERISO_ROOT/src/grub2/grub/grub.cfg" "$SRC_DIR/" diff --git a/scripts/build_grub2_212.sh b/scripts/build_grub2_212.sh new file mode 100755 index 0000000..83debd2 --- /dev/null +++ b/scripts/build_grub2_212.sh @@ -0,0 +1,118 @@ +#!/bin/sh +# build_grub2_212.sh — Build GRUB2 2.12 with Ventoy module for hiperiso. +# +# GRUB 2.12 has the "alloc magic is broken" heap corruption fix built-in. +# The Ventoy module is compiled against stock GRUB 2.12 using a compat layer +# (ventoy_def.h additions + ventoy_compat.c) that provides: +# - Typedefs for renamed types (grub_efi_guid_t → grub_guid_t) +# - Missing struct fields (vlnk, dirhook size, gpt_attrib) +# - Working EFI allocation functions (iso_buf, chain_buf) +# - Stubs for patched-core functions (fs chunks, blocklist, vlnk) +# - 3-arg grub_efi_get_variable wrapper (2.12 changed to 4-arg) +# +# Menu display, ISO enumeration, and linux/initrd (hypervisor mode) all work. +# ISO chainloading requires the stubbed fs/*.c functions — not yet ported. +# +# Usage: scripts/build_grub2_212.sh +# Output: grub2/bin/BOOTX64.EFI, grub2/bin/grubx64_real.efi, grub2/bin/grubx64.efi +set -eu +(set -o pipefail) 2>/dev/null && set -o pipefail + +HIPERISO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" +DL_DIR="$HIPERISO_ROOT/build/downloads" +MODULE_TARBALL="$HIPERISO_ROOT/vendor/grub2-modsrc.tar.xz" +BUILD_DIR="$HIPERISO_ROOT/build/grub2-212" +SRC_DIR="$BUILD_DIR/SRC/grub-2.12" + +rm -rf "$BUILD_DIR" +mkdir -p "$BUILD_DIR/SRC" + +if [ ! -f "$DL_DIR/grub-2.12.tar.xz" ]; then + echo ">>> Downloading GRUB 2.12..." + mkdir -p "$DL_DIR" + wget -O "$DL_DIR/grub-2.12.tar.xz" \ + "https://ftp.gnu.org/gnu/grub/grub-2.12.tar.xz" +fi + +echo ">>> Extracting GRUB 2.12..." +tar -xf "$DL_DIR/grub-2.12.tar.xz" -C "$BUILD_DIR/SRC/" + +echo ">>> Copying Ventoy source files..." +mkdir -p "$SRC_DIR/grub-core/ventoy" +tar -xf "$MODULE_TARBALL" -C "$BUILD_DIR/SRC/" + +# Copy ventoy source files from modsrc (2.04) into 2.12 tree +cp "$BUILD_DIR/SRC/grub-2.04/grub-core/ventoy/"*.c "$SRC_DIR/grub-core/ventoy/" 2>/dev/null || true +cp "$BUILD_DIR/SRC/grub-2.04/grub-core/ventoy/"*.h "$SRC_DIR/grub-core/ventoy/" 2>/dev/null || true +cp "$BUILD_DIR/SRC/grub-2.04/include/grub/ventoy.h" "$SRC_DIR/include/grub/" 2>/dev/null || true + +# Apply hiperiso branding +find "$SRC_DIR/grub-core/ventoy" -type f \ + \( -name '*.c' -o -name '*.h' \) -exec sed -i \ + -e 's|(partition->len != 131072)|(partition->len != 65536)|g' \ + -e 's|https://www\.ventoy\.net|https://redbearos.org/hiperiso|g' \ + -e 's|www\.ventoy\.net|redbearos.org|g' \ + -e 's|admin@ventoy\.net|adminpupkin@gmail.com|g' \ + -e 's|longpanda|vasilito|g' \ + -e 's|to use Ventoy|to use Hiperiso|g' \ + -e 's|Ventoy grub is not launched by Ventoy shim|Hiperiso grub is not launched by Hiperiso shim|g' \ + -e 's|standard Ventoy device|standard Hiperiso device|g' \ + -e 's| Ventoy scanning files| Hiperiso scanning files|g' \ + -e 's|Ventoy Secure Policy|Hiperiso Secure Policy|g' \ + -e 's|grub_printf("ventoy not ready|grub_printf("hiperiso not ready|g' \ + {} + + +echo ">>> Applying Ventoy compatibility patches..." +python3 "$HIPERISO_ROOT/scripts/patch_ventoy_212.py" "$SRC_DIR" + +echo ">>> Copying grub.cfg..." +cp "$HIPERISO_ROOT/src/grub2/grub/grub.cfg" "$SRC_DIR/grub-core/ventoy/grub.cfg" + +echo ">>> Building GRUB 2.12..." +cd "$SRC_DIR" +./autogen.sh +./configure --with-platform=efi --target=x86_64 \ + --prefix="$BUILD_DIR/INSTALL/" --disable-werror \ + CFLAGS="-std=gnu99 -Wno-error" HOST_CFLAGS="-std=gnu99 -Wno-error" +touch grub-core/extra_deps.lst +make -j"$(nproc)" + +INSTALL_DIR="$BUILD_DIR/INSTALL" +GRUB_LIB="$SRC_DIR/grub-core" +EFI_OUTPUT_DIR="$HIPERISO_ROOT/grub2/bin" +EFI_OUTPUT="$EFI_OUTPUT_DIR/BOOTX64.EFI" +REAL_GRUB_OUTPUT="$EFI_OUTPUT_DIR/grubx64_real.efi" +GRUB_ALIAS_OUTPUT="$EFI_OUTPUT_DIR/grubx64.efi" +mkdir -p "$EFI_OUTPUT_DIR" + +echo ">>> Building BOOTX64.EFI with Ventoy module..." + +NET_MODULES="efinet net tftp http" +MODULES="file blocklist ventoy test true regexp newc search \ +at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio \ +ext2 xfs read halt sleep serial terminfo png password_pbkdf2 \ +gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback \ +part_apple minicmd diskfilter linux relocator jpeg iso9660 udf \ +hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale \ +gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo \ +configfile normal terminal gettext chain priority_queue bufio \ +datetime cat extcmd crypto boot all_video efi_gop efi_uga \ +video_bochs video_cirrus video video_fb gfxterm_background \ +gfxterm_menu smbios zfs" +ALL_MODULES="$NET_MODULES $MODULES" + +PATH="$SRC_DIR:$PATH" \ +"$SRC_DIR/grub-mkimage" \ + --directory "$GRUB_LIB" \ + --prefix '(,2)/grub' \ + --output "$EFI_OUTPUT" \ + --format 'x86_64-efi' \ + --compression 'auto' \ + $ALL_MODULES + +cp "$EFI_OUTPUT" "$REAL_GRUB_OUTPUT" +cp "$EFI_OUTPUT" "$GRUB_ALIAS_OUTPUT" + +echo ">>> Built: $EFI_OUTPUT ($(du -h "$EFI_OUTPUT" | cut -f1))" +echo ">>> GRUB version: 2.12 (Ventoy compat layer)" +echo ">>> Ventoy module: $(strings "$EFI_OUTPUT" | grep -c 'ventoy_') ventoy_* symbols" diff --git a/scripts/package_release.sh b/scripts/package_release.sh index caebb32..c0e4c84 100755 --- a/scripts/package_release.sh +++ b/scripts/package_release.sh @@ -178,21 +178,7 @@ if [ -f "$ESP_STAGING/grub/grub.cfg" ]; then -e 's/HLNK/VLNK/g' \ "$ESP_STAGING/grub/grub.cfg" - # Source uses 'hiso_*' rebrand names; the modsrc binary reads - # 'vtoy_*' (Ventoy original) for env vars. Mirror the partition - # and chain variables so modsrc can find the ISO, the chain data - # buffer, and the payload directory. - # - # Only the bare $var form needs mirroring. The {hiso_X} brace form - # is intentionally NOT mirrored because the modsrc's C functions - # (vt_load_file_to_mem, etc.) set env vars using the rebranded - # name (e.g. hiso_font_mem_addr), and downstream code reads them - # back with the same rebranded brace form. Mirroring the brace - # form would break the round-trip and produce the classic - # "error: invalid font" symptom at boot. - sed -i \ - -e 's/\$hiso_/\$vtoy_/g' \ - "$ESP_STAGING/grub/grub.cfg" + fi # Copy chain-boot EFI binaries + helpers to the ESP at /hiperiso/ # (grub.cfg looks for them at \$hiso_path which is the data partition; diff --git a/scripts/patch_ventoy_212.py b/scripts/patch_ventoy_212.py new file mode 100644 index 0000000..5ec6c69 --- /dev/null +++ b/scripts/patch_ventoy_212.py @@ -0,0 +1,531 @@ +#!/usr/bin/env python3 +""" +Patch GRUB 2.12 source tree to compile the Ventoy module. +Fixes all 60 compilation errors by: +1. Adding missing struct fields to GRUB headers +2. Adding compat typedefs/macros/globals to ventoy_def.h +3. Providing working implementations for EFI allocation functions +4. Providing stubs for functions that need patched core files +5. Fixing grub_strtoul signature change +""" +import os, sys + +SRC = sys.argv[1] if len(sys.argv) > 1 else "/mnt/data/Builds/hiperiso/build/grub2-212/SRC/grub-2.12" + +def patch_file(path, old, new, must_match=True): + full = os.path.join(SRC, path) + with open(full) as f: + c = f.read() + if old not in c: + if must_match: + print(f"ERROR: pattern not found in {path}") + sys.exit(1) + else: + print(f"SKIP: pattern not found in {path}") + return + c = c.replace(old, new, 1) + with open(full, 'w') as f: + f.write(c) + print(f"PATCHED: {path}") + +# ============================================================ +# 1. Patch GRUB 2.12 headers: add missing struct fields +# ============================================================ + +# file.h: add int vlnk to struct grub_file +patch_file("include/grub/file.h", + " /* If file is not easily seekable. Should be set by underlying layer. */\n int not_easily_seekable;", + " /* If file is not easily seekable. Should be set by underlying layer. */\n int not_easily_seekable;\n\n /* Ventoy vlnk flag. */\n int vlnk;") + +# fs.h: add grub_uint64_t size to grub_dirhook_info +patch_file("include/grub/fs.h", + " grub_int64_t mtime;\n grub_uint64_t inode;\n};", + " grub_int64_t mtime;\n grub_uint64_t inode;\n grub_uint64_t size;\n};") + +# partition.h: add grub_uint64_t gpt_attrib to struct grub_partition +patch_file("include/grub/partition.h", + " grub_uint8_t msdostype;\n};", + " grub_uint8_t msdostype;\n\n /* Ventoy: GPT attribute field for priority detection. */\n grub_uint64_t gpt_attrib;\n};") + +# ============================================================ +# 2. Fix grub_strtoul call in ventoy_json.c +# ============================================================ +patch_file("grub-core/ventoy/ventoy_json.c", + "Value = grub_strtoul(pcData, (char **)ppcEnd, 10);", + "Value = grub_strtoul(pcData, (const char ** const)ppcEnd, 10);") + +# ============================================================ +# 2b. Patch kern/file.c: add mem: protocol support +# ============================================================ +file_c_path = os.path.join(SRC, "grub-core/kern/file.c") +with open(file_c_path) as f: + fc = f.read() + +memfile_func = """ +static grub_ssize_t +grub_memfile_read (grub_file_t file, char *buf, grub_size_t len) +{ + grub_size_t avail = file->size - file->offset; + if (len > avail) + len = avail; + if (len == 0) + return 0; + grub_memcpy (buf, (const char *) file->data + file->offset, len); + return (grub_ssize_t) len; +} + +static grub_err_t +grub_memfile_close (grub_file_t file) +{ + return GRUB_ERR_NONE; +} + +static struct grub_fs grub_mem_fs = +{ + .name = "mem", + .fs_read = grub_memfile_read, + .fs_close = grub_memfile_close, +}; + +static grub_file_t +grub_memfile_open (const char *name) +{ + grub_file_t file; + const char *size_str; + + file = (grub_file_t) grub_zalloc (sizeof (*file)); + if (!file) + return 0; + + file->name = grub_strdup (name); + file->data = (void *) grub_strtoul (name + 4, NULL, 0); + file->fs = &grub_mem_fs; + + size_str = grub_strstr (name, "size:"); + if (size_str) + file->size = (grub_off_t) grub_strtoul (size_str + 5, NULL, 0); + + grub_errno = GRUB_ERR_NONE; + return file; +} +""" +fc = fc.replace( + "void (*EXPORT_VAR (grub_grubnet_fini)) (void);\n", + "void (*EXPORT_VAR (grub_grubnet_fini)) (void);\n" + memfile_func, 1) + +fc = fc.replace( + " grub_file_filter_id_t filter;\n\n /* Reset grub_errno", + " grub_file_filter_id_t filter;\n\n if (grub_strncmp (name, \"mem:\", 4) == 0)\n return grub_memfile_open (name);\n\n /* Reset grub_errno", 1) + +with open(file_c_path, 'w') as f: + f.write(fc) +print("PATCHED: grub-core/kern/file.c (mem: protocol)") + +# ============================================================ +# 2c. Patch font/font.c: add mem: to direct open path +# ============================================================ +patch_file("grub-core/font/font.c", + 'if (filename[0] == \'(\' || filename[0] == \'/\' || filename[0] == \'+\')\n file = grub_buffile_open (filename, GRUB_FILE_TYPE_FONT, 1024);', + 'if (filename[0] == \'(\' || filename[0] == \'/\' || filename[0] == \'+\'\n || grub_strncmp (filename, "mem:", 4) == 0)\n file = grub_buffile_open (filename, GRUB_FILE_TYPE_FONT, 1024);') + +# ============================================================ +# 3. Add missing includes to ventoy_def.h + append compat block +# ============================================================ +ventoy_def_path = os.path.join(SRC, "grub-core/ventoy/ventoy_def.h") +with open(ventoy_def_path) as f: + vd = f.read() + +# ventoy_def.h has zero includes — relies on caller. +# Add them directly so all types resolve from any .c file. +include_anchor = "#define __VENTOY_DEF_H__\n" +if include_anchor in vd: + vd = vd.replace(include_anchor, + include_anchor + "\n#include \n#include \n#include \n", 1) + print("PATCHED: grub-core/ventoy/ventoy_def.h (includes added)") +else: + print("SKIP: ventoy_def.h include anchor not found") + +COMPAT_BLOCK = """ +/* ===== GRUB 2.12 compatibility layer for Ventoy module ===== */ + +/* Type: grub_efi_guid_t was renamed to grub_guid_t in GRUB 2.12 */ +typedef grub_guid_t grub_efi_guid_t; + +/* SB policy globals (from modsrc include/grub/env.h) */ +#define VTOY_SB_POLICY_BYPASS 0 +#define VTOY_SB_POLICY_CHECK 1 +extern grub_uint8_t g_sys_sb; +extern grub_uint8_t g_sb_policy; + +/* File type macro */ +#define GRUB_FILE_TYPE_NO_VLNK GRUB_FILE_TYPE_NONE + +/* Missing function declarations (from modsrc core patches) */ +int ventoy_check_file_exist(const char *fmt, ...); +int grub_file_is_vlnk_suffix(const char *name, int len); +int grub_file_add_vlnk(const char *src, const char *dst); +int grub_file_vtoy_vlnk(const char *src, const char *dst); +const char *grub_file_get_vlnk(const char *name, int *vlnk); +grub_fs_t grub_fs_list_probe(grub_device_t device, const char **list); +void *grub_efi_allocate_iso_buf(grub_uint64_t size); +void *grub_efi_allocate_chain_buf(grub_uint64_t size); +void grub_efi_get_reserved_page_num(grub_uint64_t *total, grub_uint64_t *org_required, grub_uint64_t *new_required); +void ventoy_env_hook_root(int hook); +grub_err_t grub_register_vtoy_menu_lang_hook(grub_env_read_hook_t read_hook); +grub_err_t grub_disk_blocklist_read(void *chunklist, grub_uint64_t sector, grub_uint64_t size, grub_uint32_t log_sector_size); + +/* grub_efi_get_variable compat: 2.12 changed to 4-arg returning status. + Provide 3-arg wrapper returning void* (matching 2.04 API). */ +#define grub_efi_get_variable ventoy_efi_get_variable_compat +void *ventoy_efi_get_variable_compat(const char *var, const grub_guid_t *guid, grub_size_t *size); + +/* ===== End compatibility layer ===== */ +""" + +# Insert before the final #endif +endif_line = vd.rfind('#endif') +if endif_line < 0: + print("ERROR: could not find #endif in ventoy_def.h") + sys.exit(1) +vd = vd[:endif_line] + COMPAT_BLOCK + "\n" + vd[endif_line:] +with open(ventoy_def_path, 'w') as f: + f.write(vd) +print("PATCHED: grub-core/ventoy/ventoy_def.h (compat block appended)") + +# Disable Ventoy anti-tamper check (VTOY_CMD_CHECK calls grub_exit() +# when ESP partition isn't exactly 33554432 bytes — hiperiso layout +# may differ. Neutralize it. +VTOY_CHECK_OLD = "#define VTOY_CMD_CHECK(a) if (33554432 != g_ventoy_disk_part_size[a]) ventoy_syscall0(exit)" +VTOY_CHECK_NEW = "#define VTOY_CMD_CHECK(a) /* disabled for hiperiso */" +if VTOY_CHECK_OLD in vd: + vd = vd.replace(VTOY_CHECK_OLD, VTOY_CHECK_NEW, 1) + print("PATCHED: ventoy_def.h (VTOY_CMD_CHECK disabled)") +else: + print("SKIP: VTOY_CMD_CHECK anchor not found (may already be patched)") +with open(ventoy_def_path, 'w') as f: + f.write(vd) + +# Bypass ventoy_check_official_device — it requires ventoy/ventoy.cpio +# on the ESP which hiperiso doesn't ship. Insert return 0 after the +# "cpio open failed" error path. +ventoy_c_path = os.path.join(SRC, "grub-core/ventoy/ventoy_cmd.c") +with open(ventoy_c_path) as f: + vc = f.read() +cpio_marker = 'return ventoy_set_check_result(3 | 0x1000, "File ventoy/ventoy.cpio open failed in VTOYEFI partition");' +cpio_replace = 'return ventoy_set_check_result(3 | 0x1000, "File ventoy/ventoy.cpio open failed in VTOYEFI partition");\n\n\t(void)file;\n\t(void)dev2;\n\t(void)devname;\n\t/* Hiperiso: official device check skipped */\n\treturn 0;' +if cpio_marker in vc: + vc = vc.replace(cpio_marker, cpio_replace, 1) + print("PATCHED: ventoy_cmd.c (official device check bypassed)") +else: + print("SKIP: official device check marker not found") +with open(ventoy_c_path, 'w') as f: + f.write(vc) + +# ============================================================ +# 3b. Add ventoy module to Makefile.core.def +# ============================================================ +mkdef_path = os.path.join(SRC, "grub-core/Makefile.core.def") +with open(mkdef_path) as f: + mkdef = f.read() +if "name = ventoy;" not in mkdef: + ventoy_module = """ +module = { + name = ventoy; + common = ventoy/ventoy.c; + common = ventoy/ventoy_cmd.c; + common = ventoy/ventoy_linux.c; + common = ventoy/ventoy_unix.c; + common = ventoy/ventoy_windows.c; + common = ventoy/ventoy_vhd.c; + common = ventoy/ventoy_plugin.c; + common = ventoy/ventoy_json.c; + common = ventoy/ventoy_browser.c; + common = ventoy/lzx.c; + common = ventoy/xpress.c; + common = ventoy/huffman.c; + common = ventoy/miniz.c; + common = ventoy/ventoy_compat.c; +}; +""" + mkdef += ventoy_module + with open(mkdef_path, 'w') as f: + f.write(mkdef) + print("PATCHED: grub-core/Makefile.core.def (ventoy module added)") +else: + print("SKIP: ventoy module already in Makefile.core.def") + +# ============================================================ +# 4. Rewrite ventoy_compat.c with all implementations +# ============================================================ +compat_c_path = os.path.join(SRC, "grub-core/ventoy/ventoy_compat.c") +COMPAT_C = r"""/* ventoy_compat.c - Compatibility layer for Ventoy module on GRUB 2.12. + * + * Provides implementations for functions that exist in the Ventoy-patched + * GRUB 2.04 modsrc but not in stock GRUB 2.12. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ventoy_def.h" + +/* Define globals (declared extern in ventoy_def.h) */ +grub_uint8_t g_sys_sb = 0; +grub_uint8_t g_sb_policy = 0; + +/* ---- EFI allocation functions (real implementations) ---- */ + +void * +grub_efi_allocate_iso_buf (grub_uint64_t size) +{ + grub_efi_boot_services_t *b; + grub_efi_physical_address_t address = 0; + grub_efi_uintn_t pages; + + pages = (size + 4095) >> 12; /* GRUB_EFI_BYTES_TO_PAGES */ + b = grub_efi_system_table->boot_services; + if (b->allocate_pages (GRUB_EFI_ALLOCATE_ANY_PAGES, + GRUB_EFI_RUNTIME_SERVICES_DATA, + pages, &address) != GRUB_EFI_SUCCESS) + return NULL; + return (void *) (grub_addr_t) address; +} + +void * +grub_efi_allocate_chain_buf (grub_uint64_t size) +{ + grub_efi_boot_services_t *b; + grub_efi_physical_address_t address = 0; + grub_efi_uintn_t pages; + + pages = (size + 4095) >> 12; + b = grub_efi_system_table->boot_services; + if (b->allocate_pages (GRUB_EFI_ALLOCATE_ANY_PAGES, + GRUB_EFI_LOADER_DATA, + pages, &address) != GRUB_EFI_SUCCESS) + return NULL; + return (void *) (grub_addr_t) address; +} + +void +grub_efi_get_reserved_page_num (grub_uint64_t * total, + grub_uint64_t * org_required, + grub_uint64_t * new_required) +{ + if (total) + *total = 0; + if (org_required) + *org_required = 0; + if (new_required) + *new_required = 0; +} + +/* ---- grub_efi_get_variable 3-arg compat wrapper ---- */ +/* Undefine the macro from ventoy_def.h so we can call the real 2.12 function */ +#undef grub_efi_get_variable + +void * +ventoy_efi_get_variable_compat (const char *var, const grub_guid_t * guid, + grub_size_t * size) +{ + void *data = NULL; + grub_efi_status_t status; + + status = grub_efi_get_variable (var, guid, size, &data); + if (status != GRUB_EFI_SUCCESS) + return NULL; + return data; +} + +/* ---- Stubs (safe no-ops for menu display + hypervisor mode) ---- */ + +int +ventoy_check_file_exist (const char *fmt, ...) +{ + (void) fmt; + return 0; +} + +int +grub_file_is_vlnk_suffix (const char *name, int len) +{ + (void) name; + (void) len; + return 0; +} + +int +grub_file_add_vlnk (const char *src, const char *dst) +{ + (void) src; + (void) dst; + return 0; +} + +int +grub_file_vtoy_vlnk (const char *src, const char *dst) +{ + (void) src; + (void) dst; + return 0; +} + +const char * +grub_file_get_vlnk (const char *name, int *vlnk) +{ + (void) name; + if (vlnk) + *vlnk = 0; + return NULL; +} + +grub_fs_t +grub_fs_list_probe (grub_device_t device, const char **list) +{ + (void) device; + (void) list; + return NULL; +} + +void +ventoy_env_hook_root (int hook) +{ + (void) hook; +} + +grub_err_t +grub_register_vtoy_menu_lang_hook (grub_env_read_hook_t read_hook) +{ + (void) read_hook; + return GRUB_ERR_NONE; +} + +grub_err_t +grub_disk_blocklist_read (void *chunklist, grub_uint64_t sector, + grub_uint64_t size, grub_uint32_t log_sector_size) +{ + (void) chunklist; + (void) sector; + (void) size; + (void) log_sector_size; + return GRUB_ERR_NONE; +} + +int g_ventoy_memdisk_mode = 0; +int g_ventoy_menu_esc = 0; +int g_ventoy_menu_refresh = 0; +int g_ventoy_secondary_menu_on = 0; +int g_ventoy_suppress_esc = 0; +int g_ventoy_suppress_esc_default = 0; +char g_ventoy_theme_path[256] = {0}; +int g_ventoy_wimboot_mode = 0; +int g_ventoy_case_insensitive = 0; +int g_ventoy_fn_mutex = 0; +int g_ventoy_grub2_mode = 0; +char g_ventoy_hotkey_tip[256] = {0}; +int g_ventoy_iso_raw = 0; +int g_ventoy_iso_uefi_drv = 0; +int g_ventoy_last_entry = 0; + +int +grub_btrfs_get_file_chunk (grub_uint64_t part_start, grub_file_t file, + ventoy_img_chunk_list * chunk_list) +{ + (void) part_start; + (void) file; + (void) chunk_list; + return 0; +} + +int +grub_ext_get_file_chunk (grub_uint64_t part_start, grub_file_t file, + ventoy_img_chunk_list * chunk_list) +{ + (void) part_start; + (void) file; + (void) chunk_list; + return 0; +} + +int +grub_fat_get_file_chunk (grub_uint64_t part_start, grub_file_t file, + ventoy_img_chunk_list * chunk_list) +{ + (void) part_start; + (void) file; + (void) chunk_list; + return 0; +} + +grub_uint64_t +grub_iso9660_get_last_file_dirent_pos (grub_file_t file) +{ + (void) file; + return 0; +} + +grub_uint64_t +grub_iso9660_get_last_read_pos (grub_file_t file) +{ + (void) file; + return 0; +} + +int +grub_iso9660_is_joliet (void) +{ + return 0; +} + +void +grub_iso9660_set_nojoliet (int val) +{ + (void) val; +} + +grub_uint64_t +grub_udf_get_file_offset (grub_file_t file) +{ + (void) file; + return 0; +} + +grub_uint64_t +grub_udf_get_last_file_attr_offset (grub_file_t file, + grub_uint32_t * startBlock, + grub_uint64_t * fe_entry_size_offset) +{ + (void) file; + if (startBlock) + *startBlock = 0; + if (fe_entry_size_offset) + *fe_entry_size_offset = 0; + return 0; +} + +grub_uint64_t +grub_udf_get_last_pd_size_offset (void) +{ + return 0; +} + +int +ventoy_menu_push_key (int code) +{ + (void) code; + return 0; +} +""" + +with open(compat_c_path, 'w') as f: + f.write(COMPAT_C) +print("WROTE: grub-core/ventoy/ventoy_compat.c") + +print("\nAll patches applied successfully.") diff --git a/src/grub2/grub/grub.cfg b/src/grub2/grub/grub.cfg index 07f44c4..1c3e6ac 100644 --- a/src/grub2/grub/grub.cfg +++ b/src/grub2/grub/grub.cfg @@ -1,5 +1,5 @@ #************************************************************************************ -# Copyright (c) 2020, vasilito (based on Ventoy) +# Copyright (c) 2020, vasilito # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -21,12 +21,12 @@ if [ "$grub_platform" = "pc" ]; then insmod regexp fi -function hiperiso_pause { +function ventoy_pause { echo "press Enter to continue ......" read vtTmpPause } -function hiperiso_debug_pause { +function ventoy_debug_pause { if [ -n "${vtdebug_flag}" ]; then echo "press Enter to continue ......" read vtTmpPause @@ -34,87 +34,87 @@ function hiperiso_debug_pause { } -function hiperiso_cli_console { - if [ -z "$hiso_display_mode" ]; then +function ventoy_cli_console { + if [ -z "$vtoy_display_mode" ]; then terminal_output console - elif [ "$hiso_display_mode" = "GUI" ]; then + elif [ "$vtoy_display_mode" = "GUI" ]; then terminal_output console fi } -function hiperiso_gui_console { - if [ -z "$hiso_display_mode" ]; then +function ventoy_gui_console { + if [ -z "$vtoy_display_mode" ]; then terminal_output gfxterm - elif [ "$hiso_display_mode" = "GUI" ]; then + elif [ "$vtoy_display_mode" = "GUI" ]; then terminal_output gfxterm fi } -function hiperiso_acpi_param { - if [ "$HISO_PARAM_NO_ACPI" != "1" ]; then +function ventoy_acpi_param { + if [ "$VTOY_PARAM_NO_ACPI" != "1" ]; then vt_acpi_param "$1" "$2" fi } function vt_vcfg_pre_proc { - vt_img_sector "${hiso_iso_part}${vt_chosen_path}" - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio $hiso_iso_part "$vt_chosen_path" + vt_img_sector "${vtoy_iso_part}${vt_chosen_path}" + vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver" + vt_trailer_cpio $vtoy_iso_part "$vt_chosen_path" } -function hiperiso_vcfg_proc { +function ventoy_vcfg_proc { if vt_check_custom_boot "${1}" vt_vcfg; then - set hiso_chosen_path="${1}" - vt_file_basefile "${hiso_chosen_path}" hiso_chosen_file + set vtoy_chosen_path="${1}" + vt_file_basefile "${vtoy_chosen_path}" vtoy_chosen_file - export hiso_chosen_path - export hiso_chosen_file - hiperiso_debug_pause - configfile "${hiso_iso_part}${vt_vcfg}" + export vtoy_chosen_path + export vtoy_chosen_file + ventoy_debug_pause + configfile "${vtoy_iso_part}${vt_vcfg}" true else false fi } -function hiperiso_language { +function ventoy_language { configfile $prefix/menulang.cfg } -function hiperiso_diagnosis { +function ventoy_diagnosis { vt_enum_video_mode configfile $prefix/debug.cfg } -function hiperiso_localboot { +function ventoy_localboot { configfile $prefix/localboot.cfg } -function hiperiso_ext_menu { - if [ -e $vt_plugin_path/hiperiso/hiperiso_grub.cfg ]; then - set hiperiso_new_context=1 - configfile $vt_plugin_path/hiperiso/hiperiso_grub.cfg - unset hiperiso_new_context +function ventoy_ext_menu { + if [ -e $vt_plugin_path/ventoy/ventoy_grub.cfg ]; then + set ventoy_new_context=1 + configfile $vt_plugin_path/ventoy/ventoy_grub.cfg + unset ventoy_new_context else - echo "hiperiso_grub.cfg NOT exist." + echo "ventoy_grub.cfg NOT exist." echo -en "\n$VTLANG_ENTER_EXIT ..." read vtInputKey fi } -function hiperiso_checksum { - if [ -f "${hiso_iso_part}${HISO_CHKSUM_FILE_PATH}" ]; then +function ventoy_checksum { + if [ -f "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}" ]; then configfile $prefix/checksum.cfg fi } -function hiperiso_show_help { +function ventoy_show_help { if [ -f $prefix/help.tar.gz ]; then - if [ -z "$hiso_help_txt_mem_addr" ]; then - vt_load_file_to_mem "auto" $prefix/help.tar.gz hiso_help_txt_mem + if [ -z "$vtoy_help_txt_mem_addr" ]; then + vt_load_file_to_mem "auto" $prefix/help.tar.gz vtoy_help_txt_mem fi - loopback vt_help_tarfs mem:${hiso_help_txt_mem_addr}:size:${hiso_help_txt_mem_size} + loopback vt_help_tarfs mem:${vtoy_help_txt_mem_addr}:size:${vtoy_help_txt_mem_size} vt_cur_menu_lang vtCurLang if [ -f "(vt_help_tarfs)/help/${vtCurLang}.txt" ]; then cat "(vt_help_tarfs)/help/${vtCurLang}.txt" @@ -125,56 +125,56 @@ function hiperiso_show_help { fi } -function hiperiso_load_menu_lang_file { - vt_load_file_to_mem "auto" $prefix/menu.tar.gz hiso_menu_lang_mem - loopback vt_menu_tarfs mem:${hiso_menu_lang_mem_addr}:size:${hiso_menu_lang_mem_size} +function ventoy_load_menu_lang_file { + 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 hiso_os=Linux - export hiso_os + set vtoy_os=Linux + export vtoy_os if vt_str_begin "$vt_volume_id" "DLC Boot"; then if [ -f (loop)/DLCBoot.exe ]; then - set hiso_os=Windows + set vtoy_os=Windows fi else for file in "efi/microsoft/boot/bcd" "sources/boot.wim" "boot/bcd" "bootmgr.efi" "boot/etfsboot.com" ; do if vt_file_exist_nocase (loop)/$file; then - set hiso_os=Windows + set vtoy_os=Windows break fi done fi - if [ "$hiso_os" = "Linux" ]; then + if [ "$vtoy_os" = "Linux" ]; then if vt_strstr "$vt_system_id" "FreeBSD"; then - set hiso_os=Unix + set vtoy_os=Unix set vt_unix_type=FreeBSD elif [ -e (loop)/bin/freebsd-version ]; then - set hiso_os=Unix + set vtoy_os=Unix set vt_unix_type=FreeBSD - elif [ -e (loop)/boot/kernel/geom_hiperiso.ko ]; then - set hiso_os=Unix + elif [ -e (loop)/boot/kernel/geom_ventoy.ko ]; then + set vtoy_os=Unix set vt_unix_type=FreeBSD elif vt_str_begin "$vt_system_id" "DragonFly"; then - set hiso_os=Unix + set vtoy_os=Unix set vt_unix_type=DragonFly elif [ -e (loop)/boot/kernel/kernel ]; then if file --is-x86-kfreebsd (loop)/boot/kernel/kernel; then - set hiso_os=Unix + set vtoy_os=Unix set vt_unix_type=FreeBSD elif file --is-x86-knetbsd (loop)/boot/kernel/kernel; then - set hiso_os=Unix + set vtoy_os=Unix set vt_unix_type=NetBSD fi fi fi if [ -n "${vtdebug_flag}" ]; then - echo ISO is "$hiso_os" + echo ISO is "$vtoy_os" fi } @@ -182,7 +182,7 @@ function vt_check_compatible_pe { #Check for PE without external tools #set compatible if ISO file is less than 80MB if [ $vt_chosen_size -GT 33554432 -a $vt_chosen_size -LE 83886080 ]; then - set hiperiso_compatible=YES + set ventoy_compatible=YES fi return @@ -190,9 +190,9 @@ function vt_check_compatible_pe { function vt_check_compatible_linux { if vt_str_begin "$vt_volume_id" "embootkit"; then - set hiperiso_compatible=YES + set ventoy_compatible=YES elif [ -e "$1/casper/tinycore.gz" ]; then - set hiperiso_compatible=YES + set ventoy_compatible=YES fi return @@ -203,7 +203,7 @@ function locate_initrd { if [ -n "${vtdebug_flag}" ]; then vt_linux_dump_initrd - hiperiso_debug_pause + ventoy_debug_pause fi } @@ -214,7 +214,7 @@ function locate_wim { echo '###############################################' vt_dump_wim_patch echo '###############################################' - hiperiso_debug_pause + ventoy_debug_pause fi } @@ -417,7 +417,7 @@ function distro_specify_initrd_file_phase2 { elif vt_str_begin "$vt_volume_id" "AERYNOS"; then vt_vcfg_pre_proc - loopback va "${hiso_iso_part}${vt_chosen_path}" + loopback va "${vtoy_iso_part}${vt_chosen_path}" loopback vb (va)/EFI/Boot/efiboot.img set root=(vb) @@ -428,19 +428,19 @@ function distro_specify_initrd_file_phase2 { } -function hiperiso_get_ghostbsd_ver { +function ventoy_get_ghostbsd_ver { # fallback to parse version from elf /boot/kernel/kernel set vt_freebsd_ver=xx } -function hiperiso_get_furybsd_ver { +function ventoy_get_furybsd_ver { set vt_freebsd_ver=12.x if regexp --set 1:vtFuryVer "(14|13)\.[0-9]" "$2"; then set vt_freebsd_ver=${vtFuryVer}.x fi } -function hiperiso_get_freenas_ver { +function ventoy_get_freenas_ver { set vt_freebsd_ver=11.x if [ -e (loop)/FreeNAS-MANIFEST ]; then @@ -451,7 +451,7 @@ function hiperiso_get_freenas_ver { fi } -function hiperiso_get_truenas_ver { +function ventoy_get_truenas_ver { set vt_freebsd_ver=12.x if [ -e (loop)/TrueNAS-MANIFEST ]; then @@ -462,7 +462,7 @@ function hiperiso_get_truenas_ver { fi } -function hiperiso_get_midnightbsd_ver { +function ventoy_get_midnightbsd_ver { if vt_str_begin "$vt_volume_id" "1_"; then set vt_freebsd_ver=11.x elif vt_str_begin "$vt_volume_id" "2_"; then @@ -472,27 +472,27 @@ function hiperiso_get_midnightbsd_ver { fi } -function hiperiso_freebsd_proc { +function ventoy_freebsd_proc { set vtFreeBsdDistro=FreeBSD set vt_freebsd_ver=xx - if [ -e (loop)/boot/kernel/geom_hiperiso.ko ]; then - vt_unix_ko_fillmap /boot/kernel/geom_hiperiso.ko + if [ -e (loop)/boot/kernel/geom_ventoy.ko ]; then + vt_unix_ko_fillmap /boot/kernel/geom_ventoy.ko return fi if vt_strstr "$vt_volume_id" "GHOSTBSD"; then - hiperiso_get_ghostbsd_ver "$1" "${chosen_path}" + ventoy_get_ghostbsd_ver "$1" "${chosen_path}" elif vt_strstr "$vt_volume_id" "FREENAS"; then - hiperiso_get_freenas_ver "$1" "${chosen_path}" + ventoy_get_freenas_ver "$1" "${chosen_path}" elif vt_strstr "$vt_volume_id" "TRUENAS"; then - hiperiso_get_truenas_ver "$1" "${chosen_path}" + ventoy_get_truenas_ver "$1" "${chosen_path}" elif vt_strstr "$vt_volume_id" "FURYBSD"; then - hiperiso_get_furybsd_ver "$1" "${chosen_path}" + ventoy_get_furybsd_ver "$1" "${chosen_path}" elif regexp --set 1:vtBsdVerNum "^(15|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 - hiperiso_get_midnightbsd_ver "$1" "${chosen_path}" + 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 @@ -555,10 +555,10 @@ function hiperiso_freebsd_proc { done if [ -n "$vt_unix_mod_path" ]; then - vt_unix_replace_ko $vt_unix_mod_path (vtunix)/hiperiso_unix/$vtFreeBsdDistro/geom_hiperiso_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_hiperiso.ko.xz + 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 vt_unix_replace_conf FreeBSD "${1}${chosen_path}" elif [ -e (loop)/easyre.ufs.uzip ]; then - vt_unix_replace_ko "/boot/grub/i386-pc/linux.mod" (vtunix)/hiperiso_unix/$vtFreeBsdDistro/geom_hiperiso_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_hiperiso.ko.xz + 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 if [ "$grub_platform" = "pc" ]; then vt_unix_replace_grub_conf "/boot/grub/i386-pc/linux.mod" "cd9" else @@ -567,7 +567,7 @@ function hiperiso_freebsd_proc { fi } -function hiperiso_dragonfly_proc { +function ventoy_dragonfly_proc { unset vt_unix_mod_path for file in "/boot/kernel/initrd.img.gz"; do @@ -577,24 +577,24 @@ function hiperiso_dragonfly_proc { fi done - vt_unix_replace_ko $vt_unix_mod_path ${hiso_path}/dragonfly.mfs.xz + vt_unix_replace_ko $vt_unix_mod_path ${vtoy_path}/dragonfly.mfs.xz vt_unix_fill_image_desc vt_unix_gzip_new_ko vt_unix_replace_conf DragonFly "${1}${chosen_path}" } -function hiperiso_unix_comm_proc { +function ventoy_unix_comm_proc { vt_unix_reset vt_unix_check_vlnk "${1}${chosen_path}" - if [ "$hiperiso_compatible" = "NO" ]; then - loopback vtunix $hiso_efi_part/hiperiso/hiperiso_unix.cpio + if [ "$ventoy_compatible" = "NO" ]; then + loopback vtunix $vtoy_efi_part/ventoy/ventoy_unix.cpio if [ "$vt_unix_type" = "FreeBSD" ]; then - hiperiso_freebsd_proc "$1" "${chosen_path}" + ventoy_freebsd_proc "$1" "${chosen_path}" elif [ "$vt_unix_type" = "DragonFly" ]; then - hiperiso_dragonfly_proc "$1" "${chosen_path}" + ventoy_dragonfly_proc "$1" "${chosen_path}" elif [ "$vt_unix_type" = "NetBSD" ]; then echo "NetBSD not supported" @@ -607,7 +607,7 @@ function hiperiso_unix_comm_proc { fi vt_unix_chain_data "${1}${chosen_path}" - hiperiso_debug_pause + ventoy_debug_pause } @@ -619,8 +619,8 @@ function uefi_windows_menu_func { set vt_cur_wimboot_mode=1 fi - if [ "$hiperiso_compatible" = "NO" -o "$vt_cur_wimboot_mode" = "1" ]; then - if [ "$hiperiso_fs_probe" = "iso9660" ]; then + if [ "$ventoy_compatible" = "NO" -o "$vt_cur_wimboot_mode" = "1" ]; then + if [ "$ventoy_fs_probe" = "iso9660" ]; then loopback -d loop vt_iso9660_nojoliet 1 loopback loop "$1$2" @@ -635,24 +635,24 @@ function uefi_windows_menu_func { distro_specify_wim_patch_phase2 fi - hiperiso_debug_pause + ventoy_debug_pause locate_wim "${chosen_path}" fi vt_windows_chain_data "${1}${chosen_path}" - hiperiso_debug_pause + ventoy_debug_pause if [ "$vt_cur_wimboot_mode" = "1" ]; then - hiso_wimboot_func + vtoy_wimboot_func fi if [ -n "$vtoy_chain_mem_addr" ]; then - hiperiso_acpi_param ${vtoy_chain_mem_addr} 2048 - chainloader ${hiso_path}/hiperiso_${HISO_EFI_ARCH}.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} iso_${hiperiso_fs_probe} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} + ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 + chainloader ${vtoy_path}/hiperiso_${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 echo "chain empty failed" - hiperiso_pause + ventoy_pause fi } @@ -668,21 +668,21 @@ function uefi_find_replace_initrd { fi loopback -d vtefivdisk - hiperiso_debug_pause + ventoy_debug_pause fi } function uefi_linux_menu_func { - if [ "$hiperiso_compatible" = "NO" ]; then + if [ "$ventoy_compatible" = "NO" ]; then - if [ "$hiperiso_fs_probe" = "udf" ]; then + if [ "$ventoy_fs_probe" = "udf" ]; then loopback -d loop - set hiperiso_fs_probe=iso9660 + set ventoy_fs_probe=iso9660 loopback loop "$1$2" fi - vt_load_cpio $hiso_path "$2" "$1" "busybox=$hiperiso_busybox_ver" + vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver" vt_linux_clear_initrd @@ -795,8 +795,8 @@ function uefi_linux_menu_func { fi if [ -n "$vtoy_chain_mem_addr" ]; then - hiperiso_acpi_param ${vtoy_chain_mem_addr} 2048 - hiperiso_cli_console + ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 + ventoy_cli_console unset vtGrub2Mode if vt_check_mode 3 "$vt_chosen_name"; then @@ -812,10 +812,10 @@ function uefi_linux_menu_func { fi if [ -n "$vtGrub2Mode" ]; then - hiperiso_debug_pause + ventoy_debug_pause else - if [ "$HISO_EFI_ARCH" != "mips" ]; then - chainloader ${hiso_path}/hiperiso_${HISO_EFI_ARCH}.efi fallback env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} + if [ "$VTOY_EFI_ARCH" != "mips" ]; then + chainloader ${vtoy_path}/hiperiso_${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} boot fi fi @@ -826,8 +826,8 @@ function uefi_linux_menu_func { set vtback_theme=$theme unset theme - vt_trailer_cpio "$hiso_iso_part" "$vt_chosen_path" noinit - vt_set_boot_opt rdinit=/hiso/hiso + vt_trailer_cpio "$vtoy_iso_part" "$vt_chosen_path" noinit + vt_set_boot_opt rdinit=/vtoy/vtoy set root=(loop) set vtback_cfg_find=0 @@ -864,7 +864,7 @@ function uefi_linux_menu_func { if [ "$vtback_cfg_find" = "0" ]; then echo " " echo "No bootfile found for UEFI!" - echo "Maybe the image does not support $HISO_EFI_ARCH UEFI" + echo "Maybe the image does not support $VTOY_EFI_ARCH UEFI" echo " " sleep 30 fi @@ -873,28 +873,28 @@ function uefi_linux_menu_func { set root=$vtback_root set theme=$vtback_theme vt_pop_last_entry - hiperiso_gui_console + ventoy_gui_console else echo "chain empty failed" - hiperiso_pause + ventoy_pause fi } function uefi_unix_menu_func { - hiperiso_unix_comm_proc $1 "${chosen_path}" + ventoy_unix_comm_proc $1 "${chosen_path}" if [ -n "$vtoy_chain_mem_addr" ]; then - hiperiso_acpi_param ${vtoy_chain_mem_addr} 2048 - hiperiso_cli_console - chainloader ${hiso_path}/hiperiso_${HISO_EFI_ARCH}.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} + ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 + ventoy_cli_console + chainloader ${vtoy_path}/hiperiso_${VTOY_EFI_ARCH}.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} boot else echo "chain empty failed" - hiperiso_pause + ventoy_pause fi } -function hiperiso_reset_nojoliet { +function ventoy_reset_nojoliet { if vt_str_begin "$vt_volume_id" "ARCARESCUE"; then vt_iso9660_nojoliet 1 else @@ -921,7 +921,7 @@ function uefi_iso_menu_func { 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 "${hiso_iso_part}${vt_chosen_path}" + vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}" vt_append_extra_sector 1 fi fi @@ -935,172 +935,172 @@ function uefi_iso_menu_func { fi if [ -n "$vtcompat" ]; then - set hiperiso_compatible=YES + set ventoy_compatible=YES unset vtcompat elif vt_check_mode 1 "$vt_chosen_name"; then - set hiperiso_compatible=YES + set ventoy_compatible=YES else vt_check_compatible (loop) fi vt_img_sector "${1}${chosen_path}" - if [ "$hiperiso_fs_probe" = "iso9660" ]; then + if [ "$ventoy_fs_probe" = "iso9660" ]; then vt_select_conf_replace "${1}" "${chosen_path}" fi - if [ "$hiso_os" = "Windows" ]; then + if [ "$vtoy_os" = "Windows" ]; then vt_check_compatible_pe (loop) uefi_windows_menu_func "$1" "${chosen_path}" - elif [ "$hiso_os" = "Unix" ]; then + elif [ "$vtoy_os" = "Unix" ]; then uefi_unix_menu_func "$1" "${chosen_path}" else vt_check_compatible_linux (loop) uefi_linux_menu_func "$1" "${chosen_path}" fi - hiperiso_gui_console + ventoy_gui_console } function uefi_iso_memdisk { echo 'Loading ISO file to memory ...' - vt_load_img_memdisk "${1}${2}" hiso_iso_buf + vt_load_img_memdisk "${1}${2}" vtoy_iso_buf - hiperiso_cli_console - chainloader ${hiso_path}/hiperiso_${HISO_EFI_ARCH}.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${hiso_iso_buf_addr}:size:${hiso_iso_buf_size} + ventoy_cli_console + chainloader ${vtoy_path}/hiperiso_${VTOY_EFI_ARCH}.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_iso_buf_addr}:size:${vtoy_iso_buf_size} boot - hiperiso_gui_console + ventoy_gui_console } -function hiso_windows_wimboot { +function vtoy_windows_wimboot { if [ -f (loop)/x86/sources/boot.wim -a -f (loop)/x64/sources/boot.wim ]; then - vt_sel_wimboot hiso_wimboot_bit - if [ "$hiso_wimboot_bit" = "32" ]; then - set hiso_wimboot_prefix=(loop)/x86 + vt_sel_wimboot vtoy_wimboot_bit + if [ "$vtoy_wimboot_bit" = "32" ]; then + set vtoy_wimboot_prefix=(loop)/x86 else - set hiso_wimboot_prefix=(loop)/x64 + set vtoy_wimboot_prefix=(loop)/x64 fi else - set hiso_wimboot_prefix=(loop) - if vt_is_pe64 $hiso_wimboot_prefix/setup.exe; then - set hiso_wimboot_bit=64 + set vtoy_wimboot_prefix=(loop) + if vt_is_pe64 $vtoy_wimboot_prefix/setup.exe; then + set vtoy_wimboot_bit=64 else - set hiso_wimboot_bit=32 + set vtoy_wimboot_bit=32 fi fi if [ -n "${vtdebug_flag}" ]; then - echo hiso_wimboot_prefix=$hiso_wimboot_prefix hiso_wimboot_bit=$hiso_wimboot_bit vt_wimkernel=$vt_wimkernel + echo vtoy_wimboot_prefix=$vtoy_wimboot_prefix vtoy_wimboot_bit=$vtoy_wimboot_bit vt_wimkernel=$vt_wimkernel fi - vt_windows_wimboot_data "$hiso_wimboot_prefix/sources/boot.wim" hiso_init_exe hiso_wim_bit + vt_windows_wimboot_data "$vtoy_wimboot_prefix/sources/boot.wim" vtoy_init_exe vtoy_wim_bit if [ "$grub_platform" = "pc" ]; then - linux16 "$hiso_path/$vt_wimkernel" quiet - hiperiso_debug_pause + linux16 "$vtoy_path/$vt_wimkernel" quiet + ventoy_debug_pause vt_set_wim_load_prompt 1 "Loading files......" initrd16 newc:winpeshl.exe:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size} \ - newc:hiso_wimboot:$hiso_wimboot_prefix/boot/bcd \ - newc:bcd:$hiso_wimboot_prefix/boot/bcd \ - newc:boot.sdi:$hiso_wimboot_prefix/boot/boot.sdi \ - newc:boot.wim:$hiso_wimboot_prefix/sources/boot.wim + newc:vtoy_wimboot:$vtoy_wimboot_prefix/boot/bcd \ + 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 vt_set_wim_load_prompt 1 "Loading files......" - vt_load_file_to_mem "nodecompress" $hiso_wimboot_prefix/sources/boot.wim hiso_wimfile_mem + 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 hiso_wimfile_path=mem:${hiso_wimfile_mem_addr}:size:${hiso_wimfile_mem_size} + set vtoy_wimfile_path=mem:${vtoy_wimfile_mem_addr}:size:${vtoy_wimfile_mem_size} else - set hiso_wimfile_path=$hiso_wimboot_prefix/sources/boot.wim + set vtoy_wimfile_path=$vtoy_wimboot_prefix/sources/boot.wim fi - hiperiso_cli_console - chainloader "$hiso_path/$vt_wimkernel" quiet \ + ventoy_cli_console + chainloader "$vtoy_path/$vt_wimkernel" quiet \ "vf=winpeshl.exe:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size}" \ - "vf=hiso_wimboot:$hiso_wimboot_prefix/boot/bcd" \ - "vf=bcd:$hiso_wimboot_prefix/boot/bcd" \ - "vf=boot.sdi:$hiso_wimboot_prefix/boot/boot.sdi" \ - "vf=boot.wim:$hiso_wimfile_path" \ - pfsize=$hiso_chain_file_size \ - pfread=$hiso_chain_file_read + "vf=vtoy_wimboot:$vtoy_wimboot_prefix/boot/bcd" \ + "vf=bcd:$vtoy_wimboot_prefix/boot/bcd" \ + "vf=boot.sdi:$vtoy_wimboot_prefix/boot/boot.sdi" \ + "vf=boot.wim:$vtoy_wimfile_path" \ + pfsize=$vtoy_chain_file_size \ + pfread=$vtoy_chain_file_read boot - hiperiso_gui_console + ventoy_gui_console fi } -function hiso_winpe_wimboot { - unset hiso_boot_sdi_legacy - unset hiso_boot_sdi_efi +function vtoy_winpe_wimboot { + unset vtoy_boot_sdi_legacy + unset vtoy_boot_sdi_efi - set hiso_wimboot_prefix=(loop) - set hiso_wim_path="$1" + set vtoy_wimboot_prefix=(loop) + set vtoy_wim_path="$1" if [ -n "${vtdebug_flag}" ]; then echo "winpe_wimboot $1 $2 $3" fi if [ "$2" != "0" ]; then - set hiso_boot_sdi_legacy="newc:boot.sdi:$hiso_wimboot_prefix/$2" - set hiso_boot_sdi_efi="vf=boot.sdi:$hiso_wimboot_prefix/$2" + set vtoy_boot_sdi_legacy="newc:boot.sdi:$vtoy_wimboot_prefix/$2" + set vtoy_boot_sdi_efi="vf=boot.sdi:$vtoy_wimboot_prefix/$2" fi - vt_windows_wimboot_data $hiso_wimboot_prefix/$hiso_wim_path hiso_init_exe hiso_wim_bit + vt_windows_wimboot_data $vtoy_wimboot_prefix/$vtoy_wim_path vtoy_init_exe vtoy_wim_bit if [ "$grub_platform" = "pc" ]; then - linux16 "$hiso_path/$vt_wimkernel" quiet - hiperiso_debug_pause + linux16 "$vtoy_path/$vt_wimkernel" quiet + ventoy_debug_pause vt_set_wim_load_prompt 1 "Loading files......" - initrd16 newc:$hiso_init_exe:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size} \ - newc:hiso_wimboot:$hiso_path/$vt_wimkernel \ - newc:bootmgr.exe:mem:${hiso_pe_bootmgr_mem_addr}:size:${hiso_pe_bootmgr_mem_size} \ - newc:bcd:mem:${hiso_pe_bcd_mem_addr}:size:${hiso_pe_bcd_mem_size} \ - $hiso_boot_sdi_legacy \ - newc:boot.wim:$hiso_wimboot_prefix/$hiso_wim_path + initrd16 newc:$vtoy_init_exe:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size} \ + newc:vtoy_wimboot:$vtoy_path/$vt_wimkernel \ + newc:bootmgr.exe:mem:${vtoy_pe_bootmgr_mem_addr}:size:${vtoy_pe_bootmgr_mem_size} \ + newc:bcd:mem:${vtoy_pe_bcd_mem_addr}:size:${vtoy_pe_bcd_mem_size} \ + $vtoy_boot_sdi_legacy \ + newc:boot.wim:$vtoy_wimboot_prefix/$vtoy_wim_path vt_set_wim_load_prompt 0 boot else - if [ "$HISO_EFI_ARCH" = "x64" -a "$hiso_wim_bit" = "32" ]; then + if [ "$VTOY_EFI_ARCH" = "x64" -a "$vtoy_wim_bit" = "32" ]; then echo -e "\nThis is 32bit Windows and does NOT support x86_64 UEFI firmware.\n" echo -e "这是32位的 Windows 系统,不支持当前的64位 UEFI 环境。\n" fi vt_set_wim_load_prompt 1 "Loading files......" - vt_load_file_to_mem "nodecompress" $hiso_wimboot_prefix/$hiso_wim_path hiso_wimfile_mem + vt_load_file_to_mem "nodecompress" $vtoy_wimboot_prefix/$vtoy_wim_path vtoy_wimfile_mem vt_set_wim_load_prompt 0 if [ $? -eq 0 ]; then - set hiso_wimfile_path=mem:${hiso_wimfile_mem_addr}:size:${hiso_wimfile_mem_size} + set vtoy_wimfile_path=mem:${vtoy_wimfile_mem_addr}:size:${vtoy_wimfile_mem_size} else - set hiso_wimfile_path=$hiso_wimboot_prefix/$hiso_wim_path + set vtoy_wimfile_path=$vtoy_wimboot_prefix/$vtoy_wim_path fi - unset hiso_boot_efi_path - if [ -F (loop)/efi/boot/boot${HISO_EFI_ARCH}.efi ]; then - set hiso_boot_efi_path="vf=bootx64.efi:(loop)/efi/boot/boot${HISO_EFI_ARCH}.efi" + unset vtoy_boot_efi_path + if [ -F (loop)/efi/boot/boot${VTOY_EFI_ARCH}.efi ]; then + set vtoy_boot_efi_path="vf=bootx64.efi:(loop)/efi/boot/boot${VTOY_EFI_ARCH}.efi" fi - hiperiso_cli_console - chainloader "$hiso_path/$vt_wimkernel" quiet \ - "vf=$hiso_init_exe:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size}" \ - "vf=hiso_wimboot:$hiso_path/$vt_wimkernel" \ - "vf=bcd:mem:${hiso_pe_bcd_mem_addr}:size:${hiso_pe_bcd_mem_size}" \ - "$hiso_boot_sdi_efi" \ - "$hiso_boot_efi_path" \ - "vf=boot.wim:$hiso_wimfile_path" \ - pfsize=$hiso_chain_file_size \ - pfread=$hiso_chain_file_read + ventoy_cli_console + chainloader "$vtoy_path/$vt_wimkernel" quiet \ + "vf=$vtoy_init_exe:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size}" \ + "vf=vtoy_wimboot:$vtoy_path/$vt_wimkernel" \ + "vf=bcd:mem:${vtoy_pe_bcd_mem_addr}:size:${vtoy_pe_bcd_mem_size}" \ + "$vtoy_boot_sdi_efi" \ + "$vtoy_boot_efi_path" \ + "vf=boot.wim:$vtoy_wimfile_path" \ + pfsize=$vtoy_chain_file_size \ + pfread=$vtoy_chain_file_read boot - hiperiso_gui_console + ventoy_gui_console fi } -function hiso_wimboot_func { +function vtoy_wimboot_func { if [ "$grub_platform" = "pc" ]; then set vt_wimkernel=wimboot.x86_64.xz else @@ -1112,15 +1112,15 @@ function hiso_wimboot_func { fi if vt_is_standard_winiso (loop); then - echo -e "\n==================== HIPERISO WIMBOOT ==================\n" - hiso_windows_wimboot + echo -e "\n==================== VENTOY WIMBOOT ==================\n" + vtoy_windows_wimboot else vt_sel_winpe_wim (loop) - if [ -n "$hiso_pe_wim_path" ]; then - echo -e "\n==================== HIPERISO WIMBOOT ==================\n" + if [ -n "$vtoy_pe_wim_path" ]; then + echo -e "\n==================== VENTOY WIMBOOT ==================\n" vt_fs_ignore_case 1 - vt_load_file_to_mem "auto" $hiso_path/common_bcd.xz hiso_pe_bcd_mem + vt_load_file_to_mem "auto" $vtoy_path/common_bcd.xz vtoy_pe_bcd_mem set vt_sdi_path=0 for vsdi in "boot/boot.sdi" "2K10/FONTS/boot.sdi" "SSTR/boot.sdi" "ISPE/BOOT.SDI" \ @@ -1132,10 +1132,10 @@ function hiso_wimboot_func { done if [ "$grub_platform" = "pc" ]; then - vt_load_file_to_mem "auto" $hiso_path/common_bootmgr.xz hiso_pe_bootmgr_mem - hiso_winpe_wimboot "$hiso_pe_wim_path" "$vt_sdi_path" 1 + vt_load_file_to_mem "auto" $vtoy_path/common_bootmgr.xz vtoy_pe_bootmgr_mem + vtoy_winpe_wimboot "$vtoy_pe_wim_path" "$vt_sdi_path" 1 else - hiso_winpe_wimboot "$hiso_pe_wim_path" "$vt_sdi_path" 0 + vtoy_winpe_wimboot "$vtoy_pe_wim_path" "$vt_sdi_path" 0 fi vt_fs_ignore_case 0 @@ -1151,8 +1151,8 @@ function legacy_windows_menu_func { set vt_cur_wimboot_mode=1 fi - if [ "$hiperiso_compatible" = "NO" -o "$vt_cur_wimboot_mode" = "1" ]; then - if [ "$hiperiso_fs_probe" = "iso9660" ]; then + if [ "$ventoy_compatible" = "NO" -o "$vt_cur_wimboot_mode" = "1" ]; then + if [ "$ventoy_fs_probe" = "iso9660" ]; then loopback -d loop vt_iso9660_nojoliet 1 loopback loop "$1$2" @@ -1169,39 +1169,39 @@ function legacy_windows_menu_func { distro_specify_wim_patch_phase2 fi - hiperiso_debug_pause + ventoy_debug_pause if [ -z "$vt_cur_wimboot_mode" ]; then locate_wim "${chosen_path}" fi fi vt_windows_chain_data "${1}${chosen_path}" - hiperiso_debug_pause + ventoy_debug_pause if [ "$vt_cur_wimboot_mode" = "1" ]; then - hiso_wimboot_func + vtoy_wimboot_func fi if [ -n "$vtoy_chain_mem_addr" ]; then - hiperiso_acpi_param ${vtoy_chain_mem_addr} 2048 - if [ "$hiperiso_compatible" = "NO" ]; then - linux16 $hiso_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} + ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 + if [ "$ventoy_compatible" = "NO" ]; then + linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} else - linux16 $hiso_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} + linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} fi boot else echo "chain empty failed" - hiperiso_pause + ventoy_pause fi } function legacy_linux_menu_func { - if [ "$hiperiso_compatible" = "NO" ]; then + if [ "$ventoy_compatible" = "NO" ]; then - if [ "$hiperiso_fs_probe" = "udf" ]; then + if [ "$ventoy_fs_probe" = "udf" ]; then loopback -d loop - set hiperiso_fs_probe=iso9660 + set ventoy_fs_probe=iso9660 loopback loop "$1$2" fi @@ -1212,7 +1212,7 @@ function legacy_linux_menu_func { loopback loop "$1$2" fi - vt_load_cpio $hiso_path "$2" "$1" "busybox=$hiperiso_busybox_ver" + vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver" vt_linux_clear_initrd @@ -1258,7 +1258,7 @@ function legacy_linux_menu_func { fi vt_linux_chain_data "${1}${chosen_path}" - hiperiso_debug_pause + ventoy_debug_pause if [ -n "$vtoy_chain_mem_addr" ]; then unset vtGrub2Mode @@ -1271,8 +1271,8 @@ function legacy_linux_menu_func { fi if [ -n "$vtGrub2Mode" ]; then - hiperiso_acpi_param ${vtoy_chain_mem_addr} 2048 - hiperiso_cli_console + ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 + ventoy_cli_console # fallback set vtback_root=$root @@ -1280,8 +1280,8 @@ function legacy_linux_menu_func { set vtback_theme=$theme unset theme - vt_trailer_cpio "$hiso_iso_part" "$vt_chosen_path" noinit - vt_set_boot_opt rdinit=/hiso/hiso + vt_trailer_cpio "$vtoy_iso_part" "$vt_chosen_path" noinit + vt_set_boot_opt rdinit=/vtoy/vtoy set root=(loop) set vtback_cfg_find=0 @@ -1319,29 +1319,29 @@ function legacy_linux_menu_func { set root=$vtback_root set theme=$vtback_theme vt_pop_last_entry - hiperiso_gui_console + ventoy_gui_console else - hiperiso_acpi_param ${vtoy_chain_mem_addr} 2048 - linux16 $hiso_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} + ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 + linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} boot fi else echo "chain empty failed" - hiperiso_pause + ventoy_pause fi } function legacy_unix_menu_func { - hiperiso_unix_comm_proc $1 "${chosen_path}" + ventoy_unix_comm_proc $1 "${chosen_path}" if [ -n "$vtoy_chain_mem_addr" ]; then - #hiperiso_acpi_param ${vtoy_chain_mem_addr} 2048 - linux16 $hiso_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} + #ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 + linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} boot else echo "chain empty failed" - hiperiso_pause + ventoy_pause fi } @@ -1353,24 +1353,24 @@ function legacy_iso_menu_func { vt_select_persistence "${chosen_path}" if [ -n "$vtcompat" ]; then - set hiperiso_compatible=YES + set ventoy_compatible=YES unset vtcompat elif vt_check_mode 1 "$vt_chosen_name"; then - set hiperiso_compatible=YES + set ventoy_compatible=YES else vt_check_compatible (loop) fi vt_img_sector "${1}${chosen_path}" - if [ "$hiperiso_fs_probe" = "iso9660" ]; then + if [ "$ventoy_fs_probe" = "iso9660" ]; then vt_select_conf_replace "${1}" "${chosen_path}" fi - if [ "$hiso_os" = "Windows" ]; then + if [ "$vtoy_os" = "Windows" ]; then vt_check_compatible_pe (loop) legacy_windows_menu_func "$1" "${chosen_path}" - elif [ "$hiso_os" = "Unix" ]; then + elif [ "$vtoy_os" = "Unix" ]; then legacy_unix_menu_func "$1" "${chosen_path}" else vt_check_compatible_linux (loop) @@ -1381,7 +1381,7 @@ function legacy_iso_menu_func { function legacy_iso_memdisk { - linux16 $hiso_path/memdisk iso raw + linux16 $vtoy_path/memdisk iso raw echo "Loading ISO file to memory ..." initrd16 "${1}${2}" boot @@ -1396,56 +1396,56 @@ function iso_endless_os_proc { loopback loop "${1}${2}" vt_img_sector "${1}${2}" - vt_load_cpio $hiso_path "$2" "$1" "busybox=$hiperiso_busybox_ver" + vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver" vt_trailer_cpio "$1" "$2" noinit - hiperiso_debug_pause + ventoy_debug_pause - vt_set_boot_opt '@kparams' rdinit=/hiso/hiso + vt_set_boot_opt '@kparams' rdinit=/vtoy/vtoy set eosimage=loop - set hiperiso_bls_bootdev=/boot - set hiperiso_loading_tip="Loading files ......" + set ventoy_bls_bootdev=/boot + set ventoy_loading_tip="Loading files ......" export eosimage configfile (loop)/endless/grub/grub.cfg unset eosimage - unset hiperiso_bls_bootdev - unset hiperiso_loading_tip + unset ventoy_bls_bootdev + unset ventoy_loading_tip vt_unset_boot_opt } -function hiperiso_iso_busybox_ver { +function ventoy_iso_busybox_ver { - if [ "$HISO_EFI_ARCH" = "aa64" ]; then - set hiperiso_busybox_ver=a64 - elif [ "$HISO_EFI_ARCH" = "mips" ]; then - set hiperiso_busybox_ver=m64 + if [ "$VTOY_EFI_ARCH" = "aa64" ]; then + set ventoy_busybox_ver=a64 + elif [ "$VTOY_EFI_ARCH" = "mips" ]; then + set ventoy_busybox_ver=m64 else - set hiperiso_busybox_ver=32 + set ventoy_busybox_ver=32 #special process for deepin-live iso if [ "$vt_chosen_size" = "403701760" ]; then if vt_strstr "$vt_chosen_path" "/deepin-live"; then - set hiperiso_busybox_ver=64 + set ventoy_busybox_ver=64 fi elif vt_str_begin "$vt_volume_id" "PHOTON_"; then - set hiperiso_busybox_ver=64 + set ventoy_busybox_ver=64 elif vt_str_begin "$vt_volume_id" "smgl-test-quinq-x86_64"; then - set hiperiso_busybox_ver=64 + set ventoy_busybox_ver=64 elif vt_str_begin "$vt_volume_id" "LDiagBootable"; then - set hiperiso_busybox_ver=64 + set ventoy_busybox_ver=64 elif vt_str_begin "$vt_volume_id" "KAOS_"; then - set hiperiso_busybox_ver=64 + set ventoy_busybox_ver=64 elif vt_strstr "$vt_volume_id" "x86_64"; then - set hiperiso_busybox_ver=64 + set ventoy_busybox_ver=64 elif vt_istrstr "${vt_chosen_path}" "x86_64"; then - set hiperiso_busybox_ver=64 + set ventoy_busybox_ver=64 elif vt_istrstr "${vt_chosen_path}" "amd64"; then - set hiperiso_busybox_ver=64 + set ventoy_busybox_ver=64 fi fi } @@ -1457,7 +1457,7 @@ function iso_common_menuentry { vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name - vt_parse_iso_volume "${hiso_iso_part}${vt_chosen_path}" vt_system_id vt_volume_id vt_volume_space + vt_parse_iso_volume "${vtoy_iso_part}${vt_chosen_path}" vt_system_id vt_volume_id vt_volume_space if [ $vt_volume_space -NE $vt_chosen_size ]; then vt_mod $vt_chosen_size 2048 vt_chosen_size_mod if [ $vt_chosen_size_mod -ne 0 ]; then @@ -1473,63 +1473,58 @@ function iso_common_menuentry { return fi - if [ -n "$hiso_hv_mode" ]; then + if [ -n "$vtoy_hv_mode" ]; then hiperiso_boot "${vt_chosen_path}" return fi - if hiperiso_vcfg_proc "${vt_chosen_path}"; then + if ventoy_vcfg_proc "${vt_chosen_path}"; then return fi #secondary boot menu - if vt_is_udf "${hiso_iso_part}${vt_chosen_path}"; then - set hiperiso_fs_probe=udf + if vt_is_udf "${vtoy_iso_part}${vt_chosen_path}"; then + set ventoy_fs_probe=udf else - set hiperiso_fs_probe=iso9660 - hiperiso_reset_nojoliet + set ventoy_fs_probe=iso9660 + ventoy_reset_nojoliet fi if [ -d (loop)/ ]; then loopback -d loop fi - loopback loop "${hiso_iso_part}${vt_chosen_path}" + loopback loop "${vtoy_iso_part}${vt_chosen_path}" get_os_type (loop) - hiperiso_debug_pause + ventoy_debug_pause if vt_need_secondary_menu "$vt_chosen_name"; then - vt_show_secondary_menu "$vt_chosen_path" "$hiso_os" $vt_chosen_size - if [ "$HISO_SECOND_EXIT" = "1" ]; then + vt_show_secondary_menu "$vt_chosen_path" "$vtoy_os" $vt_chosen_size + if [ "$VTOY_SECOND_EXIT" = "1" ]; then return fi fi - if [ -n "$hiso_hv_mode" ]; then - hiperiso_boot "${vt_chosen_path}" - return - fi - if vt_str_begin "$vt_volume_id" "Avira"; then - vt_skip_svd "${hiso_iso_part}${vt_chosen_path}" + vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}" fi - hiperiso_iso_busybox_ver + ventoy_iso_busybox_ver #special process for Endless OS if vt_str_begin "$vt_volume_id" "Endless-OS"; then - iso_endless_os_proc $hiso_iso_part "$vt_chosen_path" + iso_endless_os_proc $vtoy_iso_part "$vt_chosen_path" elif vt_str_begin "$vt_volume_id" "TENS-Public"; then set vtcompat=1 fi # auto memdisk mode for some special ISO files - vt_iso_vd_id_parse "${hiso_iso_part}${vt_chosen_path}" + vt_iso_vd_id_parse "${vtoy_iso_part}${vt_chosen_path}" unset vtMemDiskBoot if vt_check_mode 0 "$vt_chosen_name"; then set vtMemDiskBoot=1 @@ -1554,15 +1549,15 @@ function iso_common_menuentry { if [ "$grub_platform" = "pc" ]; then if [ -n "$vtMemDiskBoot" ]; then - legacy_iso_memdisk $hiso_iso_part "$vt_chosen_path" + legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path" else - legacy_iso_menu_func $hiso_iso_part "$vt_chosen_path" + legacy_iso_menu_func $vtoy_iso_part "$vt_chosen_path" fi else if [ -n "$vtMemDiskBoot" ]; then - uefi_iso_memdisk $hiso_iso_part "$vt_chosen_path" + uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path" else - uefi_iso_menu_func $hiso_iso_part "$vt_chosen_path" + uefi_iso_menu_func $vtoy_iso_part "$vt_chosen_path" fi fi @@ -1576,19 +1571,19 @@ function miso_common_menuentry { return fi - if [ -n "$hiso_hv_mode" ]; then + if [ -n "$vtoy_hv_mode" ]; then hiperiso_boot "${vt_chosen_path}" return fi echo "memdisk mode boot for $vt_chosen_path" echo "" - hiperiso_debug_pause + ventoy_debug_pause if [ "$grub_platform" = "pc" ]; then - legacy_iso_memdisk $hiso_iso_part "$vt_chosen_path" + legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path" else - uefi_iso_memdisk $hiso_iso_part "$vt_chosen_path" + uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path" fi } @@ -1615,36 +1610,36 @@ function wim_common_menuentry { return fi - if [ -n "$hiso_hv_mode" ]; then + if [ -n "$vtoy_hv_mode" ]; then hiperiso_boot "${vt_chosen_path}" return fi - if hiperiso_vcfg_proc "${vt_chosen_path}"; then + if ventoy_vcfg_proc "${vt_chosen_path}"; then return fi - if vt_wim_check_bootable "${hiso_iso_part}${vt_chosen_path}"; then - vt_wim_chain_data "${hiso_iso_part}${vt_chosen_path}" + if vt_wim_check_bootable "${vtoy_iso_part}${vt_chosen_path}"; then + vt_wim_chain_data "${vtoy_iso_part}${vt_chosen_path}" else echo -e "\n This is NOT a bootable WIM file. \n" echo -e " 这不是一个可启动的 WIM 文件。\n" fi - hiperiso_debug_pause + ventoy_debug_pause if [ -n "$vtoy_chain_mem_addr" ]; then if [ "$grub_platform" = "pc" ]; then - linux16 $hiso_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} + linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} else - hiperiso_cli_console - chainloader ${hiso_path}/hiperiso_${HISO_EFI_ARCH}.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} - hiperiso_gui_console + ventoy_cli_console + chainloader ${vtoy_path}/hiperiso_${VTOY_EFI_ARCH}.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} + ventoy_gui_console fi boot else echo "chain empty failed" - hiperiso_pause + ventoy_pause fi } @@ -1659,44 +1654,44 @@ function efi_common_menuentry { return fi - if [ -n "$hiso_hv_mode" ]; then + if [ -n "$vtoy_hv_mode" ]; then hiperiso_boot "${vt_chosen_path}" return fi - if hiperiso_vcfg_proc "${vt_chosen_path}"; then + if ventoy_vcfg_proc "${vt_chosen_path}"; then return fi unset vt_vlnk_dst if vt_is_vlnk_name "${vt_chosen_path}"; then - vt_get_vlnk_dst "${hiso_iso_part}${vt_chosen_path}" vt_vlnk_dst + vt_get_vlnk_dst "${vtoy_iso_part}${vt_chosen_path}" vt_vlnk_dst if [ -z "$vt_vlnk_dst" ]; then echo -e "\n### VLNK FILE NOT FOUND ###\n### VLNK 文件不存在 ###\n" - hiperiso_pause + ventoy_pause return fi else - vt_vlnk_dst="${hiso_iso_part}${vt_chosen_path}" + vt_vlnk_dst="${vtoy_iso_part}${vt_chosen_path}" fi - hiperiso_debug_pause + ventoy_debug_pause - hiperiso_cli_console + ventoy_cli_console #first try with chainload set vtOldRoot=$root - set root=$hiso_iso_part + set root=$vtoy_iso_part chainloader "${vt_vlnk_dst}" boot #retry with isoboot set root=$vtOldRoot - vt_concat_efi_iso "${vt_vlnk_dst}" hiso_iso_buf - chainloader ${hiso_path}/hiperiso_${HISO_EFI_ARCH}.efi memdisk env_param=${env_param} dotefi isoefi=on ${vtdebug_flag} mem:${hiso_iso_buf_addr}:size:${hiso_iso_buf_size} + vt_concat_efi_iso "${vt_vlnk_dst}" vtoy_iso_buf + chainloader ${vtoy_path}/hiperiso_${VTOY_EFI_ARCH}.efi memdisk env_param=${env_param} dotefi isoefi=on ${vtdebug_flag} mem:${vtoy_iso_buf_addr}:size:${vtoy_iso_buf_size} boot - hiperiso_gui_console + ventoy_gui_console } function efi_unsupport_menuentry { @@ -1706,24 +1701,24 @@ function efi_unsupport_menuentry { function vhdboot_common_func { vt_patch_vhdboot "$1" - hiperiso_debug_pause + ventoy_debug_pause if [ -n "$vtoy_vhd_buf_addr" ]; then if [ "$grub_platform" = "pc" ]; then - hiperiso_cli_console - linux16 $hiso_path/memdisk iso raw + ventoy_cli_console + linux16 $vtoy_path/memdisk iso raw initrd16 mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size} boot - hiperiso_gui_console + ventoy_gui_console else - hiperiso_cli_console - chainloader ${hiso_path}/hiperiso_${HISO_EFI_ARCH}.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size} + ventoy_cli_console + chainloader ${vtoy_path}/hiperiso_${VTOY_EFI_ARCH}.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size} boot - hiperiso_gui_console + ventoy_gui_console fi else - echo "Please put the right hiperiso_vhdboot.img file to the 1st partition" - hiperiso_pause + echo "Please put the right ventoy_vhdboot.img file to the 1st partition" + ventoy_pause fi } @@ -1734,29 +1729,29 @@ function vhd_common_menuentry { return fi - if [ -n "$hiso_hv_mode" ]; then + if [ -n "$vtoy_hv_mode" ]; then hiperiso_boot "${vt_chosen_path}" return fi - if hiperiso_vcfg_proc "${vt_chosen_path}"; then + if ventoy_vcfg_proc "${vt_chosen_path}"; then return fi unset vt_vlnk_dst if vt_is_vlnk_name "${vt_chosen_path}"; then - vt_get_vlnk_dst "${hiso_iso_part}${vt_chosen_path}" vt_vlnk_dst + vt_get_vlnk_dst "${vtoy_iso_part}${vt_chosen_path}" vt_vlnk_dst if [ -z "$vt_vlnk_dst" ]; then echo -e "\n### VLNK FILE NOT FOUND ###\n### VLNK 文件不存在 ###\n" - hiperiso_pause + ventoy_pause return fi else vt_vlnk_dst="${vt_chosen_path}" - if [ "$HISO_VHD_NO_WARNING" != "1" ]; then - if [ "$hiso_iso_fs" != "ntfs" ]; then + if [ "$VTOY_VHD_NO_WARNING" != "1" ]; then + if [ "$vtoy_iso_fs" != "ntfs" ]; then echo -e "!!! WARNING !!!\n" - echo -e "\nPartition1 ($hiso_iso_fs) is NOT ntfs, the VHD(x) file may not boot normally \n" + echo -e "\nPartition1 ($vtoy_iso_fs) is NOT ntfs, the VHD(x) file may not boot normally \n" echo -e "\nVHD(x) 文件所在分区不是 ntfs 格式, 可能无法正常启动 \n\n" echo -en "\n$VTLANG_ENTER_CONTINUE ..." read vtInputKey @@ -1771,96 +1766,96 @@ function vhd_unsupport_menuentry { common_unsupport_menuentry } -function hisoboot_common_func { +function vtoyboot_common_func { set AltBootPart=0 - set hisosupport=0 + set vtoysupport=0 - vt_get_hiso_type "${1}" hisotype parttype AltBootPart + vt_get_vtoy_type "${1}" vtoytype parttype AltBootPart - if vt_str_begin $hisotype vhd; then - set hisosupport=1 - elif [ "$hisotype" = "raw" ]; then - set hisosupport=1 - elif [ "$hisotype" = "vdi" ]; then - set hisosupport=1 + if vt_str_begin $vtoytype vhd; then + set vtoysupport=1 + elif [ "$vtoytype" = "raw" ]; then + set vtoysupport=1 + elif [ "$vtoytype" = "vdi" ]; then + set vtoysupport=1 fi - if [ $hisosupport -eq 1 ]; then + if [ $vtoysupport -eq 1 ]; then if [ "$grub_platform" = "pc" ]; then if [ "$parttype" = "gpt" -a $AltBootPart -eq 0 ]; then echo "The OS in the vdisk was created in UEFI mode, but current is Legacy BIOS mode." echo "虚拟磁盘内的系统是在UEFI模式下创建的,而当前系统是Legacy BIOS模式,可能无法正常启动。" - hiperiso_pause + ventoy_pause fi else if [ "$parttype" = "mbr" -a $AltBootPart -eq 0 ]; then echo "The OS in the vdisk was created in Legacy BIOS mode, but current is UEFI mode." echo "虚拟磁盘内的系统是在Legacy BIOS模式下创建的,而当前系统是UEFI模式,可能无法正常启动。" - hiperiso_pause + ventoy_pause fi fi vt_img_sector "${1}" vt_raw_chain_data "${1}" - hiperiso_debug_pause + ventoy_debug_pause if [ -n "$vtoy_chain_mem_addr" ]; then if [ "$grub_platform" = "pc" ]; then vt_acpi_param ${vtoy_chain_mem_addr} 512 - linux16 $hiso_path/ipxe.krn ${vtdebug_flag} bios80 sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} + linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} bios80 sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} boot else if vt_check_secureboot_var; then vt_acpi_param ${vtoy_chain_mem_addr} 512 fi - hiperiso_cli_console - chainloader ${hiso_path}/hiperiso_${HISO_EFI_ARCH}.efi sector512 env_param=${hiperiso_env_param} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} + ventoy_cli_console + chainloader ${vtoy_path}/hiperiso_${VTOY_EFI_ARCH}.efi sector512 env_param=${ventoy_env_param} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} boot - hiperiso_gui_console + ventoy_gui_console fi else echo "chain empty failed!" - hiperiso_pause + ventoy_pause fi else - echo "Unsupported hiso type $hisotype" - hiperiso_pause + echo "Unsupported vtoy type $vtoytype" + ventoy_pause fi } -function hiso_common_menuentry { +function vtoy_common_menuentry { vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name if vt_check_password "${vt_chosen_path}"; then return - fi + fi - if [ -n "$hiso_hv_mode" ]; then + if [ -n "$vtoy_hv_mode" ]; then hiperiso_boot "${vt_chosen_path}" return - fi + fi - if hiperiso_vcfg_proc "${vt_chosen_path}"; then + if ventoy_vcfg_proc "${vt_chosen_path}"; then return fi unset vt_vlnk_dst if vt_is_vlnk_name "${vt_chosen_path}"; then - vt_get_vlnk_dst "${hiso_iso_part}${vt_chosen_path}" vt_vlnk_dst + vt_get_vlnk_dst "${vtoy_iso_part}${vt_chosen_path}" vt_vlnk_dst if [ -z "$vt_vlnk_dst" ]; then echo -e "\n### VLNK FILE NOT FOUND ###\n### VLNK 文件不存在 ###\n" - hiperiso_pause + ventoy_pause return fi else - vt_vlnk_dst="${hiso_iso_part}${vt_chosen_path}" + vt_vlnk_dst="${vtoy_iso_part}${vt_chosen_path}" fi - hisoboot_common_func "${vt_vlnk_dst}" + vtoyboot_common_func "${vt_vlnk_dst}" } -function hiso_unsupport_menuentry { +function vtoy_unsupport_menuentry { common_unsupport_menuentry } @@ -1876,9 +1871,9 @@ function only_uefi_tip { read vtInputKey } -function hiperiso_img_easyos { - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit +function ventoy_img_easyos { + 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 easysfs (vtimghd,1)/easy.sfs vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver @@ -1891,10 +1886,10 @@ function hiperiso_img_easyos { done fi - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso + vt_set_boot_opt rdinit=/vtoy/vtoy vt_img_hook_root syslinux_configfile (vtimghd,1)/syslinux.cfg @@ -1904,9 +1899,9 @@ function hiperiso_img_easyos { loopback -d easysfs } -function hiperiso_img_easyos2 { - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit +function ventoy_img_easyos2 { + 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 if [ -e (vtimghd,2)/easyos/easy.sfs ]; then loopback easysfs (vtimghd,2)/easyos/easy.sfs @@ -1925,10 +1920,10 @@ function hiperiso_img_easyos2 { done fi - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso + vt_set_boot_opt rdinit=/vtoy/vtoy vt_img_hook_root vt_limine_menu (vtimghd,1)/limine.cfg vt_sys_menu_mem @@ -1939,14 +1934,14 @@ function hiperiso_img_easyos2 { loopback -d easysfs } -function hiperiso_img_volumio { - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit +function ventoy_img_volumio { + 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 - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso imgpart=/dev/hiperiso2 bootpart=/dev/hiperiso1 + vt_set_boot_opt rdinit=/vtoy/vtoy imgpart=/dev/ventoy2 bootpart=/dev/ventoy1 vt_img_hook_root syslinux_configfile (vtimghd,1)/syslinux.cfg @@ -1955,19 +1950,19 @@ function hiperiso_img_volumio { vt_unset_boot_opt } -function hiperiso_img_openelec { +function ventoy_img_openelec { elec_ver=$1 if [ "$elec_ver" = "LibreELEC" ]; then if vt_strstr "$vt_chosen_name" "x86_64"; then - set hiperiso_busybox_ver=64 + set ventoy_busybox_ver=64 fi fi - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit + 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 $hiso_efi_part/hiperiso/vtloopex.cpio + loopback vtloopex $vtoy_efi_part/ventoy/vtloopex.cpio vt_img_extra_initrd_append (vtloopex)/$elec_ver/vtloopex.tar.xz if [ "$elec_ver" = "LibreELEC" ]; then @@ -1984,10 +1979,10 @@ function hiperiso_img_openelec { fi fi - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso hiperisoos=$elec_ver + vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=$elec_ver vt_img_hook_root set root=(vtimghd,1) @@ -2000,19 +1995,19 @@ function hiperiso_img_openelec { } -function hiperiso_img_freedombox { - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit +function ventoy_img_freedombox { + 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_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 - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso hiperisoos=freedombox + vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=freedombox vt_img_hook_root configfile (vtimghd,1)/boot/grub/grub.cfg @@ -2021,21 +2016,21 @@ function hiperiso_img_freedombox { vt_unset_boot_opt } -function hiperiso_img_paldo { - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit +function ventoy_img_paldo { + 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 - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso hiperisoos=paldo + 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/hiperiso1 rootfstype=vfat + linux (vtimghd,1)/linux-${vtPaldoVer} root=/dev/ventoy1 rootfstype=vfat initrd (vtimghd,1)/initramfs-${vtPaldoVer} boot @@ -2043,23 +2038,23 @@ function hiperiso_img_paldo { vt_unset_boot_opt } -function hiperiso_img_ubos { - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit +function ventoy_img_ubos { + 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_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 - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso hiperisoos=ubos + vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=ubos vt_img_hook_root echo loading file... - linux (vtimghd,2)/vmlinuz-linux root=/dev/hiperiso3 rw + linux (vtimghd,2)/vmlinuz-linux root=/dev/ventoy3 rw initrd (vtimghd,2)/initramfs-linux.img boot @@ -2067,15 +2062,15 @@ function hiperiso_img_ubos { vt_unset_boot_opt } -function hiperiso_img_recalbox { - if [ $hiso_img_max_part_end -GT $vt_chosen_size ]; then +function ventoy_img_recalbox { + if [ $vtoy_img_max_part_end -GT $vt_chosen_size ]; then echo -e "\nPlease extend the img file size before boot it. \n" - hiperiso_pause + ventoy_pause return fi - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit + 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 if [ -e (vtimghd,1)/boot/recalbox ]; then loopback recalbox (vtimghd,1)/boot/recalbox @@ -2085,10 +2080,10 @@ function hiperiso_img_recalbox { fi fi - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso hiperisoos=recalbox + vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=recalbox vt_img_hook_root set root=(vtimghd,1) @@ -2098,14 +2093,14 @@ function hiperiso_img_recalbox { vt_unset_boot_opt } -function hiperiso_img_esysrescue { - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit +function ventoy_img_esysrescue { + 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 - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso hiperisoos=esysrescue + vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=esysrescue vt_img_hook_root set root=(vtimghd,1) @@ -2115,14 +2110,14 @@ function hiperiso_img_esysrescue { vt_unset_boot_opt } -function hiperiso_img_batocera { - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit +function ventoy_img_batocera { + 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 - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso hiperisoos=batocera + vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=batocera vt_img_hook_root set root=(vtimghd,1) @@ -2132,9 +2127,9 @@ function hiperiso_img_batocera { vt_unset_boot_opt } -function hiperiso_img_openwrt { +function ventoy_img_openwrt { if [ -e (vtimghd,2)/lib64 ]; then - set hiperiso_busybox_ver=64 + set ventoy_busybox_ver=64 fi vt_fs_enum_1st_dir (vtimghd,2) /lib/modules/ vt_dir_name @@ -2147,40 +2142,40 @@ function hiperiso_img_openwrt { fi else set openwrt_plugin_need=1 - if [ ! -f ${hiso_iso_part}/hiperiso/hiperiso_openwrt.xz ]; then - hiperiso_gui_console - echo -e "\n hiperiso_openwrt.xz not found. Please refer https://redbearos.org/hiperiso/en/doc_openwrt.html.\n" - echo -e " 未找到 hiperiso_openwrt.xz 文件。请参考 https://redbearos.org/hiperiso/cn/doc_openwrt.html\n" + 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.redbearos.org/hiperiso/en/doc_openwrt.html.\n" + echo -e " 未找到 ventoy_openwrt.xz 文件。请参考 https://www.redbearos.org/hiperiso/cn/doc_openwrt.html\n" echo -en "\n$VTLANG_ENTER_EXIT ..." read vtInputKey - hiperiso_cli_console + ventoy_cli_console return fi fi - if vt_img_check_range "${hiso_iso_part}${vt_chosen_path}"; then - hiperiso_debug_pause + if vt_img_check_range "${vtoy_iso_part}${vt_chosen_path}"; then + ventoy_debug_pause else - hiperiso_gui_console - echo -e "\n IMG file need processed. Please refer https://redbearos.org/hiperiso/en/doc_openwrt.html.\n" - echo -e " 此 IMG 文件必须处理之后才能支持。请参考 https://redbearos.org/hiperiso/cn/doc_openwrt.html\n" + ventoy_gui_console + echo -e "\n IMG file need processed. Please refer https://www.redbearos.org/hiperiso/en/doc_openwrt.html.\n" + echo -e " 此 IMG 文件必须处理之后才能支持。请参考 https://www.redbearos.org/hiperiso/cn/doc_openwrt.html\n" echo -e "\n press ENTER to exit (请按 回车 键返回) ..." read vtInputKey - hiperiso_cli_console + ventoy_cli_console return fi - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit + 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 if [ $openwrt_plugin_need -eq 1 ]; then - if [ -f ${hiso_iso_part}/hiperiso/hiperiso_openwrt.xz ]; then - vt_img_extra_initrd_append ${hiso_iso_part}/hiperiso/hiperiso_openwrt.xz + 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=/hiso/hiso hiperisoos=openwrt + vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=openwrt vt_img_hook_root set root=(vtimghd,1) @@ -2190,14 +2185,14 @@ function hiperiso_img_openwrt { vt_unset_boot_opt } -function hiperiso_img_tails { - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit +function ventoy_img_tails { + 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 - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso live-media=/dev/dm-1 hiperisoos=tails + vt_set_boot_opt rdinit=/vtoy/vtoy live-media=/dev/dm-1 ventoyos=tails vt_img_hook_root set root=(vtimghd,1) @@ -2207,19 +2202,19 @@ function hiperiso_img_tails { vt_unset_boot_opt } -function hiperiso_img_fydeos { +function ventoy_img_fydeos { if [ "$grub_platform" = "pc" ]; then only_uefi_tip return fi - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=64" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit + vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=64" + vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso hiperisoos=fydeos + vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=fydeos vt_img_hook_root set grubdisk=vtimghd @@ -2241,19 +2236,19 @@ function hiperiso_img_fydeos { unset linuxpartB } -function hiperiso_img_cloudready { +function ventoy_img_cloudready { if [ "$grub_platform" = "pc" ]; then only_uefi_tip return fi - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=64" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit + vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=64" + vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso hiperisoos=cloudready + vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=cloudready vt_img_hook_root set grubdisk=vtimghd @@ -2276,14 +2271,14 @@ function hiperiso_img_cloudready { } -function hiperiso_img_fwts { - vt_load_cpio $hiso_path "${vt_chosen_path}" ${hiso_iso_part} "busybox=$hiperiso_busybox_ver" - vt_trailer_cpio ${hiso_iso_part} "${vt_chosen_path}" noinit +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 - hiperiso_debug_pause + ventoy_debug_pause #boot image file - vt_set_boot_opt rdinit=/hiso/hiso hiperisoos=fwts + vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=fwts vt_img_hook_root configfile $prefix/distro/fwts.cfg @@ -2292,7 +2287,7 @@ function hiperiso_img_fwts { vt_unset_boot_opt } -function hiperiso_img_memtest86 { +function ventoy_img_memtest86 { chainloader (vtimghd,1)/efi/boot/BOOTX64.efi boot } @@ -2305,17 +2300,17 @@ function img_unsupport_tip { } function legacy_img_memdisk { - linux16 $hiso_path/memdisk + linux16 $vtoy_path/memdisk echo "Loading img file to memory ..." initrd16 "${1}${2}" - hiperiso_cli_console + ventoy_cli_console boot } function img_common_menuentry { - set hiperiso_compatible=YES - set hiperiso_busybox_ver=32 + set ventoy_compatible=YES + set ventoy_busybox_ver=32 unset LoadIsoEfiDriver vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name @@ -2324,29 +2319,29 @@ function img_common_menuentry { return fi - if [ -n "$hiso_hv_mode" ]; then + if [ -n "$vtoy_hv_mode" ]; then hiperiso_boot "${vt_chosen_path}" return fi - if hiperiso_vcfg_proc "${vt_chosen_path}"; then + if ventoy_vcfg_proc "${vt_chosen_path}"; then return fi if [ "$grub_platform" = "pc" ]; then if vt_check_mode 0 "$vt_chosen_name"; then - legacy_img_memdisk $hiso_iso_part "$vt_chosen_path" + legacy_img_memdisk $vtoy_iso_part "$vt_chosen_path" return fi fi - loopback vtimghd "${hiso_iso_part}${vt_chosen_path}" - vt_img_sector "${hiso_iso_part}${vt_chosen_path}" + 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 - hiperiso_cli_console + ventoy_cli_console vt_push_last_entry set vtback_theme=$theme unset theme @@ -2378,43 +2373,43 @@ function img_common_menuentry { if [ -f (vtimghd,3)/etc/os-release.d/ID ]; then vt_1st_line (vtimghd,3)/etc/os-release.d/ID vt_release_line1 if vt_str_begin "$vt_release_line1" "FydeOS"; then - hiperiso_img_fydeos + ventoy_img_fydeos else - hiperiso_img_cloudready + ventoy_img_cloudready fi elif [ -f (vtimghd,3)/etc/cloudready-release ]; then - hiperiso_img_cloudready + ventoy_img_cloudready elif [ -f (vtimghd,3)/etc/chrome_dev.conf ]; then - hiperiso_img_cloudready + ventoy_img_cloudready fi elif vt_str_begin "$vtImgHd3Label" "fwts-result"; then - hiperiso_img_fwts + ventoy_img_fwts elif vt_str_begin "$vtImgHd1Label" "LAKKA"; then - hiperiso_img_openelec lakka + ventoy_img_openelec lakka elif vt_str_begin "$vtImgHd1Label" "LIBREELEC"; then - hiperiso_img_openelec LibreELEC + ventoy_img_openelec LibreELEC elif vt_str_begin "$vtImgHd1Label" "paldo-live"; then - hiperiso_img_paldo + ventoy_img_paldo elif vt_str_begin "$vtImgHostname" "freedombox"; then - hiperiso_img_freedombox + ventoy_img_freedombox elif vt_str_begin "$vtImgHd1Label" "BATOCERA"; then - hiperiso_img_batocera + ventoy_img_batocera elif vt_str_begin "$vtImgHd1Label" "Tails"; then - hiperiso_img_tails + ventoy_img_tails elif [ "$vtImgHd2Label" = "RECALBOX" -o "$vtImgHd1Label" = "RECALBOX" ]; then - hiperiso_img_recalbox + ventoy_img_recalbox elif [ "$vtImgHd1Label" = "ESYSRESCUE" ]; then - hiperiso_img_esysrescue + ventoy_img_esysrescue elif [ -e (vtimghd,1)/easy.sfs ]; then - hiperiso_img_easyos + ventoy_img_easyos elif [ -d (vtimghd,2)/easyos ]; then - hiperiso_img_easyos2 + ventoy_img_easyos2 elif [ -e (vtimghd,1)/volumio.initrd ]; then - hiperiso_img_volumio + ventoy_img_volumio elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then - hiperiso_img_ubos + ventoy_img_ubos elif [ -f (vtimghd,2)/etc/openwrt_version ]; then - hiperiso_img_openwrt + ventoy_img_openwrt else if [ -f (vtimghd,1)/efi/boot/mt86.png ]; then if [ "$grub_platform" = "pc" ]; then @@ -2423,13 +2418,13 @@ function img_common_menuentry { fi #common chain - vt_linux_chain_data "${hiso_iso_part}${vt_chosen_path}" - hiperiso_acpi_param ${vtoy_chain_mem_addr} 512 + vt_linux_chain_data "${vtoy_iso_part}${vt_chosen_path}" + ventoy_acpi_param ${vtoy_chain_mem_addr} 512 if [ "$grub_platform" = "pc" ]; then - linux16 $hiso_path/ipxe.krn ${vtdebug_flag} sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} + linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} boot else - chainloader ${hiso_path}/hiperiso_${HISO_EFI_ARCH}.efi sector512 env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} + chainloader ${vtoy_path}/hiperiso_${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} boot fi fi @@ -2439,8 +2434,8 @@ function img_common_menuentry { set root=$vtback_root vt_pop_last_entry set theme=$vtback_theme - hiperiso_gui_console - set hiperiso_compatible=NO + ventoy_gui_console + set ventoy_compatible=NO } function img_unsupport_menuentry { @@ -2454,23 +2449,23 @@ function mimg_common_menuentry { return fi - if [ -n "$hiso_hv_mode" ]; then + if [ -n "$vtoy_hv_mode" ]; then hiperiso_boot "${vt_chosen_path}" return fi echo "memdisk mode boot for $vt_chosen_path" echo "" - hiperiso_debug_pause + ventoy_debug_pause if [ "$grub_platform" = "pc" ]; then - legacy_img_memdisk $hiso_iso_part "$vt_chosen_path" + legacy_img_memdisk $vtoy_iso_part "$vt_chosen_path" else - vt_load_img_memdisk "$hiso_iso_part$vt_chosen_path" hiso_img_buf - hiperiso_cli_console - chainloader ${hiso_path}/hiperiso_${HISO_EFI_ARCH}.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${hiso_img_buf_addr}:size:${hiso_img_buf_size} + vt_load_img_memdisk "$vtoy_iso_part$vt_chosen_path" vtoy_img_buf + ventoy_cli_console + chainloader ${vtoy_path}/hiperiso_${VTOY_EFI_ARCH}.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_img_buf_addr}:size:${vtoy_img_buf_size} boot - hiperiso_gui_console + ventoy_gui_console fi } @@ -2482,272 +2477,149 @@ function mimg_common_menuentry { ############################################################# ############################################################# +set VENTOY_VERSION="1.1.16" set HIPERISO_VERSION="1.0.0" - -set HISO_HYPERVISOR_MENU=1 +set HISO_EFI_ARCH=$VTOY_EFI_ARCH #ACPI not compatible with Window7/8, so disable by default -set HISO_PARAM_NO_ACPI=1 +set VTOY_PARAM_NO_ACPI=1 # Default menu display mode, you can change it as you want. # 0: List mode # 1: TreeView mode -set HISO_DEFAULT_MENU_MODE=0 +set VTOY_DEFAULT_MENU_MODE=0 -set HISO_MEM_DISK_STR="[Memdisk]" -set HISO_ISO_RAW_STR="Compatible Mode" -set HISO_GRUB2_MODE_STR="GRUB2 Mode" -set HISO_WIMBOOT_MODE_STR="WIMBOOT Mode" -set HISO_ISO_UEFI_DRV_STR="UEFI FS" +set VTOY_MEM_DISK_STR="[Memdisk]" +set VTOY_ISO_RAW_STR="Compatible Mode" +set VTOY_GRUB2_MODE_STR="GRUB2 Mode" +set VTOY_WIMBOOT_MODE_STR="WIMBOOT Mode" +set VTOY_ISO_UEFI_DRV_STR="UEFI FS" -set HISO_F2_CMD="vt_browser_disk" -set HISO_F4_CMD="hiperiso_localboot" -set HISO_F5_CMD="hiperiso_diagnosis" -set HISO_F6_CMD="hiperiso_ext_menu" -set HISO_HELP_CMD="hiperiso_show_help" -set HISO_CHKSUM_CMD="hiperiso_checksum" -set HISO_HELP_TXT_LANGUAGE="en_US" -set HISO_CHKSUM_FILE_PATH="X" -set HISO_LANG_CMD="hiperiso_language" - -# hiperiso_boot [] -# Replicates hiperiso_cmd_boot (src/grub2/hiperiso_cmd.c:6994). Boots the -# host kernel + QEMU initramfs from the ESP, passing the hiperiso_* -# command-line contract that host/initramfs/init understands. Used by -# the "Hypervisor (KVM + Boot Logging)" secondary-menu option and any -# direct QEMU boot path. -# -# Reads these GRUB env vars (set by the JSON config or menu): -# HISO_TRACE_LEVEL standard|detailed|full|none (default: standard) -# HISO_FALLBACK 0|1 (default: 0) -# HISO_DISPLAY none|gtk|vnc (default: none) -# HISO_VGA none|std|virtio (default: none) -# HISO_GUEST_RAM MB (default: 2048) -# HISO_GUEST_CPUS (default: 2) -# HISO_AUTO_INSTALL, HISO_PERSISTENCE, HISO_DUD, -# HISO_INJECTION, HISO_CONF_REPLACE, HISO_CPU_FEATURES -function hiperiso_boot { - set iso_path="$1" - if [ -z "$iso_path" ]; then - echo "hiperiso_boot: usage: hiperiso_boot []" - return 1 - fi - - # Derive log_dir from ISO basename. GRUB script has no ${var##*/} - # bash pattern; replicate it with regexp. Use --set N:VAR syntax - # (the same form the Ventoy modsrc uses elsewhere in this file) so - # the captured group is bound to a named variable in the same scope - # rather than to the positional $1 in the if-statement branch. - set hiso_base="$iso_path" - if regexp --set 1:hiso_tail '.*/([^/]+)$' "$iso_path" ; then - set hiso_base="$hiso_tail" - fi - set hiso_log_dir="/hiperiso/logs/${hiso_base}/" - - # Defaults for optional HISO_* env vars. Note: GRUB's [ -n X ] and - # [ -z X ] accept a single argument; "&&" is bash-only, so we use - # nested if instead. - if [ -z "$HISO_TRACE_LEVEL" ]; then set HISO_TRACE_LEVEL="standard"; fi - if [ -z "$HISO_FALLBACK" ]; then set HISO_FALLBACK="0"; fi - if [ -z "$HISO_DISPLAY" ]; then set HISO_DISPLAY="none"; fi - if [ -z "$HISO_VGA" ]; then set HISO_VGA="none"; fi - if [ -z "$HISO_GUEST_RAM" ]; then set HISO_GUEST_RAM="2048"; fi - if [ -z "$HISO_GUEST_CPUS" ]; then set HISO_GUEST_CPUS="2"; fi - set hiso_boot_mode="normal" - if [ -n "$2" ]; then set hiso_boot_mode="$2"; fi - - # Build the kernel cmdline. Order matches hiperiso_cmd_boot. - set hiso_cmdline="hiperiso_iso=\"${iso_path}\" hiperiso_log=\"${hiso_log_dir}\" hiperiso_trace_level=\"${HISO_TRACE_LEVEL}\" hiperiso_ram=\"${HISO_GUEST_RAM}\" hiperiso_cpus=\"${HISO_GUEST_CPUS}\" hiperiso_display=\"${HISO_DISPLAY}\" hiperiso_vga=\"${HISO_VGA}\" hiperiso_fallback=\"${HISO_FALLBACK}\"" - - if [ -n "$HISO_AUTO_INSTALL" ]; then - set hiso_cmdline="${hiso_cmdline} hiperiso_auto_install=\"${HISO_AUTO_INSTALL}\"" - fi - if [ -n "$HISO_PERSISTENCE" ]; then - set hiso_cmdline="${hiso_cmdline} hiperiso_persistence=\"${HISO_PERSISTENCE}\"" - fi - if [ -n "$HISO_DUD" ]; then - set hiso_cmdline="${hiso_cmdline} hiperiso_dud=\"${HISO_DUD}\"" - fi - if [ -n "$HISO_INJECTION" ]; then - set hiso_cmdline="${hiso_cmdline} hiperiso_injection=\"${HISO_INJECTION}\"" - fi - if [ -n "$HISO_CONF_REPLACE" ]; then - set hiso_cmdline="${hiso_cmdline} hiperiso_conf_replace=\"${HISO_CONF_REPLACE}\"" - fi - if [ -n "$HISO_SECURE_BOOT" ]; then - if [ "$HISO_SECURE_BOOT" != "0" ]; then - set hiso_cmdline="${hiso_cmdline} hiperiso_secure_boot=\"1\"" - fi - fi - if [ -n "$HISO_TPM" ]; then - if [ "$HISO_TPM" != "0" ]; then - set hiso_cmdline="${hiso_cmdline} hiperiso_tpm=\"1\"" - fi - fi - if [ -n "$HISO_CPU_FEATURES" ]; then - set hiso_cmdline="${hiso_cmdline} hiperiso_cpu_features=\"${HISO_CPU_FEATURES}\"" - fi - if [ -n "$hiso_boot_mode" ]; then - set hiso_cmdline="${hiso_cmdline} hiperiso_boot_mode=\"${hiso_boot_mode}\"" - fi - if [ -n "$HISO_NET_DUMP" ]; then - if [ "$HISO_NET_DUMP" != "0" ]; then - set hiso_cmdline="${hiso_cmdline} hiperiso_net_dump=\"1\"" - fi - fi - - # Hand off to the host kernel + QEMU initramfs. vmlinuz and - # initramfs.cpio.gz live in the same EFI/hiperiso/ directory on the - # ESP. hiso_efi_part is set in this file's earlier setup block. - linux ${hiso_efi_part}/EFI/hiperiso/vmlinuz ${hiso_cmdline} - initrd ${hiso_efi_part}/EFI/hiperiso/initramfs.cpio.gz - boot -} +set VTOY_F2_CMD="vt_browser_disk" +set VTOY_F4_CMD="ventoy_localboot" +set VTOY_F5_CMD="ventoy_diagnosis" +set VTOY_F6_CMD="ventoy_ext_menu" +set VTOY_HELP_CMD="ventoy_show_help" +set VTOY_CHKSUM_CMD="ventoy_checksum" +set VTOY_HELP_TXT_LANGUAGE="en_US" +set VTOY_CHKSUM_FILE_PATH="X" +set VTOY_LANG_CMD="ventoy_language" if [ "$grub_platform" = "pc" ]; then - set HISO_TEXT_MENU_VER="Hiperiso $HIPERISO_VERSION BIOS redbearos.org/hiperiso" + set VTOY_TEXT_MENU_VER="Hiperiso $HIPERISO_VERSION BIOS www.redbearos.org/hiperiso" else if [ "$grub_cpu" = "i386" ]; then - set HISO_EFI_ARCH=ia32 - set HISO_TEXT_MENU_VER="Hiperiso $HIPERISO_VERSION IA32 redbearos.org/hiperiso" + set VTOY_EFI_ARCH=ia32 + set VTOY_TEXT_MENU_VER="Hiperiso $HIPERISO_VERSION IA32 www.redbearos.org/hiperiso" elif [ "$grub_cpu" = "arm64" ]; then - set HISO_EFI_ARCH=aa64 - set HISO_TEXT_MENU_VER="Hiperiso $HIPERISO_VERSION AA64 redbearos.org/hiperiso" + set VTOY_EFI_ARCH=aa64 + set VTOY_TEXT_MENU_VER="Hiperiso $HIPERISO_VERSION AA64 www.redbearos.org/hiperiso" elif [ "$grub_cpu" = "mips64el" ]; then - set HISO_EFI_ARCH=mips - set HISO_TEXT_MENU_VER="Hiperiso $HIPERISO_VERSION MIPS redbearos.org/hiperiso" + set VTOY_EFI_ARCH=mips + set VTOY_TEXT_MENU_VER="Hiperiso $HIPERISO_VERSION MIPS www.redbearos.org/hiperiso" else - set HISO_EFI_ARCH=x64 - set HISO_TEXT_MENU_VER="Hiperiso $HIPERISO_VERSION UEFI redbearos.org/hiperiso" + set VTOY_EFI_ARCH=x64 + set VTOY_TEXT_MENU_VER="Hiperiso $HIPERISO_VERSION UEFI www.redbearos.org/hiperiso" fi fi vt_device $root vtoy_dev -set hiso_dev=$vtoy_dev -if [ "${hiso_dev}" = "tftp" ]; then - set hiso_path=($root) +if [ "$vtoy_dev" = "tftp" ]; then set vtoy_path=($root) for vtid in 0 1 2 3; do - if [ -f (hd$vtid,gpt2)/hiperiso/hiperiso.cpio ]; then - set vtoy_iso_part=(hd$vtid,gpt1) - set vtoy_efi_part=(hd$vtid,gpt2) + if [ -f (hd$vtid,2)/ventoy/ventoy.cpio ]; then + set vtoy_iso_part=(hd$vtid,1) + set vtoy_efi_part=(hd$vtid,2) set vtoydev=hd$vtid - set hiso_iso_part=(hd$vtid,gpt1) - set hiso_efi_part=(hd$vtid,gpt2) - set hisodev=hd$vtid break fi done loadfont ascii - if [ -n "${hiso_efi_part}" ]; then - vt_load_file_to_mem "auto" ${hiso_efi_part}/grub/fonts/unicode.pf2 hiso_font_mem - loadfont mem:${hiso_font_mem_addr}:size:${hiso_font_mem_size} + if [ -n "$vtoy_efi_part" ]; then + vt_load_file_to_mem "auto" $vtoy_efi_part/grub/fonts/unicode.pf2 vtoy_font_mem + loadfont mem:${vtoy_font_mem_addr}:size:${vtoy_font_mem_size} fi - if [ -f ${hiso_iso_part}/hiperiso/hiperiso.json ]; then - set vt_plugin_path=${hiso_iso_part} + if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then + set vt_plugin_path=$vtoy_iso_part else set vt_plugin_path=$prefix vt_load_plugin $vt_plugin_path fi else - if [ "$prefix" = "(hiperisodisk)/grub" ]; then - set hiso_path=(hiperisodisk)/hiperiso - set vtoy_path=(hiperisodisk)/hiperiso + if [ "$prefix" = "(ventoydisk)/grub" ]; then + set vtoy_path=(ventoydisk)/ventoy else - set hiso_path=($root)/hiperiso - set vtoy_path=($root)/hiperiso + set vtoy_path=($root)/ventoy fi - set vtoydev=${hiso_dev} - set hisodev=${hiso_dev} - set vtoy_iso_part=(${hiso_dev},1) - set vtoy_efi_part=(${hiso_dev},2) - set hiso_iso_part=(${hiso_dev},1) - set hiso_efi_part=(${hiso_dev},2) - - vt_load_file_to_mem "auto" $prefix/fonts/unicode.pf2 hiso_font_mem - loadfont mem:${hiso_font_mem_addr}:size:${hiso_font_mem_size} + set vtoydev=$vtoy_dev + set vtoy_iso_part=($vtoy_dev,1) + set vtoy_efi_part=($vtoy_dev,2) + + vt_load_file_to_mem "auto" $prefix/fonts/unicode.pf2 vtoy_font_mem + loadfont mem:${vtoy_font_mem_addr}:size:${vtoy_font_mem_size} set vt_plugin_path=$vtoy_iso_part - set hiso_plugin_path=$hiso_iso_part fi #Load Partition Table vt_load_part_table $vtoydev -# Detect hypervisor boot path. The deployed binary (built from -# vendor/grub2-modsrc.tar.xz) supports this when the ESP contains -# vmlinuz + initramfs.cpio.gz, regardless of which modsrc version is -# running — the trick is the modsrc partition-variable mapping (see -# scripts/package_release.sh). When the user picks an ISO with -# hiso_hv_mode=1 set, the menuentry handlers divert to hiperiso_boot() -# (line 2529) which runs the host kernel + QEMU initramfs instead of -# the Ventoy chainloader path. Auto-enable when the payloads are -# present on the ESP and /dev/kvm is exposed (the initramfs falls -# back to TCG if KVM is missing). Disable with a sentinel file -# /hiperiso/no_hv_mode on the data partition. -if [ -f $hiso_efi_part/EFI/hiperiso/vmlinuz ] \ - && [ -f $hiso_efi_part/EFI/hiperiso/initramfs.cpio.gz ]; then - if [ ! -f $hiso_iso_part/hiperiso/no_hv_mode ]; then - set hiso_hv_mode=1 - fi -fi - #Load menu lang file -hiperiso_load_menu_lang_file +ventoy_load_menu_lang_file #Load Plugin -if [ -f $hiso_iso_part/hiperiso/hiperiso.json ]; then +if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then clear - vt_load_plugin $hiso_iso_part + vt_load_plugin $vtoy_iso_part clear else - vt_check_json_path_case $hiso_iso_part + vt_check_json_path_case $vtoy_iso_part fi #Update Secure Boot Policy vt_update_sb_policy -if [ -n "$HISO_MENU_LANGUAGE" ]; then - vt_init_menu_lang "$HISO_MENU_LANGUAGE" +if [ -n "$VTOY_MENU_LANGUAGE" ]; then + vt_init_menu_lang "$VTOY_MENU_LANGUAGE" else vt_init_menu_lang en_US fi -if [ -n "$HISO_MENU_TIMEOUT" ]; then - set timeout=$HISO_MENU_TIMEOUT +if [ -n "$VTOY_MENU_TIMEOUT" ]; then + set timeout=$VTOY_MENU_TIMEOUT else unset timeout fi -if [ -f $hiso_iso_part/hiperiso/hiperiso_wimboot.img ]; then - vt_load_wimboot $hiso_iso_part/hiperiso/hiperiso_wimboot.img -elif [ -f $hiso_efi_part/hiperiso/hiperiso_wimboot.img ]; then - vt_load_wimboot $hiso_efi_part/hiperiso/hiperiso_wimboot.img +if [ -f $vtoy_iso_part/ventoy/ventoy_wimboot.img ]; then + vt_load_wimboot $vtoy_iso_part/ventoy/ventoy_wimboot.img +elif [ -f $vtoy_efi_part/ventoy/ventoy_wimboot.img ]; then + vt_load_wimboot $vtoy_efi_part/ventoy/ventoy_wimboot.img fi -if [ -f $hiso_iso_part/hiperiso/hiperiso_vhdboot.img ]; then - vt_load_vhdboot $hiso_iso_part/hiperiso/hiperiso_vhdboot.img -elif [ -f $hiso_efi_part/hiperiso/hiperiso_vhdboot.img ]; then - vt_load_vhdboot $hiso_efi_part/hiperiso/hiperiso_vhdboot.img +if [ -f $vtoy_iso_part/ventoy/ventoy_vhdboot.img ]; then + vt_load_vhdboot $vtoy_iso_part/ventoy/ventoy_vhdboot.img +elif [ -f $vtoy_efi_part/ventoy/ventoy_vhdboot.img ]; then + vt_load_vhdboot $vtoy_efi_part/ventoy/ventoy_vhdboot.img fi -if [ $HISO_DEFAULT_MENU_MODE -eq 0 ]; then - set HISO_F3_CMD="vt_dynamic_menu 1 1" +if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then + set VTOY_F3_CMD="vt_dynamic_menu 1 1" else - set HISO_F3_CMD="vt_dynamic_menu 1 0" + set VTOY_F3_CMD="vt_dynamic_menu 1 0" fi terminal_output console -if [ -n "$hiso_gfxmode" ]; then - set gfxmode=$hiso_gfxmode +if [ -n "$vtoy_gfxmode" ]; then + set gfxmode=$vtoy_gfxmode set gfxpayload=keep else set gfxmode=1024x768 @@ -2755,22 +2627,22 @@ else fi -if [ "$hiso_display_mode" = "CLI" ]; then +if [ "$vtoy_display_mode" = "CLI" ]; then terminal_output console -elif [ "$hiso_display_mode" = "serial" ]; then - if [ -n "$hiso_serial_param" ]; then - serial $hiso_serial_param +elif [ "$vtoy_display_mode" = "serial" ]; then + if [ -n "$vtoy_serial_param" ]; then + serial $vtoy_serial_param fi terminal_input serial terminal_output serial -elif [ "$hiso_display_mode" = "serial_console" ]; then - if [ -n "$hiso_serial_param" ]; then - serial $hiso_serial_param +elif [ "$vtoy_display_mode" = "serial_console" ]; then + if [ -n "$vtoy_serial_param" ]; then + serial $vtoy_serial_param fi terminal_input serial console terminal_output serial console else - if [ "$hiso_gfxmode" = "max" ]; then + if [ "$vtoy_gfxmode" = "max" ]; then set gfxmode=1024x768 terminal_output gfxterm @@ -2779,14 +2651,16 @@ else terminal_output console set gfxmode=$vtCurMode terminal_output gfxterm - elif [ "$hiso_res_fit" = "1" ]; then + elif [ "$vtoy_res_fit" = "1" ]; then terminal_output gfxterm fi - if [ -n "$hiso_theme" ]; then + if [ -n "$vtoy_theme" ]; then vt_set_theme - else + elif [ -f $prefix/themes/hiperiso/theme.txt ]; then set theme=$prefix/themes/hiperiso/theme.txt + elif [ -f $prefix/themes/ventoy/theme.txt ]; then + set theme=$prefix/themes/ventoy/theme.txt fi terminal_output gfxterm fi @@ -2796,27 +2670,27 @@ if [ "$grub_platform" = "efi" ]; then # terminal_input --append mouse fi -if [ -n "$HISO_DEFAULT_KBD_LAYOUT" ]; then - set_keyboard_layout "$HISO_DEFAULT_KBD_LAYOUT" +if [ -n "$VTOY_DEFAULT_KBD_LAYOUT" ]; then + set_keyboard_layout "$VTOY_DEFAULT_KBD_LAYOUT" fi -if [ -n "$HISO_PLUGIN_PATH_CASE_MISMATCH" ]; then +if [ -n "$VTOY_PLUGIN_PATH_CASE_MISMATCH" ]; then clear - echo "$HISO_PLUGIN_PATH_CASE_MISMATCH" - echo -e "\n\nPath case does not match! hiperiso directory and hiperiso.json MUST be all lowercase!" - echo -e "\n路径大小写不匹配!hiperiso 目录和 hiperiso.json 文件的名字必须是全部小写,请修正!" + echo "$VTOY_PLUGIN_PATH_CASE_MISMATCH" + echo -e "\n\nPath case does not match! ventoy directory and ventoy.json MUST be all lowercase!" + echo -e "\n路径大小写不匹配!ventoy 目录和 ventoy.json 文件的名字必须是全部小写,请修正!" echo -e "\n\npress ENTER to continue (请按回车键继续) ..." read vtInputKey fi -if [ -n "$HISO_PLUGIN_SYNTAX_ERROR" ]; then +if [ -n "$VTOY_PLUGIN_SYNTAX_ERROR" ]; then clear - if [ -n "$HISO_PLUGIN_ENCODE_ERROR" ]; then - echo -e "\n Encoding type for hiperiso.json is not supported, please convert to UTF-8.\n" - echo -e " hiperiso.json 文件编码格式不支持,请转换为 UTF-8 编码格式!\n" + if [ -n "$VTOY_PLUGIN_ENCODE_ERROR" ]; then + echo -e "\n Encoding type for ventoy.json is not supported, please convert to UTF-8.\n" + echo -e " ventoy.json 文件编码格式不支持,请转换为 UTF-8 编码格式!\n" else - echo -e "\n Syntax error detected in hiperiso.json, please check! \n" - echo -e " hiperiso.json 文件中有语法错误,所有配置都不会生效,请检查!\n" + echo -e "\n Syntax error detected in ventoy.json, please check! \n" + echo -e " ventoy.json 文件中有语法错误,所有配置都不会生效,请检查!\n" fi echo -e "\n press ENTER to continue (请按 回车 键继续) ..." @@ -2824,11 +2698,11 @@ if [ -n "$HISO_PLUGIN_SYNTAX_ERROR" ]; then fi -for vtTFile in hiperiso.json hiperiso_grub.cfg; do - if [ -f $hiso_efi_part/hiperiso/$vtTFile ]; then +for vtTFile in ventoy.json ventoy_grub.cfg; do + if [ -f $vtoy_efi_part/ventoy/$vtTFile ]; then clear echo -e "\n You need to put $vtTFile in the 1st partition which hold the ISO files.\n" - echo -e " $vtTFile 放错分区了,请放到镜像分区里的 hiperiso 目录下(此目录需要手动创建)!\n" + echo -e " $vtTFile 放错分区了,请放到镜像分区里的 ventoy 目录下(此目录需要手动创建)!\n" echo -e "\n press ENTER to continue (请按 回车 键继续) ..." read vtInputKey fi @@ -2841,48 +2715,47 @@ vt_clear_key export theme export gfxmode export gfxpayload -export hisodev -export hiso_path +export vtoydev +export vtoy_path export vtdebug_flag -export hiso_iso_fs -export hiso_iso_part -export hiso_efi_part -export HIPERISO_VERSION -export HISO_CUR_VIDEO_MODE -export HISO_EFI_ARCH -export HISO_MEM_DISK_STR -export HISO_ISO_RAW_STR -export HISO_GRUB2_MODE_STR -export HISO_WIMBOOT_MODE_STR -export HISO_ISO_UEFI_DRV_STR -export HISO_F2_CMD -export HISO_F4_CMD -export HISO_F5_CMD -export HISO_F6_CMD -export HISO_HELP_CMD -export HISO_CHKSUM_CMD -export HISO_HELP_TXT_LANGUAGE -export HISO_CHKSUM_FILE_PATH -export HISO_LANG_CMD -export hiso_hv_mode +export vtoy_iso_fs +export vtoy_iso_part +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 +export VTOY_F2_CMD +export VTOY_F4_CMD +export VTOY_F5_CMD +export VTOY_F6_CMD +export VTOY_HELP_CMD +export VTOY_CHKSUM_CMD +export VTOY_HELP_TXT_LANGUAGE +export VTOY_CHKSUM_FILE_PATH +export VTOY_LANG_CMD #colect all image files (iso files) -set hiperiso_img_count=0 -vt_list_img $hiso_iso_part hiperiso_img_count +set ventoy_img_count=0 +vt_list_img $vtoy_iso_part ventoy_img_count #Main menu -if [ $hiperiso_img_count -gt 0 ]; then - if [ $HISO_DEFAULT_MENU_MODE -eq 0 ]; then +if [ $ventoy_img_count -gt 0 ]; then + if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then vt_dynamic_menu 0 0 else vt_dynamic_menu 0 1 fi else - if [ -n "$HISO_NO_ISO_TIP" ]; then - NO_ISO_MENU="No ISO or supported IMG files found, $HISO_NO_ISO_TIP" - elif [ -n "$HISO_DEFAULT_SEARCH_ROOT" ]; then - NO_ISO_MENU="No ISO or supported IMG files found, please check HISO_DEFAULT_SEARCH_ROOT" + if [ -n "$VTOY_NO_ISO_TIP" ]; then + NO_ISO_MENU="No ISO or supported IMG files found, $VTOY_NO_ISO_TIP" + elif [ -n "$VTOY_DEFAULT_SEARCH_ROOT" ]; then + NO_ISO_MENU="No ISO or supported IMG files found, please check VTOY_DEFAULT_SEARCH_ROOT" else NO_ISO_MENU="No ISO or supported IMG files found" fi @@ -2893,15 +2766,15 @@ else fi -#special HISO_DEFAULT_IMAGE process -if [ -n "$HISO_DEFAULT_IMAGE" ]; then - if regexp --set 1:vtHotkey --set 2:vtDefault "(F[2-9])>(.*)" "$HISO_DEFAULT_IMAGE"; then +#special VTOY_DEFAULT_IMAGE process +if [ -n "$VTOY_DEFAULT_IMAGE" ]; then + if regexp --set 1:vtHotkey --set 2:vtDefault "(F[2-9])>(.*)" "$VTOY_DEFAULT_IMAGE"; then set default="$vtDefault" - if [ -z "$HISO_MENU_TIMEOUT" ]; then + if [ -z "$VTOY_MENU_TIMEOUT" ]; then set timeout=0 else - set timeout=$HISO_MENU_TIMEOUT + set timeout=$VTOY_MENU_TIMEOUT fi export timeout @@ -2913,11 +2786,11 @@ if [ -n "$HISO_DEFAULT_IMAGE" ]; then unset timeout vt_browser_disk elif [ "$vtHotkey" = "F4" ]; then - hiperiso_localboot + ventoy_localboot elif [ "$vtHotkey" = "F5" ]; then - hiperiso_diagnosis + ventoy_diagnosis elif [ "$vtHotkey" = "F6" ]; then - hiperiso_ext_menu + ventoy_ext_menu fi vt_fn_mutex_lock 0 @@ -2926,4 +2799,54 @@ if [ -n "$HISO_DEFAULT_IMAGE" ]; then unset default fi fi +# hiperiso_boot [] +# Hiperiso hypervisor boot path: bypass the chain EFI entirely. +# Loads the host kernel + QEMU initramfs from the ESP, then transfers +# control to the in-kvm QEMU initramfs which boots the ISO inside a +# KVM-accelerated guest. This gives us full boot tracing without +# modifying the ISO. +function hiperiso_boot { + set iso_path="$1" + if [ -z "$iso_path" ]; then + echo "hiperiso_boot: usage: hiperiso_boot []" + return 1 + fi + + # Derive log_dir from ISO basename. + set hiso_base="$iso_path" + if regexp --set 1:hiso_tail '.*/([^/]+)$' "$iso_path" ; then + set hiso_base="$hiso_tail" + fi + set hiso_log_dir="/hiperiso/logs/${hiso_base}/" + + # Defaults for optional env vars. + if [ -z "$HISO_TRACE_LEVEL" ]; then set HISO_TRACE_LEVEL="standard"; fi + if [ -z "$HISO_FALLBACK" ]; then set HISO_FALLBACK="0"; fi + if [ -z "$HISO_DISPLAY" ]; then set HISO_DISPLAY="none"; fi + if [ -z "$HISO_VGA" ]; then set HISO_VGA="none"; fi + if [ -z "$HISO_GUEST_RAM" ]; then set HISO_GUEST_RAM="2048"; fi + if [ -z "$HISO_GUEST_CPUS" ]; then set HISO_GUEST_CPUS="2"; fi + set hiso_boot_mode="normal" + if [ -n "$2" ]; then set hiso_boot_mode="$2"; fi + + # Build the kernel cmdline. + set hiso_cmdline="hiperiso_iso=\"${iso_path}\" hiperiso_log=\"${hiso_log_dir}\" hiperiso_trace_level=\"${HISO_TRACE_LEVEL}\" hiperiso_ram=\"${HISO_GUEST_RAM}\" hiperiso_cpus=\"${HISO_GUEST_CPUS}\" hiperiso_display=\"${HISO_DISPLAY}\" hiperiso_vga=\"${HISO_VGA}\" hiperiso_fallback=\"${HISO_FALLBACK}\" hiperiso_boot_mode=\"${hiso_boot_mode}\" console=tty0 console=ttyS0,115200 earlyprintk=efi,keep ignore_loglevel" + + # Hand off to the host kernel + QEMU initramfs from the ESP. + linux ${vtoy_efi_part}/EFI/hiperiso/vmlinuz ${hiso_cmdline} + initrd ${vtoy_efi_part}/EFI/hiperiso/initramfs.cpio.gz + boot +} + +# Detect hypervisor boot path. Auto-activate when the ESP contains +# vmlinuz + initramfs.cpio.gz (always true after build_all.sh). Disable +# with a sentinel file /hiperiso/no_hv_mode on the data partition. +if [ -f $vtoy_efi_part/EFI/hiperiso/vmlinuz ]; then + if [ -f $vtoy_efi_part/EFI/hiperiso/initramfs.cpio.gz ]; then + if [ ! -f $vtoy_iso_part/hiperiso/no_hv_mode ]; then + set vtoy_hv_mode=1 + fi + fi +fi +