Change to pull partition number from the image rather than hardcoded

This commit is contained in:
Drew Bonasera 2016-04-27 04:33:21 -04:00
parent e3b321a9d7
commit f45603840e
1 changed files with 2 additions and 1 deletions

View File

@ -25,6 +25,7 @@ fi
#Gather info
beforesize=`ls -lah $img | cut -d ' ' -f 5`
partnum=`parted -m $img unit B print | tail -n 1 | cut -d ':' -f 1 | tr -d '\n'`
partstart=`parted -m $img unit B print | tail -n 1 | cut -d ':' -f 2 | tr -d 'B\n'`
loopback=`losetup -f --show -o $partstart $img`
@ -64,7 +65,7 @@ sleep 1
losetup -d $loopback
partnewsize=`expr $minsize \* 4096 | tr -d '\n'`
newpartend=`expr $partstart + $partnewsize | tr -d '\n'`
part1=`parted $img rm 2`
part1=`parted $img rm $partnum`
part2=`parted $img unit B mkpart primary $partstart $newpartend`
#Truncate the file