All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH openbmc 0/7] initfs: check and auto-repair read/write file system
@ 2016-02-07  0:00 OpenBMC Patches
  2016-02-07  0:00 ` [PATCH openbmc 1/7] obmc-initfs: minor updates OpenBMC Patches
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: OpenBMC Patches @ 2016-02-07  0:00 UTC (permalink / raw)
  To: openbmc

This series of patches to the obmc init, shutdown, and update scripts adds several features, including

Run fsck on the read write filesystem before mounting.
More information on what to do and options when init fails
Consistent location of update images even during init repair cases

Plus these developer features
All mount arguments consolidated into variables
Clean unmount when testing rofs image in RAM (from the /run file system)
Other clean ups

This second version has 1 update over the first version #165.  The prior version had
mistakenly used rodir for both device and directory options to mount in "use variables" patch.  I had caught and corrected when moving the line up in the "run fsck" patch but missed the same error occurred in the prior location.

i've now done a boot and shutdown test on each of the patches and an update of u-boot-env on most of them.  In addition I've used the penultimate and final version several times including the debug-init-sh option and the failed to fsck path and done end-to-end image-rwfs update with preserved files.


https://github.com/openbmc/openbmc/pull/166

Milton Miller (7):
  obmc-initfs: minor updates
  obmc-initfs: look for images in /run/initramfs/image-
  obmc-initfs: use varables for paths and mount arguments
  obmc-initfs: factor debug and takeover
  obmc-initfs: run fsck on read/write file system
  obmc-initfs: run update as a sub-script
  obmc-initfs: shutdown when rofs is a loop mounted image in /run

 .../obmc-phosphor-initfs/files/obmc-init.sh        | 91 +++++++++++++++++-----
 .../obmc-phosphor-initfs/files/obmc-shutdown.sh    | 22 ++++--
 .../obmc-phosphor-initfs/files/obmc-update.sh      | 59 +++++++-------
 3 files changed, 114 insertions(+), 58 deletions(-)

-- 
2.6.4

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH openbmc 1/7] obmc-initfs: minor updates
  2016-02-07  0:00 [PATCH openbmc 0/7] initfs: check and auto-repair read/write file system OpenBMC Patches
@ 2016-02-07  0:00 ` OpenBMC Patches
  2016-02-08 16:25   ` Brad Bishop
  2016-02-09  0:55   ` Andrew Jeffery
  2016-02-07  0:00 ` [PATCH openbmc 2/7] obmc-initfs: look for images in /run/initramfs/image- OpenBMC Patches
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 18+ messages in thread
From: OpenBMC Patches @ 2016-02-07  0:00 UTC (permalink / raw)
  To: openbmc

From: Milton Miller <miltonm@us.ibm.com>

In shutdown, Like init and update, cd to / to be clear the
expected environment.  Although shorter names are not used, it
prevents problems with unmounting filesystems, even if this is
the normal state for a call of this script by systemd.  Also
make a few paths absolute and don't follow symlinks in ln.

In init, check the new init is an executable file with non-zero
size in addition to the shell being executable with its shared
libraries.

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
---
 .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh       | 4 ++--
 .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh   | 7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
index 0dc4c35..f0d8522 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
@@ -69,9 +69,9 @@ mkdir -p $work
 
 mount -t overlay -o lowerdir=$rodir,upperdir=$upper,workdir=$work cow /root
 
-if ! chroot /root /bin/sh -c exit
+if ! chroot /root /bin/sh -c "test -x /sbin/init -a -s /sbin/init"
 then
-	echo 'chroot test failed; invoking emergency shell.'
+	echo "Change Root test failed!  Invoking emergency shell."
 	PS1=rescue#\  sulogin
 fi
 
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
index cc076fd..c550e06 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
@@ -5,10 +5,11 @@ echo shutdown: "$@"
 export PS1=shutdown-sh#\ 
 # exec bin/sh
 
+cd /
 if [ ! -e /proc/mounts ]
 then
 	mkdir -p /proc
-	mount  proc proc -tproc
+	mount  proc /proc -tproc
 	umount_proc=1
 else
 	umount_proc=
@@ -27,10 +28,10 @@ set +x
 if test -s /run/fw_env -a -c /run/mtd:u-boot-env -a ! -e /image-u-boot-env &&
 	! cmp /run/mtd:u-boot-env /run/fw_env
 then
-	ln -s /run/fw_env /image-u-boot-env
+	ln -sn /run/fw_env /image-u-boot-env
 fi
 
-if test -x /update && ls image-* > /dev/null 2>&1
+if test -x /update && ls /image-* > /dev/null 2>&1
 then
 	exec /update ${1+"$@"}
 fi
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH openbmc 2/7] obmc-initfs: look for images in /run/initramfs/image-
  2016-02-07  0:00 [PATCH openbmc 0/7] initfs: check and auto-repair read/write file system OpenBMC Patches
  2016-02-07  0:00 ` [PATCH openbmc 1/7] obmc-initfs: minor updates OpenBMC Patches
