cfdisk 섹터 끝 값을 사용하여 파티션 크기를 계산하는 방법은 무엇입니까?

cfdisk 섹터 끝 값을 사용하여 파티션 크기를 계산하는 방법은 무엇입니까?

~에서cfdisk디스크에 대한 통계, 즉 첫 번째부터 세 번째 파티션까지의 각 파티션의 끝 섹터와 여유 공간의 끝 부분에 대한 통계를 얻을 수 있었습니다. 파티션 크기를 계산하려고 하는데 문제가 있습니다. 일부 파티션의 크기를 조정할 때 크기가 확실히 올바르지 않습니다.cfdisk분석 후. 무엇이 잘못되었는지 이해하도록 도와주세요!

#!/bin/bash
#This setsetcor script takes three arguments: setsector a b c d
#Both a, b, and c are integers

a=$1; #The end (in 512 byte sectors) of the sdx1 partition
b=$2; #The end (in 512 byte sectors) of the sdx2 partition
c=$3; #The end (in 512 byte sectors) of the sdx3 partition
d=$4; #The end (in 512 byte sectors) of the free space
e=$5; #The adjustment factor

#The result a-b-c-d

printf "The end (in 512 byte sectors) of the sdx1 partition is a=%d \n" $((a))
printf "The end (in 512 byte sectors) of the sdx2 partition is b=%d \n" $((b))
printf "The end (in 512 byte sectors) of the sdx3 partition is c=%d \n" $((c))
printf "The end (in 512 byte sectors) of the free space     is d=%d \n" $((d))
printf "The adjustment factor                               is e=%d \n" $((e))
printf "The number of sectors (512-Bytes erach) for parition 3 equals %dS .  \n" $(( $((c))-$((b))+$((e))))
printf "The number of sectors (512-Bytes erach) for parition 2 equals %dS .  \n" $(( $((b))-$((a))+$((e))))
printf "The number of sectors (512-Bytes erach) for the free space is %dS .  \n" $(( $((d))-$((c))+$((e))))
printf "The number of sectors (512-Bytes erach) for the drive size is %dS .  \n" $(( 0 ))
# printf "The initial size of sdx3 is d-c+e. \n"

관련 정보