OSDN Git Service

mkuserimg_mke2fs.sh: calculate size automatically
authorChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 26 Feb 2019 13:59:39 +0000 (21:59 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 26 Feb 2019 13:59:39 +0000 (21:59 +0800)
Add extra size by the $SRC_DIR size plus 10%.

ext4_utils/mkuserimg_mke2fs.sh

index 408b4c9..750ac73 100755 (executable)
@@ -160,6 +160,9 @@ fi
 if [ -z $SIZE ]; then
   echo "Need size of filesystem"
   exit 2
+elif [ 0 -eq 0$SIZE ]; then
+  s=$(du -sm $SRC_DIR | cut -f1)
+  SIZE=$(($s / 10 + $s))M
 fi
 
 # Round down the filesystem length to be a multiple of the block size