fix gen ext2 img error

when the SIZE is less than the final img size,
genext2fs will get error "not enough space".

Change-Id: Ie452d8532838151682d5568d9e45f379b8846916
Signed-off-by: hertz.wang <wangh@rock-chips.com>
This commit is contained in:
hertz.wang
2018-09-06 12:41:31 +08:00
committed by hertz.wong
parent 8bc2695427
commit fcad1e5256

View File

@ -2,10 +2,13 @@
SRC=$1
DST=$2
SIZE=`du -s --apparent-size $SRC | cut --fields=1`
SIZE=`expr '(' '(' $SIZE / 1024 ')' + 3 ')' '*' 1024 `
inode_counti=`expr '(' $SIZE / 4 ')'`
echo "SIZE = $SIZE"
SIZE=`du -sk --apparent-size $SRC | cut --fields=1`
inode_counti=`find $SRC | wc -l`
inode_counti=$[inode_counti+512]
EXTRA_SIZE=$[inode_counti*4]
SIZE=$[SIZE+EXTRA_SIZE]
echo "genext2fs -b $SIZE -N $inode_counti -d $SRC $DST"
genext2fs -b $SIZE -N $inode_counti -d $SRC $DST
tune2fs -C 1 $DST
resize2fs -M $DST
e2fsck -fy $DST