summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsilas jeon <silasjeon@samsung.com>2017-02-14 16:54:28 +0900
committersilas jeon <silasjeon@samsung.com>2017-02-14 17:13:24 +0900
commit97b6c51f896e3097ad6bb137df101803c93da2d5 (patch)
tree79229f94be324f474666e74cbd45e9ab69b811b0
parent192ed9c81d78255654022d30ffe522261f4071b9 (diff)
downloadsystem-plugin-97b6c51f896e3097ad6bb137df101803c93da2d5.tar.gz
system-plugin-97b6c51f896e3097ad6bb137df101803c93da2d5.tar.bz2
system-plugin-97b6c51f896e3097ad6bb137df101803c93da2d5.zip
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
-rw-r--r--scripts/init.wrapper46
1 files changed, 32 insertions, 14 deletions
diff --git a/scripts/init.wrapper b/scripts/init.wrapper
index a2f9379..1ee8917 100644
--- a/scripts/init.wrapper
+++ b/scripts/init.wrapper
@@ -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