Compare commits

...

20 Commits

Author SHA1 Message Date
longpanda
2dafe75509 Fix the boot issue for TrueNAS Scale. (#3069)
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-03-03 14:42:44 +08:00
longpanda
6fbc08cfcb Only for VirtualBox.
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-28 14:58:36 +08:00
longpanda
6034b25cba Don't force to use max resolution for VMware/VirtualBox. (#3140) 2025-02-28 14:49:40 +08:00
longpanda
c5fd64d21c Support TrueNAS Scale (Linux) distro. (#3069 #3137)
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-26 23:25:27 +08:00
longpanda
32fac72b5b 1.1.05
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-24 19:29:46 +08:00
longpanda
022322c8fa Fix the resolution issue when boot Windows/WinPE in UEFI mode. 2025-02-24 19:17:19 +08:00
longpanda
96f11252d9 support devuan in Legacy BIOS mode. 2025-02-24 19:16:31 +08:00
longpanda
004ad27e0d 1.1.04 release
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-22 11:27:31 +08:00
longpanda
9a8dc42d93 Fix the issue introduced in LinuxGUI version. (#3128) 2025-02-22 11:27:18 +08:00
longpanda
6166a813ea 1.1.03
Some checks are pending
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-21 18:14:18 +08:00
longpanda
786a9ec678 Update Ventoy2Disk.exe
Some checks are pending
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-21 13:00:15 +08:00
longpanda
0600576c78 Update Linux GUI type condition 2025-02-21 13:00:01 +08:00
longpanda
72b722c86c Fix the boot issue for latest TinyCore Linux. 2025-02-21 12:59:33 +08:00
longpanda
bea5607ea5 Fix the boot issue for pfSense 2.7.x (#2775)
Some checks are pending
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-21 00:29:38 +08:00
longpanda
b3c2bcf58f Fix the issue that SLES/OpenSUSE can not boot after install. (#3125) 2025-02-20 22:07:28 +08:00
longpanda
4e8d8b2e19 Fix Windows 11 error 0x80070001. (#3010 #3029 #3105)
Some checks are pending
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-19 23:49:03 +08:00
longpanda
60d88cb7b1 1.1.02 release
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-12 23:01:35 +08:00
longpanda
f7e6bbc70c Fix the "Unsupported vtoy type unknown" error when boot a VDI file created by VirtualBox 7.x 2025-02-12 23:00:27 +08:00
longpanda
ee994a0569 github ai version update
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-10 21:46:39 +08:00
longpanda
966ed21de7 1.1.01
Some checks are pending
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-10 20:14:46 +08:00
59 changed files with 448 additions and 403 deletions

View File

@ -15,23 +15,23 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Run docker compose up - name: Run docker compose up
run: docker compose up run: docker compose up
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
with: with:
name: ventoy-windows name: ventoy-windows
path: INSTALL/ventoy-*windows* path: INSTALL/ventoy-*windows*
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
with: with:
name: ventoy-linux name: ventoy-linux
path: INSTALL/ventoy-*linux* path: INSTALL/ventoy-*linux*
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
with: with:
name: ventoy-livecd name: ventoy-livecd
path: INSTALL/ventoy-*livecd* path: INSTALL/ventoy-*livecd*
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
with: with:
name: SHA256SUM name: SHA256SUM
path: INSTALL/sha256.txt path: INSTALL/sha256.txt
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
with: with:
name: xxx-build-log name: xxx-build-log
path: DOC/build.log path: DOC/build.log

View File

@ -861,7 +861,8 @@ typedef struct vhd_footer_t
grub_uint8_t savedst; // Saved state grub_uint8_t savedst; // Saved state
}vhd_footer_t; }vhd_footer_t;
#define VDI_IMAGE_FILE_INFO "<<< Oracle VM VirtualBox Disk Image >>>\n" #define VDI_IMAGE_FILE_INFO "<<< Oracle VM VirtualBox Disk Image >>>\n"
#define VDI_IMAGE_FILE_INFO2 "<<< Oracle VirtualBox Disk Image >>>\n"
/** Image signature. */ /** Image signature. */
#define VDI_IMAGE_SIGNATURE (0xbeda107f) #define VDI_IMAGE_SIGNATURE (0xbeda107f)

View File

@ -536,12 +536,25 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
{ {
grub_file_seek(file, 0); grub_file_seek(file, 0);
grub_file_read(file, &vdihdr, sizeof(vdihdr)); grub_file_read(file, &vdihdr, sizeof(vdihdr));
if (vdihdr.u32Signature == VDI_IMAGE_SIGNATURE && if (vdihdr.u32Signature == VDI_IMAGE_SIGNATURE)
grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO, grub_strlen(VDI_IMAGE_FILE_INFO)) == 0)
{ {
offset = 2 * 1048576;
g_img_trim_head_secnum = offset / 512;
grub_snprintf(type, sizeof(type), "vdi"); grub_snprintf(type, sizeof(type), "vdi");
if (grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO, grub_strlen(VDI_IMAGE_FILE_INFO)) == 0)
{
offset = 2 * 1048576;
g_img_trim_head_secnum = offset / 512;
debug("VDI V1\n");
}
else if (grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO2, grub_strlen(VDI_IMAGE_FILE_INFO2)) == 0)
{
offset = 2 * 1048576;
g_img_trim_head_secnum = offset / 512;
debug("VDI V2\n");
}
else
{
debug("invalid file info <%s>\n", vdihdr.szFileInfo);
}
} }
else else
{ {
@ -568,7 +581,7 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
if (gpt->MBR.Byte55 != 0x55 || gpt->MBR.ByteAA != 0xAA) if (gpt->MBR.Byte55 != 0x55 || gpt->MBR.ByteAA != 0xAA)
{ {
grub_env_set(args[1], "unknown"); grub_env_set(args[1], "unknown");
debug("invalid mbr signature: 0x%x 0x%x\n", gpt->MBR.Byte55, gpt->MBR.ByteAA); debug("invalid mbr signature: 0x%x 0x%x offset=%d\n", gpt->MBR.Byte55, gpt->MBR.ByteAA, offset);
goto end; goto end;
} }

View File

@ -0,0 +1,43 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, 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
if is_ventoy_hook_finished; then
exit 0
fi
vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
PATH=$VTPATH_OLD
exit 0
fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
PATH=$VTPATH_OLD
set_ventoy_hook_finish

View File

@ -0,0 +1,21 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, 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/>.
#
#************************************************************************************
$SED "/Mount.*cdrom/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/devuan-disk.sh" -i /init

View File

@ -0,0 +1,25 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, 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
vtlog "mount ventoy.iso"
mkdir -p /root/cdrom >>$VTLOG 2>&1
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso /root/cdrom >>$VTLOG 2>&1

View File

@ -0,0 +1,52 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, 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
vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
ventoy_run_fuse() {
vtlog "ventoy_run_fuse $*"
mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m $VTOY_PATH/mnt/fuse
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
}
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
PATH=$VTPATH_OLD
exit 0
fi
ventoy_run_fuse $vtdiskname
if [ -f /ventoy/autoinstall ]; then
sh /ventoy/hook/default/auto_install_varexp.sh /ventoy/autoinstall
fi

View File

@ -0,0 +1,27 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, 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/>.
#
#************************************************************************************
if [ -e /init ] && $GREP -q '^mountroot$' /init; then
echo "Here before mountroot ..." >> $VTLOG
$SED "/^mountroot$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/truenas-disk.sh" -i /init
$SED "/^mountroot$/i\\export LIVEMEDIA=/dev/mapper/ventoy" -i /init
$SED "/^mountroot$/i\\export LIVE_MEDIA=/dev/mapper/ventoy" -i /init
$SED "/^mountroot$/i\\export FROMISO=$VTOY_PATH/mnt/fuse/ventoy.iso" -i /init
$SED "/exec *run-init/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/truenas-bottom.sh" -i /init
fi

View File

@ -110,6 +110,14 @@ ventoy_get_debian_distro() {
echo 'pyabr'; return echo 'pyabr'; return
fi fi
if [ -e /devuan-logo.txt ]; then
echo 'devuan'; return
fi
if $GREP -q 'truenas' /proc/version; then
echo 'truenas'; return
fi
echo 'default' echo 'default'
} }

View File

@ -26,6 +26,12 @@ if [ -f $VTOY_PATH/autoinstall ]; then
fi fi
fi fi
if $GREP -q 'rdinit=/vtoy/vtoy' /proc/cmdline; then
echo "remove rdinit param" >> $VTLOG
echo "ptoptions=+rdinit" >> /linuxrc.config
fi
if $BUSYBOX_PATH/ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then if $BUSYBOX_PATH/ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then
if [ -f /linuxrc.config ]; then if [ -f /linuxrc.config ]; then
vtKerVer=$($BUSYBOX_PATH/uname -r) vtKerVer=$($BUSYBOX_PATH/uname -r)

View File

@ -45,6 +45,13 @@ fi
# TinyCore linux distro doesn't contain dmsetup, we use aoe here # TinyCore linux distro doesn't contain dmsetup, we use aoe here
sudo modprobe aoe aoe_iflist=lo sudo modprobe aoe aoe_iflist=lo
if [ -e /sys/module/aoe ]; then if [ -e /sys/module/aoe ]; then
if ! [ -d /lib64 ]; then
vtlog "link lib64"
NEED_UNLIB64=1
ln -s /lib /lib64
fi
VBLADE_BIN=$(ventoy_get_vblade_bin) VBLADE_BIN=$(ventoy_get_vblade_bin)
sudo nohup $VBLADE_BIN -r -f $VTOY_PATH/ventoy_image_map 9 0 lo "$vtdiskname" > /dev/null & sudo nohup $VBLADE_BIN -r -f $VTOY_PATH/ventoy_image_map 9 0 lo "$vtdiskname" > /dev/null &
@ -57,6 +64,11 @@ if [ -e /sys/module/aoe ]; then
sudo cp -a /dev/etherd/e9.0 "$vPart" sudo cp -a /dev/etherd/e9.0 "$vPart"
if [ -n "$NEED_UNLIB64" ]; then
vtlog "unlink lib64"
unlink /lib64
fi
ventoy_find_bin_run rebuildfstab ventoy_find_bin_run rebuildfstab
else else
vterr "aoe driver module load failed..." vterr "aoe driver module load failed..."

View File

@ -232,257 +232,6 @@ ventoy_check_dm_module() {
fi fi
} }
ventoy_need_proc_ibt() {
vtKv=$($BUSYBOX_PATH/uname -r)
vtMajor=$(echo $vtKv | $AWK -F. '{print $1}')
vtMinor=$(echo $vtKv | $AWK -F. '{print $2}')
#ibt was supported since linux kernel 5.18
if [ $vtMajor -lt 5 ]; then
$BUSYBOX_PATH/false; return
elif [ $vtMajor -eq 5 ]; then
if [ $vtMajor -lt 18 ]; then
$BUSYBOX_PATH/false; return
fi
fi
if $GREP -q ' ibt=off' /proc/cmdline; then
$BUSYBOX_PATH/false; return
fi
#hardware CPU doesn't support IBT
if $VTOY_PATH/tool/vtoykmod -I; then
:
else
$BUSYBOX_PATH/false; return
fi
#dot.CONFIG not enabled
if $GREP -q ' ibt_restore$' /proc/kallsyms; then
:
else
$BUSYBOX_PATH/false; return
fi
$BUSYBOX_PATH/true
}
ventoy_need_dm_patch() {
if [ "$VTOY_LINUX_REMOUNT" != "01" ]; then
if $GREP -q 'VTOY_LINUX_REMOUNT=1' /proc/cmdline; then
:
else
$BUSYBOX_PATH/false; return
fi
fi
if $GREP -q 'device-mapper' /proc/devices; then
:
else
$BUSYBOX_PATH/false; return
fi
if $GREP -q 'dm_patch' /proc/modules; then
$BUSYBOX_PATH/false; return
fi
vtMajorVer=$($BUSYBOX_PATH/uname -r | $AWK -F. '{print $1}')
vtMinorVer=$($BUSYBOX_PATH/uname -r | $AWK -F. '{print $2}')
if [ $vtMajorVer -lt 3 ]; then
$BUSYBOX_PATH/false; return
elif [ $vtMajorVer -eq 3 -a $vtMinorVer -lt 10 ]; then
$BUSYBOX_PATH/false; return
fi
$BUSYBOX_PATH/true
}
ventoy_dm_patch() {
vtDmPatchDebug=0
vtMType=$($BUSYBOX_PATH/uname -m)
vtlog "######### ventoy_dm_patch ############"
if echo $vtMType | $EGREP -i -q "x86.64|amd64"; then
vtKoName=dm_patch_64.ko
elif echo $vtMType | $EGREP -i -q "i[3-6]86"; then
vtKoName=dm_patch_32.ko
else
vtlog "unsupported machine type $vtMType"
return
fi
if ventoy_need_proc_ibt; then
vtlog "need to proc IBT"
vtKoName=dm_patch_ibt_64.ko
vtIBT='0x8888'
else
vtlog "NO need to proc IBT"
vtIBT='0'
fi
if [ -f $VTOY_PATH/tool/$vtKoName ]; then
vtlog "/ventoy/tool/$vtKoName exist OK"
else
vtlog "/ventoy/tool/$vtKoName NOT exist"
return
fi
$CAT /proc/kallsyms | $BUSYBOX_PATH/sort > $VTOY_PATH/kallsyms
if $GREP -m1 -q 'open_table_device.isra' $VTOY_PATH/kallsyms; then
vtISRA=$($GREP -m1 'open_table_device.isra' $VTOY_PATH/kallsyms | $AWK '{print $3}')
vtLine=$($VTOY_PATH/tool/vtoyksym $vtISRA $VTOY_PATH/kallsyms)
vtlog "get $vtISRA address $vtLine"
else
vtLine=$($VTOY_PATH/tool/vtoyksym dm_get_table_device $VTOY_PATH/kallsyms)
vtlog "get dm_get_table_device address $vtLine"
fi
get_addr=$(echo $vtLine | $AWK '{print $1}')
get_size=$(echo $vtLine | $AWK '{print $2}')
vtLine=$($VTOY_PATH/tool/vtoyksym blkdev_get_by_dev $VTOY_PATH/kallsyms)
vtlog "get blkdev_get_by_dev address $vtLine"
blkdev_get_addr=$(echo $vtLine | $AWK '{print $1}')
vtLine=$($VTOY_PATH/tool/vtoyksym blkdev_put $VTOY_PATH/kallsyms)
vtlog "get blkdev_put address $vtLine"
blkdev_put_addr=$(echo $vtLine | $AWK '{print $1}')
vtLine=$($VTOY_PATH/tool/vtoyksym bdev_open_by_dev $VTOY_PATH/kallsyms)
vtlog "get bdev_open_by_dev address $vtLine"
bdev_open_addr=$(echo $vtLine | $AWK '{print $1}')
vtLine=$($VTOY_PATH/tool/vtoyksym bdev_file_open_by_dev $VTOY_PATH/kallsyms)
vtlog "get bdev_file_open_by_dev address $vtLine"
bdev_file_open_addr=$(echo $vtLine | $AWK '{print $1}')
if $GREP -m1 -q 'close_table_device.isra' $VTOY_PATH/kallsyms; then
vtLine=$($VTOY_PATH/tool/vtoyksym close_table_device.isra $VTOY_PATH/kallsyms)
vtlog "get close_table_device.isra address $vtLine"
else
vtLine=$($VTOY_PATH/tool/vtoyksym dm_put_table_device $VTOY_PATH/kallsyms)
vtlog "get dm_put_table_device address $vtLine"
fi
put_addr=$(echo $vtLine | $AWK '{print $1}')
put_size=$(echo $vtLine | $AWK '{print $2}')
ro_addr=$($GREP ' set_memory_ro$' /proc/kallsyms | $AWK '{print $1}')
rw_addr=$($GREP ' set_memory_rw$' /proc/kallsyms | $AWK '{print $1}')
kprobe_reg_addr=$($GREP ' register_kprobe$' /proc/kallsyms | $AWK '{print $1}')
kprobe_unreg_addr=$($GREP ' unregister_kprobe$' /proc/kallsyms | $AWK '{print $1}')
if [ "$VTOY_DEBUG_LEVEL" = "01" ]; then
vtDmPatchDebug=1
fi
if $GREP -q 'dmpatch_debug' /proc/cmdline; then
vtDmPatchDebug=1
fi
if [ $vtDmPatchDebug -eq 1 ]; then
printk_addr=$($GREP ' printk$' /proc/kallsyms | $AWK '{print $1}')
if [ -z "$printk_addr" ]; then
printk_addr=$($GREP ' _printk$' /proc/kallsyms | $AWK '{print $1}')
fi
vtDebug="-v"
else
printk_addr=0
fi
#printk_addr=$($GREP ' printk$' /proc/kallsyms | $AWK '{print $1}')
#vtDebug="-v"
vtlog get_addr=$get_addr get_size=$get_size
vtlog put_addr=$put_addr put_size=$put_size
vtlog blkdev_get_addr=$blkdev_get_addr blkdev_put_addr=$blkdev_put_addr
vtlog kprobe_reg_addr=$kprobe_reg_addr kprobe_unreg_addr=$kprobe_unreg_addr
vtlog ro_addr=$ro_addr rw_addr=$rw_addr printk_addr=$printk_addr bdev_open_addr=$bdev_open_addr bdev_file_open_addr=$bdev_file_open_addr
if [ "$get_addr" = "0" -o "$put_addr" = "0" ]; then
vtlog "Invalid symbol address"
return
fi
if [ "$ro_addr" = "0" -o "$rw_addr" = "0" ]; then
vtlog "Invalid symbol address"
return
fi
vtKv=$($BUSYBOX_PATH/uname -r)
vtKVMajor=$(echo $vtKv | $AWK -F. '{print $1}')
vtKVMinor=$(echo $vtKv | $AWK -F. '{print $2}')
vtKVSubMinor=$(echo $vtKv | $AWK -F. '{print $3}')
if [ ! -d /lib/modules/$vtKv ]; then
vtlog "No modules directory found"
return
elif [ -d /lib/modules/$vtKv/kernel/fs ]; then
vtModPath=$($FIND /lib/modules/$vtKv/kernel/fs/ -name "*.ko*" | $HEAD -n1)
elif [ -d /lib/modules/$vtKv/kernel ]; then
vtModPath=$($FIND /lib/modules/$vtKv/kernel/ -name "xfs.ko*" | $HEAD -n1)
elif [ -d /lib/modules/$vtKv/initrd ]; then
vtModPath=$($FIND /lib/modules/$vtKv/initrd/ -name "xfs.ko*" | $HEAD -n1)
fi
if [ -z "$vtModPath" ]; then
vtModPath=$($FIND /lib/modules/$vtKv/ -name "*.ko*" | $HEAD -n1)
fi
vtModName=$($BUSYBOX_PATH/basename $vtModPath)
vtlog "template module is $vtModPath $vtModName"
if [ -z "$vtModPath" ]; then
vtlog "No template module found"
return
elif echo $vtModPath | $GREP -q "[.]ko$"; then
$BUSYBOX_PATH/cp -a $vtModPath $VTOY_PATH/$vtModName
elif echo $vtModPath | $GREP -q "[.]ko[.]xz$"; then
$BUSYBOX_PATH/xzcat $vtModPath > $VTOY_PATH/$vtModName
elif echo $vtModPath | $GREP -q "[.]ko[.]gz$"; then
$BUSYBOX_PATH/zcat $vtModPath > $VTOY_PATH/$vtModName
elif echo $vtModPath | $GREP -q "[.]ko[.]zst$"; then
$VTOY_PATH/tool/zstdcat $vtModPath > $VTOY_PATH/$vtModName
else
vtlog "unsupport module type"
return
fi
#step1: modify vermagic/mod crc/relocation
vtlog "$VTOY_PATH/tool/vtoykmod -u $vtKVMajor $vtKVMinor $VTOY_PATH/tool/$vtKoName $VTOY_PATH/$vtModName $vtDebug"
$VTOY_PATH/tool/vtoykmod -u $vtKVMajor $vtKVMinor $VTOY_PATH/tool/$vtKoName $VTOY_PATH/$vtModName $vtDebug >>$VTLOG 2>&1
#step2: fill parameters
vtPgsize=$($VTOY_PATH/tool/vtoyksym -p)
vtPrams="$VTOY_PATH/tool/$vtKoName $vtPgsize 0x$printk_addr 0x$ro_addr 0x$rw_addr $get_addr $get_size $put_addr $put_size 0x$kprobe_reg_addr 0x$kprobe_unreg_addr $vtKVMajor $vtIBT $vtKVMinor $blkdev_get_addr $blkdev_put_addr $vtKVSubMinor $bdev_open_addr $bdev_file_open_addr $vtDebug"
vtlog "$VTOY_PATH/tool/vtoykmod -f $vtPrams"
$VTOY_PATH/tool/vtoykmod -f $vtPrams >>$VTLOG 2>&1
vtlog "insmod $VTOY_PATH/tool/$vtKoName"
$BUSYBOX_PATH/insmod $VTOY_PATH/tool/$vtKoName >>$VTLOG 2>&1
if $GREP -q 'dm_patch' /proc/modules; then
vtlog "dm_patch module OK"
echo "done" > $VTOY_PATH/dm_patch_done
else
vtlog "dm_patch module FAILED"
fi
}
create_ventoy_device_mapper() { create_ventoy_device_mapper() {
vtlog "create_ventoy_device_mapper $*" vtlog "create_ventoy_device_mapper $*"
@ -502,17 +251,7 @@ create_ventoy_device_mapper() {
fi fi
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table $VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
$VTOY_PATH/tool/vtoydm -r -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_raw_table
vtLevel1=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
vtLevel2=$($CAT /proc/sys/kernel/printk | $AWK '{print $2}')
vtLevel3=$($CAT /proc/sys/kernel/printk | $AWK '{print $3}')
vtLevel4=$($CAT /proc/sys/kernel/printk | $AWK '{print $4}')
if ventoy_need_dm_patch; then
ventoy_dm_patch
#suppress printk message
echo 0 $vtLevel2 0 $vtLevel4 > /proc/sys/kernel/printk
fi
if [ -z "$2" ]; then if [ -z "$2" ]; then
$VT_DM_BIN create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1 $VT_DM_BIN create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
@ -520,10 +259,8 @@ create_ventoy_device_mapper() {
$VT_DM_BIN "$2" create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1 $VT_DM_BIN "$2" create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
fi fi
if ventoy_need_dm_patch; then RAWDISKNAME=$($HEAD -n1 $VTOY_PATH/ventoy_raw_table | $AWK '{print $4}')
#recover printk level $VT_DM_BIN create ${RAWDISKNAME#/dev/} $VTOY_PATH/ventoy_raw_table >>$VTLOG 2>&1
echo $vtLevel1 $vtLevel2 $vtLevel3 $vtLevel4 > /proc/sys/kernel/printk
fi
} }
create_persistent_device_mapper() { create_persistent_device_mapper() {
@ -544,23 +281,7 @@ create_persistent_device_mapper() {
fi fi
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_persistent_map -d $1 > $VTOY_PATH/persistent_dm_table $VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_persistent_map -d $1 > $VTOY_PATH/persistent_dm_table
vtLevel1=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
vtLevel2=$($CAT /proc/sys/kernel/printk | $AWK '{print $2}')
vtLevel3=$($CAT /proc/sys/kernel/printk | $AWK '{print $3}')
vtLevel4=$($CAT /proc/sys/kernel/printk | $AWK '{print $4}')
if [ -f $VTOY_PATH/dm_patch_done ]; then
#suppress printk message
echo 0 $vtLevel2 0 $vtLevel4 > /proc/sys/kernel/printk
fi
$VT_DM_BIN create vtoy_persistent $VTOY_PATH/persistent_dm_table >>$VTLOG 2>&1 $VT_DM_BIN create vtoy_persistent $VTOY_PATH/persistent_dm_table >>$VTLOG 2>&1
if [ -f $VTOY_PATH/dm_patch_done ]; then
#recover printk level
echo $vtLevel1 $vtLevel2 $vtLevel3 $vtLevel4 > /proc/sys/kernel/printk
fi
} }
@ -854,11 +575,6 @@ ventoy_udev_disk_common_hook() {
create_persistent_device_mapper "/dev/$VTDISK" create_persistent_device_mapper "/dev/$VTDISK"
ventoy_create_persistent_link ventoy_create_persistent_link
fi fi
if $GREP -q 'dm_patch' /proc/modules; then
vtlog "remove dm_patch module."
$BUSYBOX_PATH/rmmod dm_patch
fi
} }
ventoy_create_dev_ventoy_part() { ventoy_create_dev_ventoy_part() {
@ -867,16 +583,6 @@ ventoy_create_dev_ventoy_part() {
if [ -e /vtoy_dm_table ]; then if [ -e /vtoy_dm_table ]; then
vtPartid=1 vtPartid=1
vtLevel1=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
vtLevel2=$($CAT /proc/sys/kernel/printk | $AWK '{print $2}')
vtLevel3=$($CAT /proc/sys/kernel/printk | $AWK '{print $3}')
vtLevel4=$($CAT /proc/sys/kernel/printk | $AWK '{print $4}')
if [ -f $VTOY_PATH/dm_patch_done ]; then
#suppress printk message
echo 0 $vtLevel2 0 $vtLevel4 > /proc/sys/kernel/printk
fi
$CAT /vtoy_dm_table | while read vtline; do $CAT /vtoy_dm_table | while read vtline; do
echo $vtline > /ventoy/dm_table_part${vtPartid} echo $vtline > /ventoy/dm_table_part${vtPartid}
$VTOY_PATH/tool/dmsetup create ventoy${vtPartid} /ventoy/dm_table_part${vtPartid} $VTOY_PATH/tool/dmsetup create ventoy${vtPartid} /ventoy/dm_table_part${vtPartid}
@ -886,11 +592,6 @@ ventoy_create_dev_ventoy_part() {
vtPartid=$(expr $vtPartid + 1) vtPartid=$(expr $vtPartid + 1)
done done
if [ -f $VTOY_PATH/dm_patch_done ]; then
#recover printk level
echo $vtLevel1 $vtLevel2 $vtLevel3 $vtLevel4 > /proc/sys/kernel/printk
fi
fi fi
} }

View File

@ -39,35 +39,6 @@ fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace" ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
ventoy_create_dev_ventoy_part ventoy_create_dev_ventoy_part
if ventoy_need_dm_patch; then
vtlog "extract a ko file"
mkdir -p /ventoy/tmpmnt1 /ventoy/tmpmnt2
mount /dev/ventoy1 /ventoy/tmpmnt1
mount /ventoy/tmpmnt1/boot/batocera /ventoy/tmpmnt2
vtKV=$(uname -r)
mkdir -p /lib/modules/$vtKV/kernel/
vtKO=$(find "/ventoy/tmpmnt2/lib/modules/$vtKV/kernel/fs/" -name "*.ko*" | head -n1)
cp -a $vtKO /lib/modules/$vtKV/kernel/
vtlog "vtKV=$vtKV vtKO=$vtKO"
umount /ventoy/tmpmnt2
umount /ventoy/tmpmnt1
vtPartid=1
cat /vtoy_dm_table | while read vtline; do
dmsetup remove ventoy$vtPartid
vtPartid=$(expr $vtPartid + 1)
done
dmsetup remove ventoy
vtlog "Recreate device-mapper"
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
ventoy_create_dev_ventoy_part
fi
PATH=$VTPATH_OLD PATH=$VTPATH_OLD

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -21,15 +21,6 @@ submenu "$VTLANG_CTRL_TEMP_SET" --class=debug_temp_set --class=F5tool {
fi fi
} }
menuentry "[ $VTOY_LINUX_REMOUNT ] $VTLANG_LINUX_REMOUNT" --class=debug_temp_linux_remount --class=debug_temp_set --class=F5tool \
VTOY_RUN_SET2 {
if [ "$VTOY_LINUX_REMOUNT" = "0" ]; then
set VTOY_LINUX_REMOUNT=1
else
set VTOY_LINUX_REMOUNT=0
fi
}
menuentry "[ $VTOY_SECONDARY_BOOT_MENU ] $VTLANG_SECONDARY_BOOT_MENU" --class=debug_temp_second_menu --class=debug_temp_set --class=F5tool \ menuentry "[ $VTOY_SECONDARY_BOOT_MENU ] $VTLANG_SECONDARY_BOOT_MENU" --class=debug_temp_second_menu --class=debug_temp_set --class=F5tool \
VTOY_RUN_SET3 { VTOY_RUN_SET3 {
if [ "$VTOY_SECONDARY_BOOT_MENU" = "0" ]; then if [ "$VTOY_SECONDARY_BOOT_MENU" = "0" ]; then

View File

@ -33,6 +33,21 @@ function ventoy_debug_pause {
fi fi
} }
function ventoy_max_resolution {
#Skip this for VirtualBox
smbios -t 1 -s 0x05 --set=system_product;
if vt_str_casebegin "$system_product" "VirtualBox"; then
return
fi
vt_enum_video_mode
vt_get_video_mode 0 vtCurMode
terminal_output console
set gfxmode=$vtCurMode
terminal_output gfxterm
}
function ventoy_cli_console { function ventoy_cli_console {
if [ -z "$vtoy_display_mode" ]; then if [ -z "$vtoy_display_mode" ]; then
terminal_output console terminal_output console
@ -405,6 +420,8 @@ function distro_specify_initrd_file_phase2 {
vt_linux_specify_initrd_file /live/initrd vt_linux_specify_initrd_file /live/initrd
elif [ -f (loop)/initramfs-linux.img ]; then elif [ -f (loop)/initramfs-linux.img ]; then
vt_linux_specify_initrd_file /initramfs-linux.img vt_linux_specify_initrd_file /initramfs-linux.img
elif [ -f (loop)/boot/isolinux/initrd.gz ]; then
vt_linux_specify_initrd_file /boot/isolinux/initrd.gz
fi fi
} }
@ -516,6 +533,13 @@ function ventoy_freebsd_proc {
fi fi
fi fi
if [ "$vt_freebsd_ver" = "14.x" ]; then
if [ -e (loop)/boot/lua/brand-pfSense.lua ]; then
set vtFreeBsdDistro=pfSense
fi
fi
if [ -n "${vtdebug_flag}" ]; then if [ -n "${vtdebug_flag}" ]; then
echo "This is $vtFreeBsdDistro $vt_freebsd_ver ${vt_freebsd_bit}bit" echo "This is $vtFreeBsdDistro $vt_freebsd_ver ${vt_freebsd_bit}bit"
fi fi
@ -622,7 +646,7 @@ function uefi_windows_menu_func {
if [ -n "$vtoy_chain_mem_addr" ]; then if [ -n "$vtoy_chain_mem_addr" ]; then
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
ventoy_cli_console ventoy_max_resolution
chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} iso_${ventoy_fs_probe} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} iso_${ventoy_fs_probe} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot boot
else else
@ -664,7 +688,7 @@ function uefi_linux_menu_func {
if [ -d (loop)/pmagic ]; then if [ -d (loop)/pmagic ]; then
vt_linux_specify_initrd_file /pmagic/initrd.img vt_linux_specify_initrd_file /pmagic/initrd.img
else else
for file in "boot/grub/grub.cfg" "EFI/BOOT/grub.cfg" "EFI/boot/grub.cfg" "efi/boot/grub.cfg" "EFI/BOOT/BOOTX64.conf" "/grub/grub.cfg"; do for file in "boot/grub/grub.cfg" "EFI/BOOT/grub.cfg" "EFI/boot/grub.cfg" "efi/boot/grub.cfg" "EFI/BOOT/BOOTX64.conf" "/grub/grub.cfg" "EFI/BOOT/grub/grub.cfg"; do
if [ -e (loop)/$file ]; then if [ -e (loop)/$file ]; then
vt_linux_parse_initrd_grub file (loop)/$file vt_linux_parse_initrd_grub file (loop)/$file
fi fi
@ -2401,7 +2425,7 @@ function mimg_common_menuentry {
############################################################# #############################################################
############################################################# #############################################################
set VENTOY_VERSION="1.1.00" set VENTOY_VERSION="1.1.05"
#ACPI not compatible with Window7/8, so disable by default #ACPI not compatible with Window7/8, so disable by default
set VTOY_PARAM_NO_ACPI=1 set VTOY_PARAM_NO_ACPI=1

View File

@ -626,6 +626,14 @@ else
vtoycli partresize -s $DISK $part2_start vtoycli partresize -s $DISK $part2_start
fi fi
if [ "$PART1_TYPE" = "EE" ]; then
vtinfo "update esp partition attribute"
vtoycli gpt -f $DISK
sync
fi
echo "" echo ""
vtinfo "Update Ventoy on $DISK successfully finished." vtinfo "Update Ventoy on $DISK successfully finished."
echo "" echo ""

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -19,5 +19,34 @@
"condition": "equal", "condition": "equal",
"expression": "ukui", "expression": "ukui",
"gui": "gtk3" "gui": "gtk3"
},
{
"type": "env",
"name": "DESKTOP_SESSION",
"condition": "equal",
"expression": "cinnamon",
"gui": "gtk3"
},
{
"type": "env",
"name": "DESKTOP_SESSION",
"condition": "equal",
"expression": "gnome",
"gui": "gtk3"
},
{
"type": "env",
"name": "DESKTOP_SESSION",
"condition": "equal",
"expression": "plasma",
"gui": "qt5"
},
{
"type": "env",
"name": "DESKTOP_SESSION",
"condition": "equal",
"expression": "xfce",
"gui": "gtk3"
} }
] ]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -449,7 +449,6 @@ format_ventoy_disk_gpt() {
mkpart Ventoy ntfs $part1_start_sector $part1_end_sector \ mkpart Ventoy ntfs $part1_start_sector $part1_end_sector \
mkpart VTOYEFI fat16 $part2_start_sector $part2_end_sector \ mkpart VTOYEFI fat16 $part2_start_sector $part2_end_sector \
$vt_set_efi_type \ $vt_set_efi_type \
set 2 hidden on \
quit quit
sync sync

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -442,7 +442,7 @@ int ventoy_fill_gpt(uint64_t size, uint64_t reserve, int align4k, VTOY_GPT_INFO
ventoy_gen_preudo_uuid(&(Table[1].PartGuid)); ventoy_gen_preudo_uuid(&(Table[1].PartGuid));
Table[1].StartLBA = Table[0].LastLBA + 1; Table[1].StartLBA = Table[0].LastLBA + 1;
Table[1].LastLBA = Table[1].StartLBA + VTOYEFI_PART_BYTES / 512 - 1; Table[1].LastLBA = Table[1].StartLBA + VTOYEFI_PART_BYTES / 512 - 1;
Table[1].Attr = 0xC000000000000001ULL; Table[1].Attr = 0x8000000000000000ULL;
ventoy_fill_gpt_partname(Table[1].Name, "VTOYEFI"); ventoy_fill_gpt_partname(Table[1].Name, "VTOYEFI");
#if 0 #if 0

View File

@ -727,6 +727,7 @@ static void * ventoy_update_thread(void *data)
MBR_HEAD MBR; MBR_HEAD MBR;
ventoy_disk *disk = NULL; ventoy_disk *disk = NULL;
ventoy_thread_data *thread = (ventoy_thread_data *)data; ventoy_thread_data *thread = (ventoy_thread_data *)data;
VTOY_GPT_INFO *pstGPT = NULL;
vdebug("ventoy_update_thread run ...\n"); vdebug("ventoy_update_thread run ...\n");
@ -790,6 +791,36 @@ static void * ventoy_update_thread(void *data)
vlog("No need to update MBR\n"); vlog("No need to update MBR\n");
} }
if (disk->vtoydata.partition_style)
{
pstGPT = (VTOY_GPT_INFO *)malloc(sizeof(VTOY_GPT_INFO));
memset(pstGPT, 0, sizeof(VTOY_GPT_INFO));
offset = lseek(fd, 0, SEEK_SET);
len = read(fd, pstGPT, sizeof(VTOY_GPT_INFO));
vlog("Read GPT table offset:%llu len:%llu ...\n", (_ull)offset, (_ull)len);
if (pstGPT->PartTbl[1].Attr != 0x8000000000000000ULL)
{
vlog("Update EFI part attr from 0x%016llx to 0x%016llx\n",
pstGPT->PartTbl[1].Attr, 0x8000000000000000ULL);
pstGPT->PartTbl[1].Attr = 0x8000000000000000ULL;
pstGPT->Head.PartTblCrc = ventoy_crc32(pstGPT->PartTbl, sizeof(pstGPT->PartTbl));
pstGPT->Head.Crc = 0;
pstGPT->Head.Crc = ventoy_crc32(&(pstGPT->Head), pstGPT->Head.Length);
ventoy_write_gpt_part_table(fd, disk->size_in_byte, pstGPT);
}
else
{
vlog("No need to update EFI part attr\n");
}
free(pstGPT);
}
g_current_progress = PT_SYNC_DATA1; g_current_progress = PT_SYNC_DATA1;
vlog("fsync data1...\n"); vlog("fsync data1...\n");

View File

@ -2520,7 +2520,7 @@ int PartitionResizeForVentoy(PHY_DRIVE_INFO *pPhyDrive)
pGPT->PartTbl[1].StartLBA = pGPT->PartTbl[0].LastLBA + 1; pGPT->PartTbl[1].StartLBA = pGPT->PartTbl[0].LastLBA + 1;
pGPT->PartTbl[1].LastLBA = pGPT->PartTbl[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1; pGPT->PartTbl[1].LastLBA = pGPT->PartTbl[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1;
pGPT->PartTbl[1].Attr = 0xC000000000000001ULL; pGPT->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
memcpy(pGPT->PartTbl[1].Name, L"VTOYEFI", 7 * 2); memcpy(pGPT->PartTbl[1].Name, L"VTOYEFI", 7 * 2);
//Update CRC //Update CRC
@ -2797,6 +2797,7 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
BOOL CleanDisk = FALSE; BOOL CleanDisk = FALSE;
BOOL DelEFI = FALSE; BOOL DelEFI = FALSE;
BOOL bWriteBack = TRUE; BOOL bWriteBack = TRUE;
BOOL bUpdateEFIAttr = FALSE;
HANDLE hVolume; HANDLE hVolume;
HANDLE hDrive; HANDLE hDrive;
DWORD Status; DWORD Status;
@ -2906,6 +2907,12 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
Log("TryId=%d EFI GPT partition type is 0x%llx", TryId, pPhyDrive->Part2GPTAttr); Log("TryId=%d EFI GPT partition type is 0x%llx", TryId, pPhyDrive->Part2GPTAttr);
PROGRESS_BAR_SET_POS(PT_DEL_ALL_PART); PROGRESS_BAR_SET_POS(PT_DEL_ALL_PART);
if (pGptInfo->PartTbl[1].Attr != VENTOY_EFI_PART_ATTR)
{
bUpdateEFIAttr = TRUE;
}
if (TryId == 1) if (TryId == 1)
{ {
Log("Change GPT partition type to ESP"); Log("Change GPT partition type to ESP");
@ -2917,8 +2924,8 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
} }
else if (TryId == 2) else if (TryId == 2)
{ {
Log("Change GPT partition attribute"); Log("Try2 Change GPT partition attribute to 0x%016llx", VENTOY_EFI_PART_ATTR & 0xFFFFFFFFFFFFFFFEULL);
if (DISK_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, StartSector * 512ULL, 0x8000000000000001)) if (DISK_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, StartSector * 512ULL, VENTOY_EFI_PART_ATTR & 0xFFFFFFFFFFFFFFFEULL))
{ {
ChangeAttr = TRUE; ChangeAttr = TRUE;
Sleep(2000); Sleep(2000);
@ -3253,15 +3260,16 @@ End:
DISK_ChangeVtoyEFI2Basic(pPhyDrive->PhyDrive, StartSector * 512); DISK_ChangeVtoyEFI2Basic(pPhyDrive->PhyDrive, StartSector * 512);
} }
if (pPhyDrive->PartStyle == 1) if (pPhyDrive->PartStyle == 1)
{ {
if (ChangeAttr || ((pPhyDrive->Part2GPTAttr >> 56) != 0xC0)) if (ChangeAttr || bUpdateEFIAttr)
{ {
Log("Change EFI partition attr %u <0x%llx> to <0x%llx>", ChangeAttr, pPhyDrive->Part2GPTAttr, 0xC000000000000001ULL); Log("Change EFI partition attr %u <0x%llx> to <0x%llx>", ChangeAttr, pGptInfo->PartTbl[1].Attr, VENTOY_EFI_PART_ATTR);
if (DISK_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, StartSector * 512ULL, 0xC000000000000001ULL)) if (DISK_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, StartSector * 512ULL, VENTOY_EFI_PART_ATTR))
{ {
Log("Change EFI partition attr success"); Log("Change EFI partition attr success");
pPhyDrive->Part2GPTAttr = 0xC000000000000001ULL; pPhyDrive->Part2GPTAttr = VENTOY_EFI_PART_ATTR;
} }
else else
{ {

View File

@ -982,7 +982,7 @@ int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo)
CoCreateGuid(&(Table[1].PartGuid)); CoCreateGuid(&(Table[1].PartGuid));
Table[1].StartLBA = Table[0].LastLBA + 1; Table[1].StartLBA = Table[0].LastLBA + 1;
Table[1].LastLBA = Table[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1; Table[1].LastLBA = Table[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1;
Table[1].Attr = 0xC000000000000001ULL; Table[1].Attr = VENTOY_EFI_PART_ATTR;
memcpy(Table[1].Name, L"VTOYEFI", 7 * 2); memcpy(Table[1].Name, L"VTOYEFI", 7 * 2);
#if 0 #if 0

View File

@ -34,6 +34,9 @@ typedef enum VTOY_FS
#define FAT32_MAX_LIMIT (32 * 1073741824ULL) #define FAT32_MAX_LIMIT (32 * 1073741824ULL)
#define VENTOY_EFI_PART_ATTR 0x8000000000000000ULL
#define SIZE_1KB (1024) #define SIZE_1KB (1024)
#define SIZE_1GB (1024 * 1024 * 1024) #define SIZE_1GB (1024 * 1024 * 1024)
#define SIZE_1TB (1024ULL * 1024ULL * 1024ULL * 1024ULL) #define SIZE_1TB (1024ULL * 1024ULL * 1024ULL * 1024ULL)

View File

@ -68,6 +68,7 @@ static int verbose = 0;
#define CMD_DUMP_ISO_INFO 3 #define CMD_DUMP_ISO_INFO 3
#define CMD_EXTRACT_ISO_FILE 4 #define CMD_EXTRACT_ISO_FILE 4
#define CMD_PRINT_EXTRACT_ISO_FILE 5 #define CMD_PRINT_EXTRACT_ISO_FILE 5
#define CMD_PRINT_RAW_TABLE 6
static uint64_t g_iso_file_size; static uint64_t g_iso_file_size;
static char g_disk_name[128]; static char g_disk_name[128];
@ -578,6 +579,45 @@ static uint64_t vtoydm_get_part_start(const char *diskname, int part)
return size; return size;
} }
static uint64_t vtoydm_get_part_secnum(const char *diskname, int part)
{
int fd;
unsigned long long size = 0;
char diskpath[256] = {0};
char sizebuf[64] = {0};
diskname += 5; /* skip /dev/ */
if (strstr(diskname, "nvme") || strstr(diskname, "mmc") || strstr(diskname, "nbd"))
{
snprintf(diskpath, sizeof(diskpath) - 1, "/sys/class/block/%sp%d/size", diskname, part);
}
else
{
snprintf(diskpath, sizeof(diskpath) - 1, "/sys/class/block/%s%d/size", diskname, part);
}
if (access(diskpath, F_OK) >= 0)
{
debug("get part size from sysfs for %s %d\n", diskname, part);
fd = open(diskpath, O_RDONLY | O_BINARY);
if (fd >= 0)
{
read(fd, sizebuf, sizeof(sizebuf));
size = strtoull(sizebuf, NULL, 10);
close(fd);
return size;
}
}
else
{
debug("%s not exist \n", diskpath);
}
return size;
}
static int vtoydm_vlnk_convert(char *disk, int len, int *part, uint64_t *offset) static int vtoydm_vlnk_convert(char *disk, int len, int *part, uint64_t *offset)
{ {
int rc = 1; int rc = 1;
@ -627,6 +667,24 @@ end:
return rc; return rc;
} }
static int vtoydm_print_raw_linear_table(const char *img_map_file, const char *diskname, int part)
{
uint64_t disk_sector_num;
disk_sector_num = vtoydm_get_part_secnum(diskname, part);
if (strstr(diskname, "nvme") || strstr(diskname, "mmc") || strstr(diskname, "nbd"))
{
printf("0 %lu linear %sp%d 0\n", (unsigned long)disk_sector_num, diskname, part);
}
else
{
printf("0 %lu linear %s%d 0\n", (unsigned long)disk_sector_num, diskname, part);
}
return 0;
}
int vtoydm_main(int argc, char **argv) int vtoydm_main(int argc, char **argv)
{ {
int ch; int ch;
@ -639,7 +697,7 @@ int vtoydm_main(int argc, char **argv)
char filepath[300] = {0}; char filepath[300] = {0};
char outfile[300] = {0}; char outfile[300] = {0};
while ((ch = getopt(argc, argv, "s:l:o:d:f:v::i::p::c::h::e::E::")) != -1) while ((ch = getopt(argc, argv, "s:l:o:d:f:v::i::p::r::c::h::e::E::")) != -1)
{ {
if (ch == 'd') if (ch == 'd')
{ {
@ -653,6 +711,10 @@ int vtoydm_main(int argc, char **argv)
{ {
cmd = CMD_PRINT_TABLE; cmd = CMD_PRINT_TABLE;
} }
else if (ch == 'r')
{
cmd = CMD_PRINT_RAW_TABLE;
}
else if (ch == 'c') else if (ch == 'c')
{ {
cmd = CMD_CREATE_DM; cmd = CMD_CREATE_DM;
@ -713,6 +775,10 @@ int vtoydm_main(int argc, char **argv)
{ {
return vtoydm_print_linear_table(filepath, diskname, part, offset); return vtoydm_print_linear_table(filepath, diskname, part, offset);
} }
case CMD_PRINT_RAW_TABLE:
{
return vtoydm_print_raw_linear_table(filepath, diskname, part);
}
case CMD_CREATE_DM: case CMD_CREATE_DM:
{ {
break; break;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -599,7 +599,7 @@ static int update_part_table(char *disk, UINT64 part2start)
PartTbl[1].StartLBA = PartTbl[0].LastLBA + 1; PartTbl[1].StartLBA = PartTbl[0].LastLBA + 1;
PartTbl[1].LastLBA = PartTbl[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1; PartTbl[1].LastLBA = PartTbl[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1;
PartTbl[1].Attr = 0xC000000000000001ULL; PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
PartTbl[1].Name[0] = 'V'; PartTbl[1].Name[0] = 'V';
PartTbl[1].Name[1] = 'T'; PartTbl[1].Name[1] = 'T';
PartTbl[1].Name[2] = 'O'; PartTbl[1].Name[2] = 'O';

View File

@ -21,7 +21,7 @@
#ifndef __VTOYCLI_H__ #ifndef __VTOYCLI_H__
#define __VTOYCLI_H__ #define __VTOYCLI_H__
#define VENTOY_EFI_PART_ATTR 0xC000000000000001ULL #define VENTOY_EFI_PART_ATTR 0x8000000000000000ULL
#define SIZE_1MB (1024 * 1024) #define SIZE_1MB (1024 * 1024)
#define VENTOY_EFI_PART_SIZE (32 * SIZE_1MB) #define VENTOY_EFI_PART_SIZE (32 * SIZE_1MB)

View File

@ -191,23 +191,26 @@ int vtoygpt_main(int argc, char **argv)
Name = pMainGptInfo->PartTbl[1].Name; Name = pMainGptInfo->PartTbl[1].Name;
if (Name[0] == 'V' && Name[1] == 'T' && Name[2] == 'O' && Name[3] == 'Y') if (Name[0] == 'V' && Name[1] == 'T' && Name[2] == 'O' && Name[3] == 'Y')
{ {
pMainGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR; if (pMainGptInfo->PartTbl[1].Attr != VENTOY_EFI_PART_ATTR)
pMainGptInfo->Head.PartTblCrc = VtoyCrc32(pMainGptInfo->PartTbl, sizeof(pMainGptInfo->PartTbl)); {
pMainGptInfo->Head.Crc = 0; pMainGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
pMainGptInfo->Head.Crc = VtoyCrc32(&pMainGptInfo->Head, pMainGptInfo->Head.Length); pMainGptInfo->Head.PartTblCrc = VtoyCrc32(pMainGptInfo->PartTbl, sizeof(pMainGptInfo->PartTbl));
pMainGptInfo->Head.Crc = 0;
pMainGptInfo->Head.Crc = VtoyCrc32(&pMainGptInfo->Head, pMainGptInfo->Head.Length);
pBackGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR; pBackGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
pBackGptInfo->Head.PartTblCrc = VtoyCrc32(pBackGptInfo->PartTbl, sizeof(pBackGptInfo->PartTbl)); pBackGptInfo->Head.PartTblCrc = VtoyCrc32(pBackGptInfo->PartTbl, sizeof(pBackGptInfo->PartTbl));
pBackGptInfo->Head.Crc = 0; pBackGptInfo->Head.Crc = 0;
pBackGptInfo->Head.Crc = VtoyCrc32(&pBackGptInfo->Head, pBackGptInfo->Head.Length); pBackGptInfo->Head.Crc = VtoyCrc32(&pBackGptInfo->Head, pBackGptInfo->Head.Length);
lseek(fd, 512, SEEK_SET); lseek(fd, 512, SEEK_SET);
write(fd, (UINT8 *)pMainGptInfo + 512, sizeof(VTOY_GPT_INFO) - 512); write(fd, (UINT8 *)pMainGptInfo + 512, sizeof(VTOY_GPT_INFO) - 512);
lseek(fd, DiskSize - 33 * 512, SEEK_SET); lseek(fd, DiskSize - 33 * 512, SEEK_SET);
write(fd, pBackGptInfo, sizeof(VTOY_BK_GPT_INFO)); write(fd, pBackGptInfo, sizeof(VTOY_BK_GPT_INFO));
fsync(fd); fsync(fd);
}
} }
} }

View File

@ -244,7 +244,7 @@ int DumpGptInfo(VTOY_GPT_INFO *pGptInfo)
return 0; return 0;
} }
#define VENTOY_EFI_PART_ATTR 0xC000000000000001ULL #define VENTOY_EFI_PART_ATTR 0x8000000000000000ULL
int main(int argc, const char **argv) int main(int argc, const char **argv)
{ {
@ -291,23 +291,26 @@ int main(int argc, const char **argv)
Name = pMainGptInfo->PartTbl[1].Name; Name = pMainGptInfo->PartTbl[1].Name;
if (Name[0] == 'V' && Name[1] == 'T' && Name[2] == 'O' && Name[3] == 'Y') if (Name[0] == 'V' && Name[1] == 'T' && Name[2] == 'O' && Name[3] == 'Y')
{ {
pMainGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR; if (pMainGptInfo->PartTbl[1].Attr != VENTOY_EFI_PART_ATTR)
pMainGptInfo->Head.PartTblCrc = VtoyCrc32(pMainGptInfo->PartTbl, sizeof(pMainGptInfo->PartTbl)); {
pMainGptInfo->Head.Crc = 0; pMainGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
pMainGptInfo->Head.Crc = VtoyCrc32(&pMainGptInfo->Head, pMainGptInfo->Head.Length); pMainGptInfo->Head.PartTblCrc = VtoyCrc32(pMainGptInfo->PartTbl, sizeof(pMainGptInfo->PartTbl));
pMainGptInfo->Head.Crc = 0;
pMainGptInfo->Head.Crc = VtoyCrc32(&pMainGptInfo->Head, pMainGptInfo->Head.Length);
pBackGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR; pBackGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
pBackGptInfo->Head.PartTblCrc = VtoyCrc32(pBackGptInfo->PartTbl, sizeof(pBackGptInfo->PartTbl)); pBackGptInfo->Head.PartTblCrc = VtoyCrc32(pBackGptInfo->PartTbl, sizeof(pBackGptInfo->PartTbl));
pBackGptInfo->Head.Crc = 0; pBackGptInfo->Head.Crc = 0;
pBackGptInfo->Head.Crc = VtoyCrc32(&pBackGptInfo->Head, pBackGptInfo->Head.Length); pBackGptInfo->Head.Crc = VtoyCrc32(&pBackGptInfo->Head, pBackGptInfo->Head.Length);
lseek(fd, 512, SEEK_SET); lseek(fd, 512, SEEK_SET);
write(fd, (UINT8 *)pMainGptInfo + 512, sizeof(VTOY_GPT_INFO) - 512); write(fd, (UINT8 *)pMainGptInfo + 512, sizeof(VTOY_GPT_INFO) - 512);
lseek(fd, DiskSize - 33 * 512, SEEK_SET); lseek(fd, DiskSize - 33 * 512, SEEK_SET);
write(fd, pBackGptInfo, sizeof(VTOY_BK_GPT_INFO)); write(fd, pBackGptInfo, sizeof(VTOY_BK_GPT_INFO));
fsync(fd); fsync(fd);
}
} }
} }