summaryrefslogtreecommitdiff
path: root/recipes-core
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-core')
-rw-r--r--recipes-core/multitech/overlayfs-init/overlayfs.init59
1 files changed, 45 insertions, 14 deletions
diff --git a/recipes-core/multitech/overlayfs-init/overlayfs.init b/recipes-core/multitech/overlayfs-init/overlayfs.init
index 4da6217..72a6217 100644
--- a/recipes-core/multitech/overlayfs-init/overlayfs.init
+++ b/recipes-core/multitech/overlayfs-init/overlayfs.init
@@ -1,4 +1,10 @@
#!/bin/bash
+# To turn on systemd debug:
+# setenv bootargs "systemd.log_level=debug console=ttymxc0,115200 ubi.mtd=nandubi root=ubi0:rootfs rootfstype=ubifs ro
+# rootflags=chk_data_crc mtdparts=gpmi-nand:4m(nandboot),-(nandubi)"
+
+# Command to erase user data file system
+# Modified for ubifs, secure boot (no U-Boot access)
MNT_USER="/mnt/user"
OVERLAY="$MNT_USER/overlay"
@@ -6,22 +12,32 @@ WORKDIR="$MNT_USER/work"
UPPERDIR="$MNT_USER/upper"
LOWERDIR="/"
USER_ORIG="$UPPERDIR/orig"
-USER_PARTITION="/dev/mtdblock9"
+USER_PARTITION="ubi0:user-data"
DO_ERASE_USERDATA_FILE="/mnt/user/.persistent/mts_do_erase_userdata"
+DO_CLEAR_USERDATA_FILE="/mnt/user/.persistent/mts_do_clear_userdata"
-loginfo() { logger -s -t overlayfs "info: $@" 1>&2 ; }
+pid=$$
+prefix="<3>overlayrootfs-generator[${pid}]: "
+loginfo() { echo "${prefix}$@" >/dev/kmsg ; }
+logpipe() { cat <(echo -n "${prefix}") - >/dev/kmsg ; }
mnt_user() {
mkdir -p $MNT_USER
- mount -t jffs2 $USER_PARTITION $MNT_USER
+ mount -t ubifs $USER_PARTITION $MNT_USER
}
-switch_root() {
+fs="/run /dev /proc /sys /sys/kernel/security /dev/shm /dev/pts /run /sys/fs/cgroup /sys/fs/cgroup/unified
+ /sys/fs/cgroup/systemd /sys/fs/cgroup/devices /sys/fs/cgroup/freezer /sys/fs/cgroup/pids /sys/fs/cgroup/memory
+ /dev/mqueue /sys/kernel/debug /tmp /sys/fs/fuse/connections /sys/kernel/config /var/volatile"
+
+my_switch_root() {
NEW_ROOT=$1
- mount -o noatime,move --bind /run $NEW_ROOT/run
- mount -o noatime,move --bind /dev $NEW_ROOT/dev
- mount -o noatime,move --bind /proc $NEW_ROOT/proc
- mount -o noatime,move --bind /sys $NEW_ROOT/sys
+ echo mountinfo >&2
+ cat /proc/mounts >&2
+ mount --make-rprivate /
+ for f in $fs ; do
+ mount -o noatime,move --bind $f $NEW_ROOT/$f
+ done
/sbin/pivot_root $NEW_ROOT $NEW_ROOT/orig
}
@@ -57,21 +73,36 @@ do_rw_mount() {
mnt_user
do_remove_old
-
- if u-boot printenv default_reset_f; then
+ if [[ -f $DO_CLEAR_USERDATA_FILE ]] || [[ -f $DO_ERASE_USERDATA_FILE ]] ; then
do_select_old
do_remove_old
- u-boot setenv default_reset_f
+ rm -f $DO_CLEAR_USERDATA_FILE
fi
mkdir -p $UPPERDIR $WORKDIR $OVERLAY $USER_ORIG ${MNT_USER}/.persistent
loginfo "Mounting..."
- mount -o noatime,lowerdir=$LOWERDIR,upperdir=$UPPERDIR,workdir=$WORKDIR -t overlay overlay $OVERLAY
+ set -x
+ mount -o noatime,lowerdir=$LOWERDIR,upperdir=$UPPERDIR,workdir=$WORKDIR,rw -t overlay overlay $OVERLAY
+ loginfo "JAK: What does overlay look like in /proc/mounts?"
+ cat /proc/mounts | grep overlay | logpipe
mkdir -p ${OVERLAY}/var/persistent
- mount --bind ${MNT_USER}/.persistent ${OVERLAY}/var/persistent
- switch_root $OVERLAY
+ mount --bind ${MNT_USER}/.persistent ${OVERLAY}/var/persistent
+ loginfo "Switch root to $OVERLAY"
+ my_switch_root $OVERLAY
+ cat /proc/mounts | grep overlay >&2
+ mount -o remount,rw /
+ cat /proc/mounts | grep overlay | logpipe
+ cat /proc/mounts | grep tmp | logpipe
+ umount -l /tmp
+ umount -l /var/volatile
+ cgroupmnts=$(sed -r -e 's/[^[:space:]]*[[:space:]]//' -e 's/[[:space:]]+.*//g' /proc/mounts | grep '^/orig')
+ for mp in ${cgroupmnts} ; do
+ if [[ $mp != /orig ]] ; then
+ umount -l $mp
+ fi
+ done
}
do_start() {