[PATCH openbmc 8/9] initfs: Add flash clear and update during init

Andrew Jeffery andrew at aj.id.au
Thu Feb 25 21:42:50 AEDT 2016


On Wed, 2016-02-24 at 12:40 -0600, OpenBMC Patches wrote:
> From: Milton Miller <miltonm at us.ibm.com>
> 
> Add code to clear the rwfs (preserving files from the whitelist)
> during init, by a command line option.
> 
> Also allow it to be triggered by the file system not being a jffs2.

So this helps avoid a two-stage upgrade process right? We write a new
(fixed wrt spi-nor) image-kernel and an updated image-initrd, reboot,
and then have obmc-init.sh switch the rwfs partition to JFFS2. Is this
worth mentioning?

A cleaning function seems useful; did you give any thought to a factory
-reset function (i.e. not preserving the whitelist files)? I don't
think this is covered either here or in obmc-update.sh? Avoiding pflash
would be nice but it's probably a separate problem.

Otherwise:

Reviewed-by: Andrew Jeffery <andrew at aj.id.au>

> 
> A console user can download images to /run/initramfs/ at the
> debug-init-sh prompt for manual update.
> 
> Also add code but do not enable detecting images loaded into
> initramfs / for future update options.  If enabled a custom initrd
> with update images can be bulit (it would not fit in flash and
> need to be netbooted).
> 
> Signed-off-by: Milton Miller <miltonm at us.ibm.com>
> ---
>  .../obmc-phosphor-initfs/files/obmc-init.sh        | 54 +++++++++++++++++++++-
>  1 file changed, 53 insertions(+), 1 deletion(-)
> 
> 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 f2fe938..12c5a2f 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
> @@ -85,13 +85,21 @@ rwfs=$(findmtd rwfs)
>  rodev=/dev/mtdblock${rofs#mtd}
>  rwdev=/dev/mtdblock${rwfs#mtd}
>  
> +# Set to y for yes, anything else for no.
> +force_rwfst_jffs2=y
> +flash_images_before_init=n
> +
>  rofst=squashfs
>  rwfst=$(probe_fs_type $rwdev)
>  roopts=ro
>  rwopts=rw
>  
> +image=/run/initramfs/image-
> +trigger=${image}rwfs
> +
>  init=/sbin/init
> -fsck=/sbin/fsck.$rwfst
> +fsckbase=/sbin/fsck.
> +fsck=$fsckbase$rwfst
>  fsckopts=-a
>  
>  echo rofs = $rofs $rofst   rwfs = $rwfs $rwfst
> @@ -101,6 +109,50 @@ then
>  > 	> debug_takeover "Debug initial shell requested by command line."
>  fi
>  
> +# If there are images in root move them to run/initramfs/ now.
> +imagebasename=${image##*/}
> +if test -n "${imagebasename}" -a "x$flash_images_before_init" = xy &&
> +> 	> ls /${imagebasename}* > /dev/null 2>&1
> +then
> +> 	> echo "Pending flash updates found."
> +> 	> mv /${imagebasename}* ${image%$imagebasename}
> +fi
> +
> +if grep -w clean-rwfs-filesystem /proc/cmdline
> +then
> +> 	> echo "Cleaning of read-write overlay filesystem requested."
> +> 	> touch $trigger
> +fi
> +
> +if test "x$force_rwfst_jffs2" = xy -a $rwfst != jffs2 -a ! -f $trigger
> +then
> +> 	> echo "Converting read-write overlay filesystem to jffs2 forced."
> +> 	> touch $trigger
> +fi
> +
> +if ls $image* > /dev/null 2>&1
> +then
> +> 	> if ! test -x /update
> +> 	> then
> +> 	> 	> debug_takeover "Flash update requested but /update missing!"
> +> 	> elif test -f $trigger -a ! -s $trigger
> +> 	> then
> +> 	> 	> echo "Saving selected files from read-write overlay filesystem."
> +> 	> 	> /update && rm -f $image*
> +> 	> 	> echo "Clearing read-write overlay filesystem."
> +> 	> 	> flash_eraseall /dev/$rwfs
> +> 	> 	> echo "Restoring saved files to read-write overlay filesystem."
> +> 	> 	> touch $trigger
> +> 	> 	> /update 
> +> 	> 	> rm -rf /save $trigger
> +> 	> else
> +> 	> 	> /update && rm -f $image*
> +> 	> fi
> +
> +> 	> rwfst=$(probe_fs_type $rwdev)
> +> 	> fsck=$fsckbase$rwfst
> +fi
> +
>  mount $rodev $rodir -t $rofst -o $roopts
>  
>  if test -x $rodir$fsck
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20160225/b05f9e14/attachment.sig>


More information about the openbmc mailing list