@ 2016-02-07  0:00 ` OpenBMC Patches
  2016-02-08 16:25   ` Brad Bishop
  2016-02-07  0:00 ` [PATCH openbmc 3/7] obmc-initfs: use varables for paths and mount arguments OpenBMC Patches
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: OpenBMC Patches @ 2016-02-07  0:00 UTC (permalink / raw)
  To: openbmc

From: Milton Miller <miltonm@us.ibm.com>

Teach update to look for /run/initramfs/image- not /image-*.

When describing how to recover from a corrupted flash by grabbing
the images and running update from the init debug shell, it
became aparent that while at systemd shutdown /run/initramfs/
is mounted at /, it is not the case during init.  Use variable
image to hold this pathname.

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
---
 .../obmc-phosphor-initfs/files/obmc-shutdown.sh              |  7 ++++---
 .../obmc-phosphor-initfs/files/obmc-update.sh                | 12 ++++++------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
index c550e06..d530265 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
@@ -25,13 +25,14 @@ do
 done
 set +x
 
-if test -s /run/fw_env -a -c /run/mtd:u-boot-env -a ! -e /image-u-boot-env &&
+image=/run/initramfs/image-
+if test -s /run/fw_env -a -c /run/mtd:u-boot-env -a ! -e ${image}u-boot-env &&
 	! cmp /run/mtd:u-boot-env /run/fw_env
 then
-	ln -sn /run/fw_env /image-u-boot-env
+	ln -sn /run/fw_env ${image}u-boot-env
 fi
 
-if test -x /update && ls /image-* > /dev/null 2>&1
+if test -x /update && ls $image* > /dev/null 2>&1
 then
 	exec /update ${1+"$@"}
 fi
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
index 1122e83..f83b1ad 100755
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
@@ -61,10 +61,10 @@ then
 	umount rw
 fi
 
-
-for f in image-*
+image=/run/initramfs/image-
+for f in $image*
 do
-	m=$(findmtd ${f#image-})
+	m=$(findmtd ${f#$image})
 	if test -z "$m"
 	then
 		echo 1>&2  "Unable to find mtd partiton for $f"
@@ -72,10 +72,10 @@ do
 	fi
 done
 
-for f in image-*
+for f in $image*
 do
-	m=$(findmtd ${f#image-})
-	echo "Updating ${f#image-}"
+	m=$(findmtd ${f#$image})
+	echo "Updating ${f#$image}..."
 	# flasheraseall /dev/$m && dd if=$f of=/dev/$m
 	flashcp -v $f /dev/$m
 done
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH openbmc 3/7] obmc-initfs: use varables for paths and mount arguments
  2016-02-07  0:00 [PATCH openbmc 0/7] initfs: check and auto-repair read/write file system OpenBMC Patches
  2016-02-07  0:00 ` [PATCH openbmc 1/7] obmc-initfs: minor updates OpenBMC Patches
  2016-02-07  0:00 ` [PATCH openbmc 2/7] obmc-initfs: look for images in /run/initramfs/image- OpenBMC Patches
@ 2016-02-07  0:00 ` OpenBMC Patches
  2016-02-08 16:37   ` Brad Bishop
  2016-02-09  0:46   ` Andrew Jeffery
  2016-02-07  0:00 ` [PATCH openbmc 4/7] obmc-initfs: factor debug and takeover OpenBMC Patches
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 18+ messages in thread
From: OpenBMC Patches @ 2016-02-07  0:00 UTC (permalink / raw)
  To: openbmc

From: Milton Miller <miltonm@us.ibm.com>

Create variables for all mount parameters and paths related to
the read-only and read-write mounts, including fs type, full
device name, and options.  Reorder mount arguments to always
place options last.

Also add variables for update save directory and real init.

This allows easy testing of a file systems by changing a few
parameters including making the rofs an image in ram.

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
---
 .../obmc-phosphor-initfs/files/obmc-init.sh        | 22 ++++++++++-----
 .../obmc-phosphor-initfs/files/obmc-update.sh      | 32 ++++++++++++----------
 2 files changed, 33 insertions(+), 21 deletions(-)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
index f0d8522..0109925 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
@@ -1,12 +1,13 @@
 #!/bin/sh
 
+fslist="proc sys dev run"
 rodir=run/initramfs/ro
 rwdir=run/initramfs/rw
 upper=$rwdir/cow
 work=$rwdir/work
 
 cd /
-mkdir -p sys proc dev run
+mkdir -p $fslist
 mount dev dev -tdevtmpfs
 mount sys sys -tsysfs
 mount proc proc -tproc
@@ -39,13 +40,20 @@ fi
 rofs=$(findmtd rofs)
 rwfs=$(findmtd rwfs)
 
+rodev=/dev/mtdblock${rofs#mtd}
+rwdev=/dev/mtdblock${rwfs#mtd}
+
 rofst=squashfs
 rwfst=ext4
+roopts=ro
+rwopts=rw
+
+init=/sbin/init
 
 echo rofs = $rofs $rofst   rwfs = $rwfs $rwfst
 
 if grep -w debug-init-sh /proc/cmdline ||
-	! mount -o rw /dev/mtdblock${rwfs#mtd} $rwdir -t $rwfst
+	! mount $rwdev $rwdir -t $rwfst -o $rwopts
 then
 	echo Please mount the rw file system on $rwdir from this shell
 	while ! sulogin && ! test -f /takeover
@@ -61,7 +69,7 @@ then
 	exec /bin/sh
 fi
 
-mount -o ro /dev/mtdblock${rofs#mtd} $rodir -t $rofst
+mount $rodev $rodir -t $rofst -o $roopts
 
 rm -rf $work
 mkdir -p $upper
@@ -69,17 +77,17 @@ mkdir -p $work
 
 mount -t overlay -o lowerdir=$rodir,upperdir=$upper,workdir=$work cow /root
 
-if ! chroot /root /bin/sh -c "test -x /sbin/init -a -s /sbin/init"
+if ! chroot /root /bin/sh -c "test -x '$init' -a -s '$init'"
 then
 	echo "Change Root test failed!  Invoking emergency shell."
 	PS1=rescue#\  sulogin
 fi
 
-for f in sys dev proc run
+for f in $fslist
 do
 	mount --move $f root/$f
 done
 
-# switch_root /root /sbin/init
-exec chroot /root /sbin/init
+# switch_root /root $init
+exec chroot /root $init
 
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
index f83b1ad..ec4a769 100755
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
@@ -35,30 +35,35 @@ findmtd() {
 	echo $m
 }
 
-rofs=$(findmtd rofs)
 rwfs=$(findmtd rwfs)
 
-rofst=squahsfs
+rwdev=/dev/mtdblock${rwfs#mtd}
 rwfst=ext4
+rwopts=rw
+rorwopts=ro${rwopts#rw}
+
+rwdir=rw
+upper=$rwdir/cow
+save=save/${upper##*/}
 
 if test -n "$rwfs" && test -s whitelist
 then
 
-	mkdir -p rw
-	mount /dev/mtdblock${rwfs#mtd} rw -oro -t $rwfst
+	mkdir -p $rwdir
+	mount $rwdev $rwdir -t $rwfst -o $rorwopts
 
 	while read f
 	do
-		if ! test -e rw/cow/$f
+		if ! test -e $upper/$f
 		then
 			continue
 		fi
-		d="save/cow/$f"
+		d="$save/$f"
 		mkdir -p "${d%/*}"
-		cp -rp rw/cow/$f "${d%/*}/"
+		cp -rp $upper/$f "${d%/*}/"
 	done < whitelist
 
-	umount rw
+	umount $rwdir
 fi
 
 image=/run/initramfs/image-
@@ -67,7 +72,7 @@ do
 	m=$(findmtd ${f#$image})
 	if test -z "$m"
 	then
-		echo 1>&2  "Unable to find mtd partiton for $f"
+		echo 1>&2  "Unable to find mtd partiton for ${f##*/}."
 		exec /bin/sh
 	fi
 done
@@ -80,12 +85,11 @@ do
 	flashcp -v $f /dev/$m
 done
 
-
-if test -d save/cow
+if test -d $save
 then
-	mount /dev/mtdblock${rwfs#mtd} rw -o rw -t $rwfst
-	cp -rp save/cow/. rw/cow/
-	umount rw
+	mount $rwdev rw -t $rwfst -o rw
+	cp -rp $save/. $upper/
+	umount $rwdir
 fi
 
 # Execute the command systemd told us to ...
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH openbmc 4/7] obmc-initfs: factor debug and takeover
  2016-02-07  0:00 [PATCH openbmc 0/7] initfs: check and auto-repair read/write file system OpenBMC Patches
                   ` (2 preceding siblings ...)
  2016-02-07  0:00 ` [PATCH openbmc 3/7] obmc-initfs: use varables for paths and mount arguments OpenBMC Patches
@ 2016-02-07  0:00 ` OpenBMC Patches
  2016-02-08 16:58   ` Brad Bishop
  2016-02-07  0:00 ` [PATCH openbmc 5/7] obmc-initfs: run fsck on read/write file system OpenBMC Patches
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: OpenBMC Patches @ 2016-02-07  0:00 UTC (permalink / raw)
  To: openbmc

From: Milton Miller <miltonm@us.ibm.com>

Factor out sulogin and init takeover with a message.  This is mostly
a refactor and message update with no significant logic flow.  It
makes the repair opertunity logic consistent.

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
---
 .../obmc-phosphor-initfs/files/obmc-init.sh        | 46 ++++++++++++++++------
 1 file changed, 35 insertions(+), 11 deletions(-)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
index 0109925..daa4f5c 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
@@ -30,6 +30,32 @@ findmtd() {
 	echo $m
 }
 
+debug_takeover() {
+	echo "$@"
+	test -n "$@" && echo Enter password to try to manually fix.
+	cat << HERE
+After fixing run exit to continue this script, or reboot -f to retry, or
+touch /takeover and exit to become PID 1 allowing editing of this script.
+HERE
+
+	while ! sulogin && ! test -f /takeover
+	do
+		echo getty failed, retrying
+	done
+
+	# Touch /takeover in the above getty to become pid 1
+	if test -e /takeover
+	then
+		cat << HERE
+Takeover of init requested.  Executing /bin/sh as PID 1.
+When finished exec new init or cleanup and run reboot -f.
+Warning: No job control!  Shell exit will panic the system!
+HERE
+		export PS1=init#\ 
+		exec /bin/sh
+	fi
+}
+
 env=$(findmtd u-boot-env)
 if test -n $env
 then
