X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/1e4965cb245cd9e597d9b875ad9624a2c7b9292c..f77ba141fdd0372c7ccc79f8de7eee771e65aba7:/INSTALL/tool/ventoy_lib.sh diff --git a/INSTALL/tool/ventoy_lib.sh b/INSTALL/tool/ventoy_lib.sh index 803375d..7387ed1 100644 --- a/INSTALL/tool/ventoy_lib.sh +++ b/INSTALL/tool/ventoy_lib.sh @@ -22,40 +22,17 @@ ventoy_is_linux64() { ventoy_false } -ventoy_is_dash() { - if [ -L /bin/sh ]; then - vtdst=$(readlink /bin/sh) - if [ "$vtdst" = "dash" ]; then - ventoy_true - return - fi - fi - ventoy_false -} - vtinfo() { - if ventoy_is_dash; then - echo "\033[32m$*\033[0m" - else - echo -e "\033[32m$*\033[0m" - fi + echo -e "\033[32m$*\033[0m" } vtwarn() { - if ventoy_is_dash; then - echo "\033[33m$*\033[0m" - else - echo -e "\033[33m$*\033[0m" - fi + echo -e "\033[33m$*\033[0m" } vterr() { - if ventoy_is_dash; then - echo "\033[31m$*\033[0m" - else - echo -e "\033[31m$*\033[0m" - fi + echo -e "\033[31m$*\033[0m" } vtdebug() { @@ -207,9 +184,9 @@ get_disk_ventoy_version() { ventoy_false } - format_ventoy_disk() { DISK=$1 + PART1=$(get_disk_part_name $DISK 1) PART2=$(get_disk_part_name $DISK 2) sector_num=$(cat /sys/block/${DISK#/dev/}/size) @@ -219,15 +196,30 @@ format_ventoy_disk() { export part2_start_sector=$(expr $part1_end_sector + 1) part2_end_sector=$(expr $sector_num - 1) + vtdebug "part1_start_sector=$part1_start_sector part1_end_sector=$part1_end_sector" + vtdebug "part2_start_sector=$part2_start_sector part2_end_sector=$part2_end_sector" + if [ -e $PART2 ]; then echo "delete $PART2" rm -f $PART2 fi echo "" - echo "Create partitions on $DISK ..." + echo "Create partitions on $DISK by $2 ..." -fdisk $DISK >/dev/null 2>&1 <>./log.txt 2>&1 </dev/null 2>&1 partprobe >/dev/null 2>&1 @@ -264,7 +257,11 @@ EOF sleep 1 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) echo "mknod -m 0660 $PART2 b $MajorMinor ..." @@ -288,7 +285,3 @@ EOF fi done } - - - -