mirror of
				https://github.com/ventoy/Ventoy.git
				synced 2025-10-30 22:36:22 +00:00 
			
		
		
		
	Merge e13e4f7646 into 2dafe75509
				
					
				
			This commit is contained in:
		| @@ -312,22 +312,18 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then | |||||||
|  |  | ||||||
|     #format part1 |     #format part1 | ||||||
|     wait_and_create_part ${PART1} ${PART2}     |     wait_and_create_part ${PART1} ${PART2}     | ||||||
|     if [ -b ${PART1} ]; then |     vtinfo "Format partition 1 ${PART1}..." | ||||||
|         vtinfo "Format partition 1 ${PART1} ..." |     mkexfatfs -n "$VTNEW_LABEL" -s $cluster_sectors ${PART1} | ||||||
|  |     if [ $? -ne 0 ]; then | ||||||
|  |         vtwarn "mkexfatfs failed; retrying..." | ||||||
|         mkexfatfs -n "$VTNEW_LABEL" -s $cluster_sectors ${PART1} |         mkexfatfs -n "$VTNEW_LABEL" -s $cluster_sectors ${PART1} | ||||||
|         if [ $? -ne 0 ]; then |         if [ $? -ne 0 ]; then | ||||||
|             echo "mkexfatfs failed, now retry..." |             vterr "######## mkexfatfs failed, exit ########" | ||||||
|             mkexfatfs -n "$VTNEW_LABEL" -s $cluster_sectors ${PART1} |             exit 1 | ||||||
|             if [ $? -ne 0 ]; then |         fi | ||||||
|                 echo "######### mkexfatfs failed, exit ########" |  | ||||||
|                 exit 1 |  | ||||||
|             fi |  | ||||||
|         else |  | ||||||
|             echo "mkexfatfs success" |  | ||||||
|         fi         |  | ||||||
|     else |     else | ||||||
|         vterr "${PART1} NOT exist" |         vtinfo "mkexfatfs success" | ||||||
|     fi |     fi         | ||||||
|  |  | ||||||
|     vtinfo "writing data to disk ..." |     vtinfo "writing data to disk ..." | ||||||
|     dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=446 |     dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=446 | ||||||
|   | |||||||
| @@ -210,45 +210,73 @@ get_disk_ventoy_version() { | |||||||
|     ventoy_false |     ventoy_false | ||||||
| } | } | ||||||
|  |  | ||||||
| wait_and_create_part() { | wait_for_blockdevs() { | ||||||
|     vPART1=$1 |     attempts=3 | ||||||
|     vPART2=$2 |     delay=2 | ||||||
|     echo 'Wait for partitions $vPART1 and $vPART2 ...' |  | ||||||
|     for i in 0 1 2 3 4 5 6 7 8 9; do |     vtdebug "wait_for_blockdevs called with the following arguments:" | ||||||
|         if ls -l $vPART1 2>/dev/null | grep -q '^b'; then |     for dev in "$@"; do | ||||||
|             if ls -l $vPART2 2>/dev/null | grep -q '^b'; then |         vtdebug '  - '"$dev" | ||||||
|                 break |  | ||||||
|             fi |  | ||||||
|         else |  | ||||||
|             echo "Wait for $vPART1 and $vPART2 ..." |  | ||||||
|             sleep 1 |  | ||||||
|         fi |  | ||||||
|     done |     done | ||||||
|  |  | ||||||
|     if ls -l $vPART1 2>/dev/null | grep -q '^b'; then |     i= | ||||||
|         echo "$vPART1 exist OK" |     while [ $((i+=1)) -le $attempts ]; do | ||||||
|     else |         all_ready=0 | ||||||
|         MajorMinor=$(sed "s/:/ /" /sys/class/block/${vPART1#/dev/}/dev)         |  | ||||||
|         echo "mknod -m 0660 $vPART1 b $MajorMinor ..." |  | ||||||
|         mknod -m 0660 $vPART1 b $MajorMinor |  | ||||||
|     fi |  | ||||||
|      |  | ||||||
|     if ls -l $vPART2 2>/dev/null | grep -q '^b'; then |  | ||||||
|         echo "$vPART2 exist OK" |  | ||||||
|     else |  | ||||||
|         MajorMinor=$(sed "s/:/ /" /sys/class/block/${vPART2#/dev/}/dev)         |  | ||||||
|         echo "mknod -m 0660 $vPART2 b $MajorMinor ..." |  | ||||||
|         mknod -m 0660 $vPART2 b $MajorMinor         |  | ||||||
|     fi |  | ||||||
|  |  | ||||||
|     if ls -l $vPART1 2>/dev/null | grep -q '^b'; then |         echo "Waiting for block devices..." | ||||||
|         if ls -l $vPART2 2>/dev/null | grep -q '^b'; then |         for dev in "$@"; do | ||||||
|             echo "partition exist OK" |             if ! [ -b "$dev" ]; then | ||||||
|  |                 vtwarn "$dev not found." | ||||||
|  |                 all_ready=1 | ||||||
|  |                 break | ||||||
|  |             fi | ||||||
|  |         done | ||||||
|  |  | ||||||
|  |         if [ "$all_ready" -eq 0 ]; then | ||||||
|  |             vtinfo "Block devices ready!" | ||||||
|  |             return | ||||||
|         fi |         fi | ||||||
|     else |  | ||||||
|         echo "[FAIL] $vPART1/$vPART2 does not exist" |         echo 'Refreshing kernel partition table' | ||||||
|         exit 1 |         partprobe | ||||||
|     fi |  | ||||||
|  |         sleep "$delay" | ||||||
|  |     done | ||||||
|  |  | ||||||
|  |     vterr "Required block devices not ready." | ||||||
|  |     return 1 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | wait_and_create_part() { | ||||||
|  |     # Return immediately if devices found | ||||||
|  |     wait_for_blockdevs "$@" && return | ||||||
|  |  | ||||||
|  |     # Fallback: manually create fs nodes | ||||||
|  |     echo "Attempting to create device nodes in /dev/" | ||||||
|  |  | ||||||
|  |     for part in "$@"; do | ||||||
|  |         # Skip if device found | ||||||
|  |         [ -b $part ] && continue | ||||||
|  |      | ||||||
|  |         MajorMinor=$(sed "s/:/ /" /sys/class/block/${part#/dev/}/dev)         | ||||||
|  |         echo ">> mknod -m 0660 $part b $MajorMinor..." | ||||||
|  |         mknod -m 0660 $part b $MajorMinor | ||||||
|  |  | ||||||
|  |         if [ "$?" -ne 0 ]; then | ||||||
|  |             vterr 'Creating device node failed' | ||||||
|  |             exit 1 | ||||||
|  |         fi | ||||||
|  |     done | ||||||
|  |      | ||||||
|  |     partprobe | ||||||
|  |     echo "Confirming partitions are now available..." | ||||||
|  |      | ||||||
|  |     # Return if success | ||||||
|  |     wait_for_blockdevs "$@" && return | ||||||
|  |  | ||||||
|  |     # RIP | ||||||
|  |     vterr 'Cannot proceed -- please check your device. Try re-plugging or using a different USB port or device.' | ||||||
|  |     exit 1 | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user