cfdiskセクタエンド値を使用してパーティションサイズを計算する方法は?

cfdiskセクタエンド値を使用してパーティションサイズを計算する方法は?

~からcfdiskディスクの統計、つまり最初から3番目のパーティションまでの各パーティションの終了セクタと空き領域の終わりに関する統計を取得できました。パーティションサイズを計算しようとして問題があります。一部のパーティションのサイズを変更すると、サイズは間違いなく正しくありません。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"

ベストアンサー1

おすすめ記事