@@ -52,21 +78,19 @@ init=/sbin/init
 
 echo rofs = $rofs $rofst   rwfs = $rwfs $rwfst
 
-if grep -w debug-init-sh /proc/cmdline ||
-	! mount $rwdev $rwdir -t $rwfst -o $rwopts
+if grep -w debug-init-sh /proc/cmdline
 then
-	echo Please mount the rw file system on $rwdir from this shell
-	while ! sulogin && ! test -f /takeover
-	do
-		echo getty failed, retrying
-	done
+	debug_takeover "Debug initial shell requested by command line."
 fi
 
-# Touch /takeover in the above getty to become pid 1
-if test -e /takeover
+if ! mount $rwdev $rwdir -t $rwfst -o $rwopts
 then
-	export PS1=init#\ 
-	exec /bin/sh
+	msg="$(cat)" << HERE
+Mounting read-write $rwdev filesystem failed.  Please fix and run
+	mount $rwdev $rwdir -t $rwfs -o $rwopts
+to to continue, or do change nothing to run from RAM for this boot.
+HERE
+	debug_takeover "$msg"
 fi
 
 mount $rodev $rodir -t $rofst -o $roopts
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH openbmc 5/7] obmc-initfs: run fsck on read/write file system
  2016-02-07  0:00 [PATCH openbmc 0/7] initfs: check and auto-repair read/write file system OpenBMC Patches
                   ` (3 preceding siblings ...)
  2016-02-07  0:00 ` [PATCH openbmc 4/7] obmc-initfs: factor debug and takeover OpenBMC Patches
@ 2016-02-07  0:00 ` OpenBMC Patches
  2016-02-08 17:03   ` Brad Bishop
  2016-02-07  0:00 ` [PATCH openbmc 6/7] obmc-initfs: run update as a sub-script OpenBMC Patches
  2016-02-07  0:00 ` [PATCH openbmc 7/7] obmc-initfs: shutdown when rofs is a loop mounted image in /run OpenBMC Patches
  6 siblings, 1 reply; 18+ messages in thread
From: OpenBMC Patches @ 2016-02-07  0:00 UTC (permalink / raw)
  To: openbmc

From: Milton Miller <miltonm@us.ibm.com>

Good practice is to run fsck to repair minor damage and make a
filesystem consistent before mounting it.  We don't have space
in the initramfs to add fsck, but we can mount the read-only
reference partition first and run fsck from there.

Also a test that init appears to be an executable file in the
combined target filesystem in addition to /bin/sh actually
executing and a minor consolidation of establishing the overly
directories in the read-write filesystem.

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
---
 .../obmc-phosphor-initfs/files/obmc-init.sh        | 29 +++++++++++++++++++---
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
index daa4f5c..b7ef09f 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
@@ -75,6 +75,8 @@ roopts=ro
 rwopts=rw
 
 init=/sbin/init
+fsck=/sbin/fsck.$rwfst
+fsckopts=-a
 
 echo rofs = $rofs $rofst   rwfs = $rwfs $rwfst
 
@@ -83,6 +85,28 @@ then
 	debug_takeover "Debug initial shell requested by command line."
 fi
 
+mount $rodev $rodir -t $rofst -o $roopts
+
+if test -x $rodir$fsck
+then
+	for fs in $fslist
+	do
+		mount --bind $fs $rodir/$fs
+	done
+	chroot $rodir $fsck $fsckopts $rwdev
+	rc=$?
+	for fs in $fslist
+	do
+		umount $rodir/$fs
+	done
+	if test $rc -gt 1
+	then
+		debug_takeover "fsck of read-write fs on $rwdev failed (rc=$rc)"
+	fi
+else
+	echo "No '$fsck' in read only fs, skipping fsck."
+fi
+
 if ! mount $rwdev $rwdir -t $rwfst -o $rwopts
 then
 	msg="$(cat)" << HERE
@@ -93,11 +117,8 @@ HERE
 	debug_takeover "$msg"
 fi
 
-mount $rodev $rodir -t $rofst -o $roopts
-
 rm -rf $work
-mkdir -p $upper
-mkdir -p $work
+mkdir -p $upper $work
 
 mount -t overlay -o lowerdir=$rodir,upperdir=$upper,workdir=$work cow /root
 
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH openbmc 6/7] obmc-initfs: run update as a sub-script
  2016-02-07  0:00 [PATCH openbmc 0/7] initfs: check and auto-repair read/write file system OpenBMC Patches
                   ` (4 preceding siblings ...)
  2016-02-07  0:00 ` [PATCH openbmc 5/7] obmc-initfs: run fsck on read/write file system OpenBMC Patches
@ 2016-02-07  0:00 ` OpenBMC Patches
  2016-02-08 17:05   ` Brad Bishop
  2016-02-07  0:00 ` [PATCH openbmc 7/7] obmc-initfs: shutdown when rofs is a loop mounted image in /run OpenBMC Patches
  6 siblings, 1 reply; 18+ messages in thread
From: OpenBMC Patches @ 2016-02-07  0:00 UTC (permalink / raw)
  To: openbmc

From: Milton Miller <miltonm@us.ibm.com>

The update script has replicated logic to do the final reboot, kexec,
halt, or poweroff command.  Instead of transferring control via exec
just call it as a normal command, and return to shutdown for the
final mounted fs debug print and command.

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
---
 .../obmc-phosphor-initfs/files/obmc-shutdown.sh           |  3 +--
 .../obmc-phosphor-initfs/files/obmc-update.sh             | 15 ++++-----------
 2 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
index d530265..7d1157a 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
@@ -34,7 +34,7 @@ fi
 
 if test -x /update && ls $image* > /dev/null 2>&1
 then
-	exec /update ${1+"$@"}
+	/update ${1+"$@"}
 fi
 
 echo Remaining mounts:
@@ -43,7 +43,6 @@ cat /proc/mounts
 test "umount_proc" && umount /proc && rmdir /proc
 
 
-
 # Execute the command systemd told us to ...
 if test -d /oldroot  && test "$1"
 then
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
index ec4a769..3cf6bc3 100755
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
@@ -92,19 +92,12 @@ then
 	umount $rwdir
 fi
 
-# Execute the command systemd told us to ...
-if test -d /oldroot && test -x "/sbin/$1" && test -f "/sbin/$1"
-then
-	if test "$1" == kexec
-	then
-		/sbin/$1 -f -e
-	else
-		/sbin/$1 -f
-	fi
-fi
+exit
 
+# NOT REACHED without edit
+# NOT REACHED without edit
 
-echo "Execute ${1-reboot} -f if all is ok"
+echo "Flash completed.  Inspect, cleanup and reboot -f to continue."
 
 export PS1=update-sh#\ 
 exec /bin/sh
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH openbmc 7/7] obmc-initfs: shutdown when rofs is a loop mounted image in /run
  2016-02-07  0:00 [PATCH openbmc 0/7] initfs: check and auto-repair read/write file system OpenBMC Patches
                   ` (5 preceding siblings ...)
  2016-02-07  0:00 ` [PATCH openbmc 6/7] obmc-initfs: run update as a sub-script OpenBMC Patches
@ 2016-02-07  0:00 ` OpenBMC Patches
  2016-02-08 17:07   ` Brad Bishop
  6 siblings, 1 reply; 18+ messages in thread
From: OpenBMC Patches @ 2016-02-07  0:00 UTC (permalink / raw)
  To: openbmc

From: Milton Miller <miltonm@us.ibm.com>

If one sets rodir=/run/image-rofs roopts=ro,loop and transfers
an image one can run from a base image in ram.  However, the
shutdown will fail to unmount /run because it is busy and then
fails to unmount /cow which causes oldroot to be still mounted.

By moving the mount to the side everything cleans up (as long
as there are no other mounts under run, and systemd-shutdown
tried to do as much as possible).

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
---
 .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
index 7d1157a..3eff1ea 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
@@ -15,11 +15,16 @@ else
 	umount_proc=
 fi
 
-# remove an empty oldroot, that means we are not invoked from systemd-shutdown
+# Remove an empty oldroot, that means we are not invoked from systemd-shutdown
 rmdir /oldroot 2>/dev/null
 
+# Move /oldroot/run to /mnt in case it has the underlying rofs loop mounted.
+# Ordered before /oldroot the overlay is unmounted before the loop mount
+mkdir -p /mnt
+mount --move /oldroot/run /mnt
+
 set -x
-for f in $( awk '/oldroot/ { print $2 }' < /proc/mounts | sort -r )
+for f in $( awk '/oldroot|mnt/ { print $2 }' < /proc/mounts | sort -r )
 do
 	umount $f
 done
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH openbmc 1/7] obmc-initfs: minor updates
  2016-02-07  0:00 ` [PATCH openbmc 1/7] obmc-initfs: minor updates OpenBMC Patches
