]> glassweightruler.freedombox.rocks Git - Ventoy.git/blobdiff - INSTALL/tool/ventoy_lib.sh
1. Add a new feature to directly boot wim files
[Ventoy.git] / INSTALL / tool / ventoy_lib.sh
index 7387ed15f036b88082381507831b58f79739e293..dd9e09594166cb7b29251c640eae64fe11e5f79b 100644 (file)
@@ -186,6 +186,8 @@ get_disk_ventoy_version() {
 
 format_ventoy_disk() {
     DISK=$1
+    PARTTOOL=$2
+    
     PART1=$(get_disk_part_name $DISK 1)
     PART2=$(get_disk_part_name $DISK 2)
     
@@ -205,9 +207,9 @@ format_ventoy_disk() {
     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 \
@@ -216,6 +218,9 @@ format_ventoy_disk() {
             mkpart primary fat16 $part2_start_sector $part2_end_sector \
             set 2 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 ..."
     
@@ -243,10 +248,10 @@ 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
@@ -258,9 +263,6 @@ EOF
         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)        
@@ -274,7 +276,7 @@ EOF
         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'
@@ -285,3 +287,7 @@ EOF
         fi
     done
 }
+
+
+
+