do not truncate if used directly on the SD

This commit is contained in:
Csaba Kiraly 2016-11-24 11:59:51 +01:00
parent 9b55197d9b
commit 57a69657c8
1 changed files with 6 additions and 5 deletions

View File

@ -150,8 +150,9 @@ part1=`parted $img rm $partnum`
part2=`parted $img unit B mkpart primary $partstart $newpartend` part2=`parted $img unit B mkpart primary $partstart $newpartend`
#Truncate the file #Truncate the file
if [[ -f $img ]]; then
endresult=`parted -m $img unit B print free | tail -1 | cut -d ':' -f 2 | tr -d 'B\n'` endresult=`parted -m $img unit B print free | tail -1 | cut -d ':' -f 2 | tr -d 'B\n'`
truncate -s $endresult $img truncate -s $endresult $img
aftersize=`ls -lah $img | cut -d ' ' -f 5` aftersize=`ls -lah $img | cut -d ' ' -f 5`
echo "Shrunk $img from $beforesize to $aftersize" echo "Shrunk $img from $beforesize to $aftersize"
fi