@ 2016-02-08 16:25   ` Brad Bishop
  2016-02-09  0:55   ` Andrew Jeffery
  1 sibling, 0 replies; 18+ messages in thread
From: Brad Bishop @ 2016-02-08 16:25 UTC (permalink / raw)
  To: OpenBMC Patches; +Cc: openbmc

Reviewed-by: Brad Bishop <brad@bwbmail.net>

> On Feb 6, 2016, at 7:00 PM, OpenBMC Patches <openbmc-patches@stwcx.xyz> wrote:
> 
> From: Milton Miller <miltonm@us.ibm.com>
> 
> In shutdown, Like init and update, cd to / to be clear the
> expected environment.  Although shorter names are not used, it
> prevents problems with unmounting filesystems, even if this is
> the normal state for a call of this script by systemd.  Also
> make a few paths absolute and don't follow symlinks in ln.
> 
> In init, check the new init is an executable file with non-zero
> size in addition to the shell being executable with its shared
> libraries.
> 
> Signed-off-by: Milton Miller <miltonm@us.ibm.com>
> ---
> .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh       | 4 ++--
> .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh   | 7 ++++---
> 2 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> index 0dc4c35..f0d8522 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> @@ -69,9 +69,9 @@ mkdir -p $work
> 
> mount -t overlay -o lowerdir=$rodir,upperdir=$upper,workdir=$work cow /root
> 
> -if ! chroot /root /bin/sh -c exit
> +if ! chroot /root /bin/sh -c "test -x /sbin/init -a -s /sbin/init"
> then
> -	echo 'chroot test failed; invoking emergency shell.'
> +	echo "Change Root test failed!  Invoking emergency shell."
> 	PS1=rescue#\  sulogin
> fi
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> index cc076fd..c550e06 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> @@ -5,10 +5,11 @@ echo shutdown: "$@"
> export PS1=shutdown-sh#\ 
> # exec bin/sh
> 
> +cd /
> if [ ! -e /proc/mounts ]
> then
> 	mkdir -p /proc
> -	mount  proc proc -tproc
> +	mount  proc /proc -tproc
> 	umount_proc=1
> else
> 	umount_proc=
> @@ -27,10 +28,10 @@ set +x
> if test -s /run/fw_env -a -c /run/mtd:u-boot-env -a ! -e /image-u-boot-env &&
> 	! cmp /run/mtd:u-boot-env /run/fw_env
> then
> -	ln -s /run/fw_env /image-u-boot-env
> +	ln -sn /run/fw_env /image-u-boot-env
> fi
> 
> -if test -x /update && ls image-* > /dev/null 2>&1
> +if test -x /update && ls /image-* > /dev/null 2>&1
> then
> 	exec /update ${1+"$@"}
> fi
> -- 
> 2.6.4
> 
> 
> _______________________________________________
> openbmc mailing list
> openbmc@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH openbmc 2/7] obmc-initfs: look for images in /run/initramfs/image-
  2016-02-07  0:00 ` [PATCH openbmc 2/7] obmc-initfs: look for images in /run/initramfs/image- OpenBMC Patches
@ 2016-02-08 16:25   ` Brad Bishop
  0 siblings, 0 replies; 18+ messages in thread
From: Brad Bishop @ 2016-02-08 16:25 UTC (permalink / raw)
  To: OpenBMC Patches; +Cc: openbmc

Reviewed-by: Brad Bishop <brad@bwbmail.net>

