[PATCH openbmc 5/7] obmc-initfs: run fsck on read/write file system

Brad Bishop bradleyb at fuzziesquirrel.com
Tue Feb 9 04:03:09 AEDT 2016


> On Feb 6, 2016, at 7:00 PM, OpenBMC Patches <openbmc-patches at stwcx.xyz> wrote:
> 
> From: Milton Miller <miltonm at 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 at 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 at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc


More information about the openbmc mailing list