format_ventoy_disk() {
DISK=$1
+ PARTTOOL=$2
+
PART1=$(get_disk_part_name $DISK 1)
PART2=$(get_disk_part_name $DISK 2)
fi
echo ""
- echo "Create partitions on $DISK by $2 ..."
+ echo "Create partitions on $DISK by $PARTTOOL ..."
- if [ "$2" = "parted" ]; then
+ if [ "$PARTTOOL" = "parted" ]; then
vtdebug "format disk by parted ..."
parted -a none --script $DISK \
mklabel msdos \
unit s \
mkpart primary ntfs $part1_start_sector $part1_end_sector \
mkpart primary fat16 $part2_start_sector $part2_end_sector \
- set 2 boot on \
+ set 1 boot on \
quit
+
+ sync
+ echo -en '\xEF' | dd of=$DISK conv=fsync bs=1 count=1 seek=466 > /dev/null 2>&1
else
vtdebug "format disk by fdisk ..."
2
ef
a
-2
+1
w
EOF
fi
- echo "Done"
udevadm trigger >/dev/null 2>&1
partprobe >/dev/null 2>&1
sleep 3
+ echo "Done"
echo 'mkfs on disk partitions ...'
for i in 1 2 3 4 5 6 7; do
fi
done
- if [ "$2" = "parted" ]; then
- echo -en '\xEF' | dd of=$DISK conv=fsync bs=1 count=1 seek=466
- fi
if ! [ -b $PART2 ]; then
MajorMinor=$(sed "s/:/ /" /sys/class/block/${PART2#/dev/}/dev)
fi
fi
- echo "create efi fat fs ..."
+ echo "create efi fat fs $PART2 ..."
for i in 0 1 2 3 4 5 6 7 8 9; do
if mkfs.vfat -F 16 -n EFI $PART2; then
echo 'success'