{ "vt_push_pager", ventoy_cmd_push_pager, 0, NULL, "", "", NULL },
{ "vt_pop_pager", ventoy_cmd_pop_pager, 0, NULL, "", "", NULL },
{ "vt_check_json_path_case", ventoy_cmd_chk_json_pathcase, 0, NULL, "", "", NULL },
+ { "vt_append_extra_sector", ventoy_cmd_append_ext_sector, 0, NULL, "", "", NULL },
};
int ventoy_register_all_cmd(void)
grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_valid_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args);
+grub_err_t ventoy_cmd_append_ext_sector(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_skip_svd(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_cpio_busybox_64(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_trailer_cpio(grub_extcmd_context_t ctxt, int argc, char **args);
GRUB_MOD_LICENSE ("GPLv3+");
+#define VTOY_APPEND_EXT_SIZE 4096
+static int g_append_ext_sector = 0;
+
char * ventoy_get_line(char *start)
{
if (start == NULL)
count++;
}
+ if (g_append_ext_sector > 0)
+ {
+ count++;
+ }
+
return count;
}
{
size += sizeof(ventoy_virt_chunk) + g_conf_replace_new_len_align;
}
+
+ if (g_append_ext_sector > 0)
+ {
+ size += sizeof(ventoy_virt_chunk) + VTOY_APPEND_EXT_SIZE;
+ }
return size;
}
cur++;
}
+ /* Lenovo EasyStartup need an addional sector for boundary check */
+ if (g_append_ext_sector > 0)
+ {
+ cpio_secs = VTOY_APPEND_EXT_SIZE / 2048;
+
+ cur->mem_sector_start = sector;
+ cur->mem_sector_end = cur->mem_sector_start + cpio_secs;
+ cur->mem_sector_offset = offset;
+ cur->remap_sector_start = 0;
+ cur->remap_sector_end = 0;
+ cur->org_sector_start = 0;
+
+ grub_memset(override + offset, 0, VTOY_APPEND_EXT_SIZE);
+
+ chain->virt_img_size_in_bytes += VTOY_APPEND_EXT_SIZE;
+
+ offset += VTOY_APPEND_EXT_SIZE;
+ sector += cpio_secs;
+ cur++;
+ }
+
if (g_conf_replace_offset > 0)
{
cpio_secs = g_conf_replace_new_len_align / 2048;
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
+grub_err_t ventoy_cmd_append_ext_sector(grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ (void)ctxt;
+ (void)argc;
+ (void)args;
+
+ if (args[0][0] == '1')
+ {
+ g_append_ext_sector = 1;
+ }
+ else
+ {
+ g_append_ext_sector = 0;
+ }
+
+ VENTOY_CMD_RETURN(GRUB_ERR_NONE);
+}
+
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args)
{
int i;
--- /dev/null
+#!/ventoy/busybox/sh
+#************************************************************************************
+# Copyright (c) 2021, longpanda <admin@ventoy.net>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+#************************************************************************************
+
+. /ventoy/hook/ventoy-hook-lib.sh
+
+VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
+
+get_rhel_ver() {
+ if uname -m | grep -q '64'; then
+ machine='_X64'
+ fi
+
+ if grep -q '6[.]1' /etc/redhat-release; then
+ echo "RHAS6U1$machine"; return
+ fi
+
+ echo "RHAS6U1$machine"
+}
+
+install_dm_mod_ko() {
+ # dump iso file location
+ vtoydm -i -f $VTOY_PATH/ventoy_image_map -d ${vtdiskname} > $VTOY_PATH/iso_file_list
+
+ sysver=$(get_rhel_ver)
+ vtlog "sysver=$sysver"
+
+ LINE=$(grep "$sysver" -n -m1 $VTOY_PATH/iso_file_list | awk -F: '{print $1}')
+ vtlog "LINE=$LINE"
+
+ LINE=$(sed -n "$LINE,\$p" $VTOY_PATH/iso_file_list | grep -m1 'initrd.img')
+ vtlog "LINE=$LINE"
+
+ sector=$(echo $LINE | $AWK '{print $(NF-1)}')
+ length=$(echo $LINE | $AWK '{print $NF}')
+ vtlog "sector=$sector length=$length"
+
+ mkdir xxx
+ vtoydm -e -f $VTOY_PATH/ventoy_image_map -d ${vtdiskname} -s $sector -l $length -o ./xxx.img
+
+ cd xxx/
+ zcat ../xxx.img | cpio -idmu
+ ko=$(find -name dm-mod.ko*)
+ vtlog "ko=$ko ..."
+ insmod $ko
+
+ cd ../
+ rm -f xxx.img
+ rm -rf xxx
+}
+
+vtdiskname=$(get_ventoy_disk_name)
+vtlog "vtdiskname=$vtdiskname ..."
+if [ "$vtdiskname" = "unknown" ]; then
+ exit 0
+fi
+
+if grep -q 'device-mapper' /proc/devices; then
+ vtlog "device-mapper module check ko"
+else
+ install_dm_mod_ko
+fi
+
+ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
+
+ln -s /dev/dm-0 /dev/root
+
+PATH=$VTPATH_OLD
--- /dev/null
+#!/ventoy/busybox/sh
+#************************************************************************************
+# Copyright (c) 2021, longpanda <admin@ventoy.net>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+#************************************************************************************
+
+. $VTOY_PATH/hook/ventoy-os-lib.sh
+
+$SED "s#^CDROM=.*#CDROM=/dev/dm-0#" -i /init
+$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/easystartup/ventoy-initqueue.sh /initqueue/ventoy.sh
--- /dev/null
+#!/ventoy/busybox/sh
+#************************************************************************************
+# Copyright (c) 2021, longpanda <admin@ventoy.net>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+#************************************************************************************
+
+/ventoy/busybox/sh /ventoy/hook/easystartup/disk_hook.sh $*
# rhel6/CentOS6 and all other distributions based on them
elif $GREP -q 'el6' /proc/version; then
+ if [ -f /sbin/detectcd ]; then
+ if $GREP -q -i 'LENOVO-EasyStartup' /sbin/detectcd; then
+ echo 'easystartup'; return
+ fi
+ fi
+
echo 'rhel6'; return
# rhel7/CentOS7/rhel8/CentOS8 and all other distributions based on them
else
vt_iso9660_nojoliet 0
fi
+
+ vt_append_extra_sector 0
}
function uefi_iso_menu_func {
else
set ventoy_fs_probe=iso9660
ventoy_reset_nojoliet
+
+ # Lenovo EasyStartup need an addional sector for boundary check
+ if vt_str_begin "$vt_volume_id" "EasyStartup"; then
+ vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}"
+ vt_append_extra_sector 1
+ fi
fi
loopback loop "${1}${chosen_path}"