Add some functions in init.wrapper 21/114621/1 accepted/tizen/common/20170215.170628 accepted/tizen/ivi/20170214.225826 accepted/tizen/mobile/20170214.225724 accepted/tizen/tv/20170214.225745 accepted/tizen/wearable/20170214.225813 submit/tizen/20170214.082432
authorsilas jeon <silasjeon@samsung.com>
Tue, 14 Feb 2017 07:54:28 +0000 (16:54 +0900)
committersilas jeon <silasjeon@samsung.com>
Tue, 14 Feb 2017 08:13:24 +0000 (17:13 +0900)
Now it resizes rootfs. Resizing was originally done by systemd-r-
size service. But now read-only option is going to be applied, so
it can not be done as systemd service. So init.wrapper took the
job. Initrd will take the resizing job later.

Also now it uses both of 'partlabel' and 'label' to find the disk.
Before this commit it did not find the disk by 'partlabel', so it
has not been working.

Change-Id: Ibb56a459e614b3f83651806c246fe3b877e5441d

scripts/init.wrapper

index a2f9379..1ee8917 100644 (file)
@@ -5,33 +5,50 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin
 SYSTEM_MNT=/opt
 SYS_BLK_DIR=/sys/class/block
 
-/usr/bin/mount -t proc none /proc
-/usr/bin/mount -t sysfs none /sys
+mount -o nosuid,strictatime,mode=755 -t devtmpfs devtmpfs /dev
+mount -o nosuid,noexec,nodev -t sysfs sysfs /sys
+mount -o nosuid,noexec,nodev -t proc proc /proc
 
-DISK_LIST=`ls $SYS_BLK_DIR`
+ROOTFS=`/sbin/blkid -L rootfs`
+if [ x$ROOTFS = "x" ]
+then
+ROOTFS=`/sbin/blkid -t PARTLABEL=rootfs -o device`
+fi
+
+DATAFS=`/sbin/blkid -L system-data`
+if [ x$DATAFS = "x" ]
+then
+DATAFS=`/sbin/blkid -t PARTLABEL=system-data -o device`
+fi
 
-for BLK_NAME in $DISK_LIST
-do
-lsblk -r -n -d --output LABEL,PARTLABEL /dev/$BLK_NAME | grep -qi "system-data"
-if [ $? = "0" ] 
+if [ "$ROOTFS" == "" ]
 then
-SYSTEM_DISK=/dev/$BLK_NAME
-break
+    echo "Warning : There is no rootfs partition."
+else
+    /usr/bin/mount | grep "$ROOTFS " > /dev/null
+
+    if [ $? = "0" ]
+    then
+        /usr/bin/mount -o remount,rw $ROOTFS
+    fi
+
+    /sbin/fsck $ROOTFS
+    /sbin/resize2fs -f $ROOTFS
 fi
-done
 
-if [ "$SYSTEM_DISK" == "" ]
+
+if [ "$DATAFS" == "" ]
 then
     echo "Warning : There is no system-data partition."
 else
-    /usr/bin/mount | grep "$SYSTEM_MNT " > /dev/null
+    /usr/bin/mount | grep "$DATAFS " > /dev/null
 
     if [ $? = "0" ]
     then
-        /usr/bin/umount -l "$SYSTEM_MNT"
+        /usr/bin/umount -l "DATAFS"
     fi
 
-    /usr/bin/mount $SYSTEM_DISK $SYSTEM_MNT
+    /usr/bin/mount $DATAFS $SYSTEM_MNT
 fi
 
 INIT=/usr/lib/systemd/systemd
@@ -43,3 +60,4 @@ echo "======================================================================"
 echo "[/sbin/init] WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
 echo "This Message should be never printed. ($INIT execution failure?)"
 echo "======================================================================"
+exec /bin/sh