Ventoy2Disk.sh: use iflag=fullblock when writing images from xzcat (#3806)
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run

dd reads from the xzcat pipe in 512-byte blocks, and a short read still
counts as one of the count blocks. dd then stops early and the end of
the VTOYEFI partition (or of core.img) keeps old data or zeros, while
the script reports success. status=none hides dd's partial-read count.

Fixes #3805
This commit is contained in:
0z5a
2026-11-20 08:39:22 +08:00
committed by GitHub
parent 74cff34240
commit 8308a527ac
+9 -9
View File
@@ -334,16 +334,16 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
if [ -n "$VTGPT" ]; then if [ -n "$VTGPT" ]; then
echo -en '\x22' | dd status=none of=$DISK conv=fsync bs=1 count=1 seek=92 echo -en '\x22' | dd status=none of=$DISK conv=fsync bs=1 count=1 seek=92
xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2014 seek=34 xzcat ./boot/core.img.xz | dd status=none iflag=fullblock conv=fsync of=$DISK bs=512 count=2014 seek=34
echo -en '\x23' | dd of=$DISK conv=fsync bs=1 count=1 seek=17908 status=none echo -en '\x23' | dd of=$DISK conv=fsync bs=1 count=1 seek=17908 status=none
else else
xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2047 seek=1 xzcat ./boot/core.img.xz | dd status=none iflag=fullblock conv=fsync of=$DISK bs=512 count=2047 seek=1
fi fi
# check and umount # check and umount
check_umount_disk "$DISK" check_umount_disk "$DISK"
xzcat ./ventoy/ventoy.disk.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector xzcat ./ventoy/ventoy.disk.img.xz | dd status=none iflag=fullblock conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector
#test UUID #test UUID
testUUIDStr=$(vtoy_gen_uuid | hexdump -C) testUUIDStr=$(vtoy_gen_uuid | hexdump -C)
@@ -500,13 +500,13 @@ elif [ "$MODE" = "install" -a -n "$NONDESTRUCTIVE" ]; then
if [ "$OldStyle" = "GPT" ]; then if [ "$OldStyle" = "GPT" ]; then
echo -en '\x22' | dd status=none of=$DISK conv=fsync bs=1 count=1 seek=92 echo -en '\x22' | dd status=none of=$DISK conv=fsync bs=1 count=1 seek=92
xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2014 seek=34 xzcat ./boot/core.img.xz | dd status=none iflag=fullblock conv=fsync of=$DISK bs=512 count=2014 seek=34
echo -en '\x23' | dd of=$DISK conv=fsync bs=1 count=1 seek=17908 status=none echo -en '\x23' | dd of=$DISK conv=fsync bs=1 count=1 seek=17908 status=none
else else
xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2047 seek=1 xzcat ./boot/core.img.xz | dd status=none iflag=fullblock conv=fsync of=$DISK bs=512 count=2047 seek=1
fi fi
xzcat ./ventoy/ventoy.disk.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector xzcat ./ventoy/ventoy.disk.img.xz | dd status=none iflag=fullblock conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector
#test UUID #test UUID
testUUIDStr=$(vtoy_gen_uuid | hexdump -C) testUUIDStr=$(vtoy_gen_uuid | hexdump -C)
@@ -594,7 +594,7 @@ else
if [ "$PART1_TYPE" = "EE" ]; then if [ "$PART1_TYPE" = "EE" ]; then
vtdebug "This is GPT partition style ..." vtdebug "This is GPT partition style ..."
echo -en '\x22' | dd status=none of=$DISK conv=fsync bs=1 count=1 seek=92 echo -en '\x22' | dd status=none of=$DISK conv=fsync bs=1 count=1 seek=92
xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2014 seek=34 xzcat ./boot/core.img.xz | dd status=none iflag=fullblock conv=fsync of=$DISK bs=512 count=2014 seek=34
echo -en '\x23' | dd of=$DISK conv=fsync bs=1 count=1 seek=17908 status=none echo -en '\x23' | dd of=$DISK conv=fsync bs=1 count=1 seek=17908 status=none
else else
vtdebug "This is MBR partition style ..." vtdebug "This is MBR partition style ..."
@@ -608,7 +608,7 @@ else
echo -en '\x80' | dd of=$DISK conv=fsync bs=1 count=1 seek=446 status=none echo -en '\x80' | dd of=$DISK conv=fsync bs=1 count=1 seek=446 status=none
echo -en '\x00' | dd of=$DISK conv=fsync bs=1 count=1 seek=462 status=none echo -en '\x00' | dd of=$DISK conv=fsync bs=1 count=1 seek=462 status=none
fi fi
xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2047 seek=1 xzcat ./boot/core.img.xz | dd status=none iflag=fullblock conv=fsync of=$DISK bs=512 count=2047 seek=1
fi fi
dd status=none conv=fsync if=./rsvdata.bin seek=2040 bs=512 count=8 of=${DISK} dd status=none conv=fsync if=./rsvdata.bin seek=2040 bs=512 count=8 of=${DISK}
@@ -616,7 +616,7 @@ else
check_umount_disk "$DISK" check_umount_disk "$DISK"
xzcat ./ventoy/ventoy.disk.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start xzcat ./ventoy/ventoy.disk.img.xz | dd status=none iflag=fullblock conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start
sync sync
vtinfo "esp partition processing ..." vtinfo "esp partition processing ..."