Make caching file for imporoving performance. 08/123508/2 accepted/tizen/4.0/unified/20170816.012714 accepted/tizen/4.0/unified/20170829.020323 accepted/tizen/unified/20170406.173313 submit/tizen/20170406.045247 submit/tizen_4.0/20170811.094300 submit/tizen_4.0/20170828.100004 submit/tizen_4.0/20170828.110004 tizen_4.0.m1_release
authorYunmi Ha <yunmi.ha@samsung.com>
Thu, 6 Apr 2017 01:58:13 +0000 (10:58 +0900)
committerYunmi Ha <yunmi.ha@samsung.com>
Thu, 6 Apr 2017 04:19:32 +0000 (13:19 +0900)
Previously, init.sh resize and check the filesystem every time.
It makes growing in booting time.
To reduce this, init.sh makes chache file for checking first boot or not.
Only when boot the first time, init.sh will resize and check the filesystem.

Change-Id: I31dbe37e59029365098b45cdfcb0dba95a11d8c0
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
scripts/init.sh

index 56c51e5..e23f161 100755 (executable)
@@ -5,6 +5,7 @@ mount -o nosuid,noexec,nodev -t sysfs sysfs /sys
 mount -o nosuid,noexec,nodev -t proc proc /proc
 
 /bin/mkdir /sysroot
+/bin/mkdir /opt
 
 #Find devices
 ROOTFS=`/sbin/blkid -L rootfs`
@@ -26,10 +27,27 @@ then
 fi
 
 #Check and mount devices
+FIRSTBOOT=1
+if [ x"$DATAFS" != "x" ]
+then
+    /bin/mount $DATAFS /opt
+
+    if [ -e /opt/var/.fsck_done ]
+    then
+        FIRSTBOOT=0
+    else
+        echo " " > /opt/var/.fsck_done
+        /bin/umount /opt
+    fi
+fi
+
 if [ x$ROOTFS != "x" ]
 then
-    /sbin/fsck -y $ROOTFS
-    /sbin/resize2fs -f $ROOTFS
+    if [ "$FIRSTBOOT" = "1" ]
+    then
+        /sbin/resize2fs -f $ROOTFS
+        /sbin/fsck -y $ROOTFS
+    fi
     /bin/mount $ROOTFS /sysroot
 else
     echo "WARNING : THERE IS NO ROOTFS."
@@ -38,16 +56,24 @@ fi
 
 if [ x$MODULES != "x" ]
 then
-    /sbin/fsck -y $MODULES
-    /sbin/resize2fs -f $MODULES
+    if [ "$FIRSTBOOT" = "1" ]
+    then
+        /sbin/resize2fs -f $MODULES
+        /sbin/fsck -y $MODULES
+    fi
     /bin/mount $MODULES /sysroot/usr/lib/modules
 fi
 
 if [ x"$DATAFS" != "x" ]
 then
-    /sbin/fsck -y $DATAFS
-    /sbin/resize2fs -f $DATAFS
-    /bin/mount $DATAFS /sysroot/opt
+    if [ "$FIRSTBOOT" = "1" ]
+    then
+        /sbin/resize2fs -f $DATAFS
+        /sbin/fsck -y $DATAFS
+        /bin/mount $DATAFS /sysroot/opt
+    else
+        /bin/mount -M /opt /sysroot/opt
+    fi
 fi
 
 cd /sysroot