> On Feb 6, 2016, at 7:00 PM, OpenBMC Patches <openbmc-patches@stwcx.xyz> wrote:
> 
> From: Milton Miller <miltonm@us.ibm.com>
> 
> Teach update to look for /run/initramfs/image- not /image-*.
> 
> When describing how to recover from a corrupted flash by grabbing
> the images and running update from the init debug shell, it
> became aparent that while at systemd shutdown /run/initramfs/
> is mounted at /, it is not the case during init.  Use variable
> image to hold this pathname.
> 
> Signed-off-by: Milton Miller <miltonm@us.ibm.com>
> ---
> .../obmc-phosphor-initfs/files/obmc-shutdown.sh              |  7 ++++---
> .../obmc-phosphor-initfs/files/obmc-update.sh                | 12 ++++++------
> 2 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> index c550e06..d530265 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> @@ -25,13 +25,14 @@ do
> done
> set +x
> 
> -if test -s /run/fw_env -a -c /run/mtd:u-boot-env -a ! -e /image-u-boot-env &&
> +image=/run/initramfs/image-
> +if test -s /run/fw_env -a -c /run/mtd:u-boot-env -a ! -e ${image}u-boot-env &&
> 	! cmp /run/mtd:u-boot-env /run/fw_env
> then
> -	ln -sn /run/fw_env /image-u-boot-env
> +	ln -sn /run/fw_env ${image}u-boot-env
> fi
> 
> -if test -x /update && ls /image-* > /dev/null 2>&1
> +if test -x /update && ls $image* > /dev/null 2>&1
> then
> 	exec /update ${1+"$@"}
> fi
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> index 1122e83..f83b1ad 100755
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> @@ -61,10 +61,10 @@ then
> 	umount rw
> fi
> 
> -
> -for f in image-*
> +image=/run/initramfs/image-
> +for f in $image*
> do
> -	m=$(findmtd ${f#image-})
> +	m=$(findmtd ${f#$image})
> 	if test -z "$m"
> 	then
> 		echo 1>&2  "Unable to find mtd partiton for $f"
> @@ -72,10 +72,10 @@ do
> 	fi
> done
> 
> -for f in image-*
> +for f in $image*
> do
> -	m=$(findmtd ${f#image-})
> -	echo "Updating ${f#image-}"
> +	m=$(findmtd ${f#$image})
> +	echo "Updating ${f#$image}..."
> 	# flasheraseall /dev/$m && dd if=$f of=/dev/$m
> 	flashcp -v $f /dev/$m
> done
> -- 
> 2.6.4
> 
> 
> _______________________________________________
> openbmc mailing list
> openbmc@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH openbmc 3/7] obmc-initfs: use varables for paths and mount arguments
  2016-02-07  0:00 ` [PATCH openbmc 3/7] obmc-initfs: use varables for paths and mount arguments OpenBMC Patches
@ 2016-02-08 16:37   ` Brad Bishop
  2016-02-09  0:46   ` Andrew Jeffery
  1 sibling, 0 replies; 18+ messages in thread
From: Brad Bishop @ 2016-02-08 16:37 UTC (permalink / raw)
  To: OpenBMC Patches; +Cc: openbmc

Reviewed-by: Brad Bishop <brad@bwbmail.net>

> On Feb 6, 2016, at 7:00 PM, OpenBMC Patches <openbmc-patches@stwcx.xyz> wrote:
> 
> From: Milton Miller <miltonm@us.ibm.com>
> 
> Create variables for all mount parameters and paths related to
> the read-only and read-write mounts, including fs type, full
> device name, and options.  Reorder mount arguments to always
> place options last.
> 
> Also add variables for update save directory and real init.
> 
> This allows easy testing of a file systems by changing a few
> parameters including making the rofs an image in ram.
> 
> Signed-off-by: Milton Miller <miltonm@us.ibm.com>
> ---
> .../obmc-phosphor-initfs/files/obmc-init.sh        | 22 ++++++++++-----
> .../obmc-phosphor-initfs/files/obmc-update.sh      | 32 ++++++++++++----------
> 2 files changed, 33 insertions(+), 21 deletions(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> index f0d8522..0109925 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> @@ -1,12 +1,13 @@
> #!/bin/sh
> 
> +fslist="proc sys dev run"
> rodir=run/initramfs/ro
> rwdir=run/initramfs/rw
> upper=$rwdir/cow
> work=$rwdir/work
> 
> cd /
> -mkdir -p sys proc dev run
> +mkdir -p $fslist
> mount dev dev -tdevtmpfs
> mount sys sys -tsysfs
> mount proc proc -tproc
> @@ -39,13 +40,20 @@ fi
> rofs=$(findmtd rofs)
> rwfs=$(findmtd rwfs)
> 
> +rodev=/dev/mtdblock${rofs#mtd}
> +rwdev=/dev/mtdblock${rwfs#mtd}
> +
> rofst=squashfs
> rwfst=ext4
> +roopts=ro
> +rwopts=rw
> +
> +init=/sbin/init
> 
> echo rofs = $rofs $rofst   rwfs = $rwfs $rwfst
> 
> if grep -w debug-init-sh /proc/cmdline ||
> -	! mount -o rw /dev/mtdblock${rwfs#mtd} $rwdir -t $rwfst
> +	! mount $rwdev $rwdir -t $rwfst -o $rwopts
> then
> 	echo Please mount the rw file system on $rwdir from this shell
> 	while ! sulogin && ! test -f /takeover
> @@ -61,7 +69,7 @@ then
> 	exec /bin/sh
> fi
> 
> -mount -o ro /dev/mtdblock${rofs#mtd} $rodir -t $rofst
> +mount $rodev $rodir -t $rofst -o $roopts
> 
> rm -rf $work
> mkdir -p $upper
> @@ -69,17 +77,17 @@ mkdir -p $work
> 
> mount -t overlay -o lowerdir=$rodir,upperdir=$upper,workdir=$work cow /root
> 
> -if ! chroot /root /bin/sh -c "test -x /sbin/init -a -s /sbin/init"
> +if ! chroot /root /bin/sh -c "test -x '$init' -a -s '$init'"
> then
> 	echo "Change Root test failed!  Invoking emergency shell."
> 	PS1=rescue#\  sulogin
> fi
> 
> -for f in sys dev proc run
> +for f in $fslist
> do
> 	mount --move $f root/$f
> done
> 
> -# switch_root /root /sbin/init
> -exec chroot /root /sbin/init
> +# switch_root /root $init
> +exec chroot /root $init
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> index f83b1ad..ec4a769 100755
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> @@ -35,30 +35,35 @@ findmtd() {
> 	echo $m
> }
> 
> -rofs=$(findmtd rofs)
> rwfs=$(findmtd rwfs)
> 
> -rofst=squahsfs
> +rwdev=/dev/mtdblock${rwfs#mtd}
> rwfst=ext4
> +rwopts=rw
> +rorwopts=ro${rwopts#rw}
> +
> +rwdir=rw
> +upper=$rwdir/cow
> +save=save/${upper##*/}
> 
> if test -n "$rwfs" && test -s whitelist
> then
> 
> -	mkdir -p rw
> -	mount /dev/mtdblock${rwfs#mtd} rw -oro -t $rwfst
> +	mkdir -p $rwdir
> +	mount $rwdev $rwdir -t $rwfst -o $rorwopts
> 
> 	while read f
> 	do
> -		if ! test -e rw/cow/$f
> +		if ! test -e $upper/$f
> 		then
> 			continue
> 		fi
> -		d="save/cow/$f"
> +		d="$save/$f"
> 		mkdir -p "${d%/*}"
> -		cp -rp rw/cow/$f "${d%/*}/"
> +		cp -rp $upper/$f "${d%/*}/"
> 	done < whitelist
> 
> -	umount rw
> +	umount $rwdir
> fi
> 
> image=/run/initramfs/image-
> @@ -67,7 +72,7 @@ do
> 	m=$(findmtd ${f#$image})
> 	if test -z "$m"
> 	then
> -		echo 1>&2  "Unable to find mtd partiton for $f"
> +		echo 1>&2  "Unable to find mtd partiton for ${f##*/}."
> 		exec /bin/sh
> 	fi
> done
> @@ -80,12 +85,11 @@ do
> 	flashcp -v $f /dev/$m
> done
> 
> -
> -if test -d save/cow
> +if test -d $save
> then
> -	mount /dev/mtdblock${rwfs#mtd} rw -o rw -t $rwfst
> -	cp -rp save/cow/. rw/cow/
> -	umount rw
> +	mount $rwdev rw -t $rwfst -o rw
> +	cp -rp $save/. $upper/
> +	umount $rwdir
> fi
> 
> # Execute the command systemd told us to ...
> -- 
> 2.6.4
> 
> 
> _______________________________________________
> openbmc mailing list
> openbmc@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH openbmc 4/7] obmc-initfs: factor debug and takeover
  2016-02-07  0:00 ` [PATCH openbmc 4/7] obmc-initfs: factor debug and takeover OpenBMC Patches
@ 2016-02-08 16:58   ` Brad Bishop
  0 siblings, 0 replies; 18+ messages in thread
From: Brad Bishop @ 2016-02-08 16:58 UTC (permalink / raw)
  To: OpenBMC Patches; +Cc: openbmc


> On Feb 6, 2016, at 7:00 PM, OpenBMC Patches <openbmc-patches@stwcx.xyz> wrote:
> 
> From: Milton Miller <miltonm@us.ibm.com>
> 
> Factor out sulogin and init takeover with a message.  This is mostly
> a refactor and message update with no significant logic flow.  It
> makes the repair opertunity logic consistent.

opportunity

> 
> Signed-off-by: Milton Miller <miltonm@us.ibm.com>
> ---
> .../obmc-phosphor-initfs/files/obmc-init.sh        | 46 ++++++++++++++++------
> 1 file changed, 35 insertions(+), 11 deletions(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> index 0109925..daa4f5c 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> @@ -30,6 +30,32 @@ findmtd() {
> 	echo $m
> }
> 
> +debug_takeover() {
> +	echo "$@"
> +	test -n "$@" && echo Enter password to try to manually fix.
> +	cat << HERE
> +After fixing run exit to continue this script, or reboot -f to retry, or
> +touch /takeover and exit to become PID 1 allowing editing of this script.
> +HERE
> +
> +	while ! sulogin && ! test -f /takeover
> +	do
> +		echo getty failed, retrying
> +	done
> +
> +	# Touch /takeover in the above getty to become pid 1
> +	if test -e /takeover
> +	then
> +		cat << HERE
> +Takeover of init requested.  Executing /bin/sh as PID 1.
> +When finished exec new init or cleanup and run reboot -f.
> +Warning: No job control!  Shell exit will panic the system!
> +HERE
> +		export PS1=init#\ 
> +		exec /bin/sh
> +	fi
> +}
> +
> env=$(findmtd u-boot-env)
> if test -n $env
> then
> @@ -52,21 +78,19 @@ init=/sbin/init
> 
> echo rofs = $rofs $rofst   rwfs = $rwfs $rwfst
> 
> -if grep -w debug-init-sh /proc/cmdline ||
> -	! mount $rwdev $rwdir -t $rwfst -o $rwopts
> +if grep -w debug-init-sh /proc/cmdline
> then
> -	echo Please mount the rw file system on $rwdir from this shell
> -	while ! sulogin && ! test -f /takeover
> -	do
> -		echo getty failed, retrying
> -	done
> +	debug_takeover "Debug initial shell requested by command line."
> fi
> 
> -# Touch /takeover in the above getty to become pid 1
> -if test -e /takeover
> +if ! mount $rwdev $rwdir -t $rwfst -o $rwopts
> then
> -	export PS1=init#\ 
> -	exec /bin/sh
> +	msg="$(cat)" << HERE
> +Mounting read-write $rwdev filesystem failed.  Please fix and run
> +	mount $rwdev $rwdir -t $rwfs -o $rwopts
> +to to continue, or do change nothing to run from RAM for this boot.
> +HERE
> +	debug_takeover "$msg"
> fi
> 
> mount $rodev $rodir -t $rofst -o $roopts
> -- 
> 2.6.4
> 
> 
> _______________________________________________
> openbmc mailing list
> openbmc@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH openbmc 5/7] obmc-initfs: run fsck on read/write file system
  2016-02-07  0:00 ` [PATCH openbmc 5/7] obmc-initfs: run fsck on read/write file system OpenBMC Patches
@ 2016-02-08 17:03   ` Brad Bishop
  0 siblings, 0 replies; 18+ messages in thread
From: Brad Bishop @ 2016-02-08 17:03 UTC (permalink / raw)
  To: OpenBMC Patches; +Cc: openbmc


> On Feb 6, 2016, at 7:00 PM, OpenBMC Patches <openbmc-patches@stwcx.xyz> wrote:
> 
> From: Milton Miller <miltonm@us.ibm.com>
> 
> Good practice is to run fsck to repair minor damage and make a
> filesystem consistent before mounting it.  We don't have space
> in the initramfs to add fsck, but we can mount the read-only
> reference partition first and run fsck from there.
> 
> Also a test that init appears to be an executable file in the
> combined target filesystem in addition to /bin/sh actually
> executing and a minor consolidation of establishing the overly

overlay

> directories in the read-write filesystem.
> 
> Signed-off-by: Milton Miller <miltonm@us.ibm.com>
> ---
> .../obmc-phosphor-initfs/files/obmc-init.sh        | 29 +++++++++++++++++++---
> 1 file changed, 25 insertions(+), 4 deletions(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> index daa4f5c..b7ef09f 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> @@ -75,6 +75,8 @@ roopts=ro
> rwopts=rw
> 
> init=/sbin/init
> +fsck=/sbin/fsck.$rwfst
> +fsckopts=-a
> 
> echo rofs = $rofs $rofst   rwfs = $rwfs $rwfst
> 
> @@ -83,6 +85,28 @@ then
> 	debug_takeover "Debug initial shell requested by command line."
> fi
> 
> +mount $rodev $rodir -t $rofst -o $roopts
> +
> +if test -x $rodir$fsck
> +then
> +	for fs in $fslist
> +	do
> +		mount --bind $fs $rodir/$fs
> +	done
> +	chroot $rodir $fsck $fsckopts $rwdev
> +	rc=$?
> +	for fs in $fslist
> +	do
> +		umount $rodir/$fs
> +	done
> +	if test $rc -gt 1
> +	then
> +		debug_takeover "fsck of read-write fs on $rwdev failed (rc=$rc)"
> +	fi
> +else
> +	echo "No '$fsck' in read only fs, skipping fsck."
> +fi
> +
> if ! mount $rwdev $rwdir -t $rwfst -o $rwopts
> then
> 	msg="$(cat)" << HERE
> @@ -93,11 +117,8 @@ HERE
> 	debug_takeover "$msg"
> fi
> 
> -mount $rodev $rodir -t $rofst -o $roopts
> -
> rm -rf $work
> -mkdir -p $upper
> -mkdir -p $work
> +mkdir -p $upper $work
> 
> mount -t overlay -o lowerdir=$rodir,upperdir=$upper,workdir=$work cow /root
> 
> -- 
> 2.6.4
> 
> 
> _______________________________________________
> openbmc mailing list
> openbmc@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH openbmc 6/7] obmc-initfs: run update as a sub-script
  2016-02-07  0:00 ` [PATCH openbmc 6/7] obmc-initfs: run update as a sub-script OpenBMC Patches
@ 2016-02-08 17:05   ` Brad Bishop
  0 siblings, 0 replies; 18+ messages in thread
From: Brad Bishop @ 2016-02-08 17:05 UTC (permalink / raw)
  To: OpenBMC Patches; +Cc: openbmc

Reviewed-by: Brad Bishop <brad@bwbmail.net>

> On Feb 6, 2016, at 7:00 PM, OpenBMC Patches <openbmc-patches@stwcx.xyz> wrote:
> 
> From: Milton Miller <miltonm@us.ibm.com>
> 
> The update script has replicated logic to do the final reboot, kexec,
> halt, or poweroff command.  Instead of transferring control via exec
> just call it as a normal command, and return to shutdown for the
> final mounted fs debug print and command.
> 
> Signed-off-by: Milton Miller <miltonm@us.ibm.com>
> ---
> .../obmc-phosphor-initfs/files/obmc-shutdown.sh           |  3 +--
> .../obmc-phosphor-initfs/files/obmc-update.sh             | 15 ++++-----------
> 2 files changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> index d530265..7d1157a 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> @@ -34,7 +34,7 @@ fi
> 
> if test -x /update && ls $image* > /dev/null 2>&1
> then
> -	exec /update ${1+"$@"}
> +	/update ${1+"$@"}
> fi
> 
> echo Remaining mounts:
> @@ -43,7 +43,6 @@ cat /proc/mounts
> test "umount_proc" && umount /proc && rmdir /proc
> 
> 
> -
> # Execute the command systemd told us to ...
> if test -d /oldroot  && test "$1"
> then
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> index ec4a769..3cf6bc3 100755
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> @@ -92,19 +92,12 @@ then
> 	umount $rwdir
> fi
> 
> -# Execute the command systemd told us to ...
> -if test -d /oldroot && test -x "/sbin/$1" && test -f "/sbin/$1"
> -then
> -	if test "$1" == kexec
> -	then
> -		/sbin/$1 -f -e
> -	else
> -		/sbin/$1 -f
> -	fi
> -fi
> +exit
> 
> +# NOT REACHED without edit
> +# NOT REACHED without edit
> 
> -echo "Execute ${1-reboot} -f if all is ok"
> +echo "Flash completed.  Inspect, cleanup and reboot -f to continue."
> 
> export PS1=update-sh#\ 
> exec /bin/sh
> -- 
> 2.6.4
> 
> 
> _______________________________________________
> openbmc mailing list
> openbmc@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH openbmc 7/7] obmc-initfs: shutdown when rofs is a loop mounted image in /run
  2016-02-07  0:00 ` [PATCH openbmc 7/7] obmc-initfs: shutdown when rofs is a loop mounted image in /run OpenBMC Patches
@ 2016-02-08 17:07   ` Brad Bishop
  0 siblings, 0 replies; 18+ messages in thread
From: Brad Bishop @ 2016-02-08 17:07 UTC (permalink / raw)
  To: OpenBMC Patches; +Cc: openbmc

Reviewed-by: Brad Bishop <brad@bwbmail.net>

> On Feb 6, 2016, at 7:00 PM, OpenBMC Patches <openbmc-patches@stwcx.xyz> wrote:
> 
> From: Milton Miller <miltonm@us.ibm.com>
> 
> If one sets rodir=/run/image-rofs roopts=ro,loop and transfers
> an image one can run from a base image in ram.  However, the
> shutdown will fail to unmount /run because it is busy and then
> fails to unmount /cow which causes oldroot to be still mounted.
> 
> By moving the mount to the side everything cleans up (as long
> as there are no other mounts under run, and systemd-shutdown
> tried to do as much as possible).
> 
> Signed-off-by: Milton Miller <miltonm@us.ibm.com>
> ---
> .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> index 7d1157a..3eff1ea 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> @@ -15,11 +15,16 @@ else
> 	umount_proc=
> fi
> 
> -# remove an empty oldroot, that means we are not invoked from systemd-shutdown
> +# Remove an empty oldroot, that means we are not invoked from systemd-shutdown
> rmdir /oldroot 2>/dev/null
> 
> +# Move /oldroot/run to /mnt in case it has the underlying rofs loop mounted.
> +# Ordered before /oldroot the overlay is unmounted before the loop mount
> +mkdir -p /mnt
> +mount --move /oldroot/run /mnt
> +
> set -x
> -for f in $( awk '/oldroot/ { print $2 }' < /proc/mounts | sort -r )
> +for f in $( awk '/oldroot|mnt/ { print $2 }' < /proc/mounts | sort -r )
> do
> 	umount $f
> done
> -- 
> 2.6.4
> 
> 
> _______________________________________________
> openbmc mailing list
> openbmc@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH openbmc 3/7] obmc-initfs: use varables for paths and mount arguments
  2016-02-07  0:00 ` [PATCH openbmc 3/7] obmc-initfs: use varables for paths and mount arguments OpenBMC Patches
  2016-02-08 16:37   ` Brad Bishop
@ 2016-02-09  0:46   ` Andrew Jeffery
  1 sibling, 0 replies; 18+ messages in thread
From: Andrew Jeffery @ 2016-02-09  0:46 UTC (permalink / raw)
  To: OpenBMC Patches, openbmc

On Sat, 2016-02-06 at 18:00 -0600, OpenBMC Patches wrote:
> From: Milton Miller <miltonm@us.ibm.com>
> 
> Create variables for all mount parameters and paths related to
> the read-only and read-write mounts, including fs type, full
> device name, and options.  Reorder mount arguments to always
> place options last.
> 
> Also add variables for update save directory and real init.
> 
> This allows easy testing of a file systems by changing a few
> parameters including making the rofs an image in ram.
> 
> Signed-off-by: Milton Miller <miltonm@us.ibm.com>
> ---
>  .../obmc-phosphor-initfs/files/obmc-init.sh        | 22 ++++++++++--
> ---
>  .../obmc-phosphor-initfs/files/obmc-update.sh      | 32 ++++++++++++
> ----------
>  2 files changed, 33 insertions(+), 21 deletions(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> index f0d8522..0109925 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> @@ -1,12 +1,13 @@
>  #!/bin/sh
>  
> +fslist="proc sys dev run"
>  rodir=run/initramfs/ro
>  rwdir=run/initramfs/rw
>  upper=$rwdir/cow
>  work=$rwdir/work
>  
>  cd /
> -mkdir -p sys proc dev run
> +mkdir -p $fslist
>  mount dev dev -tdevtmpfs
>  mount sys sys -tsysfs
>  mount proc proc -tproc
> @@ -39,13 +40,20 @@ fi
>  rofs=$(findmtd rofs)
>  rwfs=$(findmtd rwfs)
>  
> +rodev=/dev/mtdblock${rofs#mtd}
> +rwdev=/dev/mtdblock${rwfs#mtd}
> +
>  rofst=squashfs
>  rwfst=ext4
> +roopts=ro
> +rwopts=rw
> +
> +init=/sbin/init
>  
>  echo rofs = $rofs $rofst   rwfs = $rwfs $rwfst
>  
>  if grep -w debug-init-sh /proc/cmdline ||
> -	! mount -o rw /dev/mtdblock${rwfs#mtd} $rwdir -t $rwfst
> +	! mount $rwdev $rwdir -t $rwfst -o $rwopts
>  then
>  	echo Please mount the rw file system on $rwdir from this
> shell
>  	while ! sulogin && ! test -f /takeover
> @@ -61,7 +69,7 @@ then
>  	exec /bin/sh
>  fi
>  
> -mount -o ro /dev/mtdblock${rofs#mtd} $rodir -t $rofst
> +mount $rodev $rodir -t $rofst -o $roopts
>  
>  rm -rf $work
>  mkdir -p $upper
> @@ -69,17 +77,17 @@ mkdir -p $work
>  
>  mount -t overlay -o lowerdir=$rodir,upperdir=$upper,workdir=$work
> cow /root
>  
> -if ! chroot /root /bin/sh -c "test -x /sbin/init -a -s /sbin/init"
> +if ! chroot /root /bin/sh -c "test -x '$init' -a -s '$init'"
>  then
>  	echo "Change Root test failed!  Invoking emergency shell."
>  	PS1=rescue#\  sulogin
>  fi
>  
> -for f in sys dev proc run
> +for f in $fslist
>  do
>  	mount --move $f root/$f
>  done
>  
> -# switch_root /root /sbin/init
> -exec chroot /root /sbin/init
> +# switch_root /root $init
> +exec chroot /root $init
>  
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor
> -initfs/files/obmc-update.sh b/meta-phosphor/common/recipes
> -phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> index f83b1ad..ec4a769 100755
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor
> -initfs/files/obmc-update.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor
> -initfs/files/obmc-update.sh
> @@ -35,30 +35,35 @@ findmtd() {
>  	echo $m
>  }
>  
> -rofs=$(findmtd rofs)
>  rwfs=$(findmtd rwfs)
>  
> -rofst=squahsfs
> +rwdev=/dev/mtdblock${rwfs#mtd}
>  rwfst=ext4
> +rwopts=rw
> +rorwopts=ro${rwopts#rw}
> +
> +rwdir=rw
> +upper=$rwdir/cow
> +save=save/${upper##*/}
>  
>  if test -n "$rwfs" && test -s whitelist
>  then
>  
> -	mkdir -p rw
> -	mount /dev/mtdblock${rwfs#mtd} rw -oro -t $rwfst
> +	mkdir -p $rwdir
> +	mount $rwdev $rwdir -t $rwfst -o $rorwopts
>  
>  	while read f
>  	do
> -		if ! test -e rw/cow/$f
> +		if ! test -e $upper/$f
>  		then
>  			continue
>  		fi
> -		d="save/cow/$f"
> +		d="$save/$f"
>  		mkdir -p "${d%/*}"
> -		cp -rp rw/cow/$f "${d%/*}/"
> +		cp -rp $upper/$f "${d%/*}/"
>  	done < whitelist
>  
> -	umount rw
> +	umount $rwdir
>  fi
>  
>  image=/run/initramfs/image-
> @@ -67,7 +72,7 @@ do
>  	m=$(findmtd ${f#$image})
>  	if test -z "$m"
>  	then
> -		echo 1>&2  "Unable to find mtd partiton for $f"
> +		echo 1>&2  "Unable to find mtd partiton for
> ${f##*/}."
>  		exec /bin/sh
>  	fi
>  done
> @@ -80,12 +85,11 @@ do
>  	flashcp -v $f /dev/$m
>  done
>  
> -
> -if test -d save/cow
> +if test -d $save
>  then
> -	mount /dev/mtdblock${rwfs#mtd} rw -o rw -t $rwfst
> -	cp -rp save/cow/. rw/cow/
> -	umount rw
> +	mount $rwdev rw -t $rwfst -o rw

Shouldn't this be as below in line with the stated aim of the patch
(use of variables for mount parameters)?

	mount $rwdev $rwdir -t $rwfst -o $rwopts

> +	cp -rp $save/. $upper/
> +	umount $rwdir
>  fi
>  
>  # Execute the command systemd told us to ...

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH openbmc 1/7] obmc-initfs: minor updates
  2016-02-07  0:00 ` [PATCH openbmc 1/7] obmc-initfs: minor updates OpenBMC Patches
  2016-02-08 16:25   ` Brad Bishop
@ 2016-02-09  0:55   ` Andrew Jeffery
  1 sibling, 0 replies; 18+ messages in thread
From: Andrew Jeffery @ 2016-02-09  0:55 UTC (permalink / raw)
  To: OpenBMC Patches, openbmc

On Sat, 2016-02-06 at 18:00 -0600, OpenBMC Patches wrote:
> From: Milton Miller <miltonm@us.ibm.com>
> 
> In shutdown, Like init and update, cd to / to be clear the
> expected environment.  Although shorter names are not used, it
> prevents problems with unmounting filesystems, even if this is
> the normal state for a call of this script by systemd.  Also
> make a few paths absolute and don't follow symlinks in ln.
> 
> In init, check the new init is an executable file with non-zero
> size in addition to the shell being executable with its shared
> libraries.

From a process point of view, these paragraphs appear to be separate
concerns and so my preference (in the future) is they be separate
patches. That way we avoid confusion around subtle interactions between
the changes. If the changes need to happen together then that should be
stated, along with an explanation as to why.

> 
> Signed-off-by: Milton Miller <miltonm@us.ibm.com>
> ---
>  .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh       |
> 4 ++--
>  .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh   |
> 7 ++++---
>  2 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor
> -initfs/files/obmc-init.sh b/meta-phosphor/common/recipes
> -phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> index 0dc4c35..f0d8522 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor
> -initfs/files/obmc-init.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor
> -initfs/files/obmc-init.sh
> @@ -69,9 +69,9 @@ mkdir -p $work
>  
>  mount -t overlay -o lowerdir=$rodir,upperdir=$upper,workdir=$work
> cow /root
>  
> -if ! chroot /root /bin/sh -c exit
> +if ! chroot /root /bin/sh -c "test -x /sbin/init -a -s /sbin/init"
>  then
> -	echo 'chroot test failed; invoking emergency shell.'
> +	echo "Change Root test failed!  Invoking emergency shell."

Maybe it would be nice to tell the user exactly what test failed? Given
it's an emergency shell I think it would be nice to have as much info
as possible about what went wrong. Maybe something like "Will not
chroot to /root: /sbin/init is not functional in /root. Invoking
emergency shell".

Even here 'not functional' could be seen as vague, though that's around
where my line in the sand exists. Thoughts?

>  	PS1=rescue#\  sulogin
>  fi
>  
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor
> -initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes
> -phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> index cc076fd..c550e06 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor
> -initfs/files/obmc-shutdown.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor
> -initfs/files/obmc-shutdown.sh
> @@ -5,10 +5,11 @@ echo shutdown: "$@"
>  export PS1=shutdown-sh#\ 
>  # exec bin/sh
>  
> +cd /
>  if [ ! -e /proc/mounts ]
>  then
>  	mkdir -p /proc
> -	mount  proc proc -tproc
> +	mount  proc /proc -tproc
>  	umount_proc=1
>  else
>  	umount_proc=
> @@ -27,10 +28,10 @@ set +x
>  if test -s /run/fw_env -a -c /run/mtd:u-boot-env -a ! -e /image-u
> -boot-env &&
>  	! cmp /run/mtd:u-boot-env /run/fw_env
>  then
> -	ln -s /run/fw_env /image-u-boot-env
> +	ln -sn /run/fw_env /image-u-boot-env
>  fi
>  
> -if test -x /update && ls image-* > /dev/null 2>&1
> +if test -x /update && ls /image-* > /dev/null 2>&1
>  then
>  	exec /update ${1+"$@"}
>  fi

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH openbmc 7/7] obmc-initfs: shutdown when rofs is a loop mounted image in /run
  2016-02-06  0:20 [PATCH openbmc 0/7] initfs: check and auto-repair read/write file system OpenBMC Patches
@ 2016-02-06  0:20 ` OpenBMC Patches
  0 siblings, 0 replies; 18+ messages in thread
From: OpenBMC Patches @ 2016-02-06  0:20 UTC (permalink / raw)
  To: openbmc

From: Milton Miller <miltonm@us.ibm.com>

If one sets rodir=/run/image-rofs roopts=ro,loop and transfers
an image one can run from a base image in ram.  However, the
shutdown will fail to unmount /run because it is busy and then
fails to unmount /cow which causes oldroot to be still mounted.

By moving the mount to the side everything cleans up (as long
as there are no other mounts under run, and systemd-shutdown
tried to do as much as possible).

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
---
 .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
index 7d1157a..3eff1ea 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
@@ -15,11 +15,16 @@ else
 	umount_proc=
 fi
 
-# remove an empty oldroot, that means we are not invoked from systemd-shutdown
+# Remove an empty oldroot, that means we are not invoked from systemd-shutdown
 rmdir /oldroot 2>/dev/null
 
+# Move /oldroot/run to /mnt in case it has the underlying rofs loop mounted.
+# Ordered before /oldroot the overlay is unmounted before the loop mount
+mkdir -p /mnt
+mount --move /oldroot/run /mnt
+
 set -x
-for f in $( awk '/oldroot/ { print $2 }' < /proc/mounts | sort -r )
+for f in $( awk '/oldroot|mnt/ { print $2 }' < /proc/mounts | sort -r )
 do
 	umount $f
 done
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-02-09  0:55 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-07  0:00 [PATCH openbmc 0/7] initfs: check and auto-repair read/write file system OpenBMC Patches
2016-02-07  0:00 ` [PATCH openbmc 1/7] obmc-initfs: minor updates OpenBMC Patches
2016-02-08 16:25   ` Brad Bishop
2016-02-09  0:55   ` Andrew Jeffery
2016-02-07  0:00 ` [PATCH openbmc 2/7] obmc-initfs: look for images in /run/initramfs/image- OpenBMC Patches
2016-02-08 16:25   ` Brad Bishop
2016-02-07  0:00 ` [PATCH openbmc 3/7] obmc-initfs: use varables for paths and mount arguments OpenBMC Patches
2016-02-08 16:37   ` Brad Bishop
2016-02-09  0:46   ` Andrew Jeffery
2016-02-07  0:00 ` [PATCH openbmc 4/7] obmc-initfs: factor debug and takeover OpenBMC Patches
2016-02-08 16:58   ` Brad Bishop
2016-02-07  0:00 ` [PATCH openbmc 5/7] obmc-initfs: run fsck on read/write file system OpenBMC Patches
2016-02-08 17:03   ` Brad Bishop
2016-02-07  0:00 ` [PATCH openbmc 6/7] obmc-initfs: run update as a sub-script OpenBMC Patches
2016-02-08 17:05   ` Brad Bishop
2016-02-07  0:00 ` [PATCH openbmc 7/7] obmc-initfs: shutdown when rofs is a loop mounted image in /run OpenBMC Patches
2016-02-08 17:07   ` Brad Bishop
  -- strict thread matches above, loose matches on Subject: below --
2016-02-06  0:20 [PATCH openbmc 0/7] initfs: check and auto-repair read/write file system OpenBMC Patches
2016-02-06  0:20 ` [PATCH openbmc 7/7] obmc-initfs: shutdown when rofs is a loop mounted image in /run OpenBMC Patches

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.