calculate extra space properly on depending on blocksize

This commit is contained in:
Simone Karin Lehmann 2018-03-16 22:18:15 +01:00 committed by Simone Karin Lehmann
parent b7fd6adc6f
commit b24a244894
1 changed files with 2 additions and 2 deletions

View File

@ -47,8 +47,8 @@ blocksize=$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':
e2fsck -y -f "$loopback" e2fsck -y -f "$loopback"
minsize=$(resize2fs -P "$loopback" | cut -d ':' -f 2 | tr -d ' ') minsize=$(resize2fs -P "$loopback" | cut -d ':' -f 2 | tr -d ' ')
# add ~200 MB of extra space, the system may need it to run # add 200 MB of extra space, the system may need it to run, minsize is in blocks unit
minsize=$(($minsize + 50000)) minsize=$(($minsize + 200 * 1048576 / $blocksize))
if [[ $minsize -gt $currentsize ]]; then if [[ $minsize -gt $currentsize ]]; then
echo "ERROR: Image already shrunk to smallest size" echo "ERROR: Image already shrunk to smallest size"