mirror of https://github.com/ventoy/Ventoy.git
Support Lenovo EasyStartup
This commit is contained in:
parent
112c557428
commit
05e208ea2a
|
@ -4970,6 +4970,7 @@ static cmd_para ventoy_cmds[] =
|
||||||
{ "vt_push_pager", ventoy_cmd_push_pager, 0, NULL, "", "", NULL },
|
{ "vt_push_pager", ventoy_cmd_push_pager, 0, NULL, "", "", NULL },
|
||||||
{ "vt_pop_pager", ventoy_cmd_pop_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_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)
|
int ventoy_register_all_cmd(void)
|
||||||
|
|
|
@ -568,6 +568,7 @@ grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc,
|
||||||
grub_err_t ventoy_cmd_initrd_count(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);
|
||||||
grub_err_t ventoy_cmd_valid_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_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_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_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_err_t ventoy_cmd_trailer_cpio(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
|
|
||||||
GRUB_MOD_LICENSE ("GPLv3+");
|
GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
|
|
||||||
|
#define VTOY_APPEND_EXT_SIZE 4096
|
||||||
|
static int g_append_ext_sector = 0;
|
||||||
|
|
||||||
char * ventoy_get_line(char *start)
|
char * ventoy_get_line(char *start)
|
||||||
{
|
{
|
||||||
if (start == NULL)
|
if (start == NULL)
|
||||||
|
@ -658,6 +661,11 @@ static grub_uint32_t ventoy_linux_get_virt_chunk_count(void)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_append_ext_sector > 0)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,6 +680,11 @@ static grub_uint32_t ventoy_linux_get_virt_chunk_size(void)
|
||||||
size += sizeof(ventoy_virt_chunk) + g_conf_replace_new_len_align;
|
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;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,6 +740,27 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
|
||||||
cur++;
|
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)
|
if (g_conf_replace_offset > 0)
|
||||||
{
|
{
|
||||||
cpio_secs = g_conf_replace_new_len_align / 2048;
|
cpio_secs = g_conf_replace_new_len_align / 2048;
|
||||||
|
@ -1119,6 +1153,24 @@ grub_err_t ventoy_cmd_skip_svd(grub_extcmd_context_t ctxt, int argc, char **args
|
||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
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)
|
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
#!/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
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/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
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/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 $*
|
|
@ -58,6 +58,12 @@ ventoy_get_os_type() {
|
||||||
|
|
||||||
# rhel6/CentOS6 and all other distributions based on them
|
# rhel6/CentOS6 and all other distributions based on them
|
||||||
elif $GREP -q 'el6' /proc/version; then
|
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
|
echo 'rhel6'; return
|
||||||
|
|
||||||
# rhel7/CentOS7/rhel8/CentOS8 and all other distributions based on them
|
# rhel7/CentOS7/rhel8/CentOS8 and all other distributions based on them
|
||||||
|
|
|
@ -761,6 +761,8 @@ function ventoy_reset_nojoliet {
|
||||||
else
|
else
|
||||||
vt_iso9660_nojoliet 0
|
vt_iso9660_nojoliet 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
vt_append_extra_sector 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function uefi_iso_menu_func {
|
function uefi_iso_menu_func {
|
||||||
|
@ -787,6 +789,12 @@ function uefi_iso_menu_func {
|
||||||
else
|
else
|
||||||
set ventoy_fs_probe=iso9660
|
set ventoy_fs_probe=iso9660
|
||||||
ventoy_reset_nojoliet
|
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
|
fi
|
||||||
|
|
||||||
loopback loop "${1}${chosen_path}"
|
loopback loop "${1}${chosen_path}"
|
||||||
|
|
Loading…
Reference in New Issue