diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c index 820e94f7..ae831cff 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c @@ -7039,6 +7039,7 @@ static cmd_para ventoy_cmds[] = { "vt_cmp_checksum", ventoy_cmd_cmp_checksum, 0, NULL, "", "", NULL }, { "vt_push_menu_lang", ventoy_cmd_push_menulang, 0, NULL, "", "", NULL }, { "vt_pop_menu_lang", ventoy_cmd_pop_menulang, 0, NULL, "", "", NULL }, + { "vt_linux_initrd", ventoy_cmd_linux_initrd, 0, NULL, "", "", NULL }, }; diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h index e696eafa..832ac951 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h @@ -37,6 +37,7 @@ #define VTOY_SIZE_4MB (4 * 1024 * 1024) #define VTOY_SIZE_512KB (512 * 1024) #define VTOY_SIZE_1KB 1024 +#define VTOY_SIZE_4KB 4096 #define VTOY_SIZE_32KB (32 * 1024) #define VTOY_SIZE_128KB (128 * 1024) @@ -662,6 +663,7 @@ grub_uint32_t ventoy_get_iso_boot_catlog(grub_file_t file); int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector); grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args); +grub_err_t ventoy_cmd_linux_initrd(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_linux_limine_menu(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args); @@ -1279,6 +1281,7 @@ typedef struct systemd_menu_ctx { char *dev; char *buf; + const char *initrd_cmd; int pos; int len; }systemd_menu_ctx; diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c index 93ebeb92..3777e08f 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c @@ -1867,7 +1867,7 @@ static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirh ctx->pos = oldpos; goto out; } - vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Downloading kernel ...\"\n linux %s ", tag); + vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Loading kernel ...\"\n linux %s ", tag); /* kernel options */ grub_memcpy(filebuf, bkbuf, file->size); @@ -1876,7 +1876,7 @@ static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirh /* initrd xxx xxx xxx */ - vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Downloading initrd ...\"\n initrd "); + vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Loading initrd ...\"\n %s ", ctx->initrd_cmd); grub_memcpy(filebuf, bkbuf, file->size); tag = ventoy_systemd_conf_tag(filebuf, "initrd", 1); while (tag) @@ -1893,6 +1893,34 @@ out: return 0; } +grub_err_t ventoy_cmd_linux_initrd(grub_extcmd_context_t ctxt, int argc, char **args) +{ + int i; + int pos = 0; + char *buf = NULL; + + (void)ctxt; + + buf = (char *)grub_malloc(VTOY_SIZE_4KB); + if (!buf) + { + return 1; + } + + pos += grub_snprintf(buf + pos, VTOY_SIZE_4KB - pos, "initrd mem:%s:size:%s", + grub_env_get("ventoy_cpio_addr"), grub_env_get("ventoy_cpio_size")); + + for (i = 0; i < argc; i++) + { + pos += grub_snprintf(buf + pos, VTOY_SIZE_4KB - pos, " newc:initrd%03d:%s", i + 1, args[i]); + } + + grub_script_execute_sourcecode(buf); + grub_free(buf); + + return 0; +} + grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args) { static char *buf = NULL; @@ -1936,6 +1964,7 @@ grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, c ctx.dev = args[0]; ctx.buf = buf; + ctx.initrd_cmd = args[2] ? args[2] : "initrd"; ctx.pos = 0; ctx.len = VTOY_LINUX_SYSTEMD_MENU_MAX_BUF; fs->fs_dir(dev, "/loader/entries", ventoy_systemd_conf_hook, &ctx); diff --git a/IMG/cpio/ventoy/ventoy_chain.sh b/IMG/cpio/ventoy/ventoy_chain.sh index cecdd0ae..35f670e3 100644 --- a/IMG/cpio/ventoy/ventoy_chain.sh +++ b/IMG/cpio/ventoy/ventoy_chain.sh @@ -177,6 +177,8 @@ ventoy_get_os_type() { echo 'deepin'; return elif $GREP -q 'chinauos' /etc/os-release; then echo 'deepin'; return + elif $GREP -qi 'aerynos' /etc/os-release; then + echo 'rhel7'; return fi fi diff --git a/INSTALL/grub/grub.cfg b/INSTALL/grub/grub.cfg index 613630ff..9534333e 100644 --- a/INSTALL/grub/grub.cfg +++ b/INSTALL/grub/grub.cfg @@ -70,6 +70,12 @@ function ventoy_acpi_param { fi } +function vt_vcfg_pre_proc { + 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 ventoy_vcfg_proc { if vt_check_custom_boot "${1}" vt_vcfg; then set vtoy_chosen_path="${1}" @@ -422,6 +428,16 @@ function distro_specify_initrd_file_phase2 { vt_linux_specify_initrd_file /initramfs-linux.img elif [ -f (loop)/boot/isolinux/initrd.gz ]; then vt_linux_specify_initrd_file /boot/isolinux/initrd.gz + elif vt_str_begin "$vt_volume_id" "AERYNOS"; then + vt_vcfg_pre_proc + + loopback va "${vtoy_iso_part}${vt_chosen_path}" + loopback vb (va)/EFI/Boot/efiboot.img + + set root=(vb) + vt_systemd_menu (vb) vt_sys_menu_mem vt_linux_initrd + configfile "mem:${vt_sys_menu_mem_addr}:size:${vt_sys_menu_mem_size}" + fi }