- if ! dd if=/dev/zero of=$DISK bs=1 count=512 status=none; then
- vterr "Write data to $DISK failed, please check whether it's in use."
- exit 1
- fi
-
- format_ventoy_disk $DISK
-
- # format part1
- if ventoy_is_linux64; then
- cmd=./tool/mkexfatfs_64
- else
- cmd=./tool/mkexfatfs_32
- fi
-
- chmod +x ./tool/*
-
- # DiskSize > 32GB Cluster Size use 128KB
- # DiskSize < 32GB Cluster Size use 32KB
- if [ $disk_size_gb -gt 32 ]; then
- cluster_sectors=256
- else
- cluster_sectors=64
- fi
-
- $cmd -n ventoy -s $cluster_sectors ${DISK}1
-
- dd status=none if=./boot/boot.img of=$DISK bs=1 count=446
- ./tool/xzcat ./boot/core.img.xz | dd status=none of=$DISK bs=512 count=2047 seek=1
- ./tool/xzcat ./ventoy/ventoy.disk.img.xz | dd status=none of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector
-
-
- chmod +x ./tool/vtoy_gen_uuid
- ./tool/vtoy_gen_uuid | dd status=none of=${DISK} seek=384 bs=1 count=16
-
- sync
-
- echo ""
- vtinfo "Install Ventoy to $DISK successfully finished."
- echo ""
-
-else
- vtdebug "update ventoy ..."
-
- oldver=$(get_disk_ventoy_version $DISK)
- if [ $? -ne 0 ]; then
- vtwarn "$DISK does not contain ventoy or data corupted"
- echo ""
- vtwarn "Please use -i option if you want to install ventoy to $DISK"
- echo ""
- exit 1
- fi
-
- curver=$(cat ./ventoy/version)
-
- vtinfo "Upgrade operation is safe, all the data in the 1st partition (iso files and other) will be unchanged!"
- echo ""
-
- read -p "Update Ventoy $oldver ===> $curver Continue? (y/n)" Answer
- if [ "$Answer" != "y" ]; then
- if [ "$Answer" != "Y" ]; then
- exit 0
- fi
- fi
-
- PART2=$(get_disk_part_name $DISK 2)
-
- dd status=none if=./boot/boot.img of=$DISK bs=1 count=446
-
- ./tool/xzcat ./boot/core.img.xz | dd status=none of=$DISK bs=512 count=2047 seek=1
-
- disk_sector_num=$(cat /sys/block/${DISK#/dev/}/size)
- part2_start=$(expr $disk_sector_num - $VENTOY_SECTOR_NUM)
- ./tool/xzcat ./ventoy/ventoy.disk.img.xz | dd status=none of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start
-
- sync