- read -p 'Continue? (y/n)' Answer
- if [ "$Answer" != "y" ]; then
- if [ "$Answer" != "Y" ]; then
- exit 0
- fi
- fi
-
- echo ""
- vtwarn "All the data on the disk $DISK will be lost!!!"
- read -p 'Double-check. Continue? (y/n)' Answer
- if [ "$Answer" != "y" ]; then
- if [ "$Answer" != "Y" ]; then
- exit 0
- fi
- fi
-
-
- if [ $disk_sector_num -le $VENTOY_SECTOR_NUM ]; then
- vterr "No enough space in disk $DISK"
- exit 1
- fi
-
- if ! dd if=/dev/zero of=$DISK bs=1 count=512 status=none conv=fsync; 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
-
- chmod +x ./tool/vtoy_gen_uuid
-
- vtinfo "writing data to disk ..."
- dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=446
- ./tool/xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2047 seek=1
- ./tool/xzcat ./ventoy/ventoy.disk.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector
-
- #disk uuid
- ./tool/vtoy_gen_uuid | dd status=none conv=fsync of=${DISK} seek=384 bs=1 count=16
-
- #disk signature
- ./tool/vtoy_gen_uuid | dd status=none conv=fsync of=${DISK} skip=12 seek=440 bs=1 count=4
-
- vtinfo "sync data ..."
- sync
-
- vtinfo "esp partition processing ..."
-
- if [ "$SECUREBOOT" != "YES" ]; then
- mkdir ./tmp_mnt
-
- vtdebug "mounting part2 ...."
- for tt in 1 2 3; do
- if mount ${DISK}2 ./tmp_mnt; then
- vtdebug "mounting part2 success"
- break
- fi
- sleep 2
- done
-
- rm -f ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
- rm -f ./tmp_mnt/EFI/BOOT/grubx64.efi
- rm -f ./tmp_mnt/EFI/BOOT/MokManager.efi
- rm -f ./tmp_mnt/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
- mv ./tmp_mnt/EFI/BOOT/grubx64_real.efi ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
-
- umount ./tmp_mnt
- rm -rf ./tmp_mnt
- fi
-
- echo ""
- vtinfo "Install Ventoy to $DISK successfully finished."
- echo ""
-