diff options
author | Michael Tritz <mtritz@us.ibm.com> | 2017-08-08 13:35:17 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-08-18 20:29:19 +0000 |
commit | 82cad8431dcba9c19daeb2cc2b2f94ac580311e9 (patch) | |
tree | 6ad412f411bb2431bd0f9c0fe4dd6ef81f0356ff /meta-openbmc-machines | |
parent | 4fb42ed0dbb06c18e9533288251292caf22b3815 (diff) | |
download | talos-openbmc-82cad8431dcba9c19daeb2cc2b2f94ac580311e9.tar.gz talos-openbmc-82cad8431dcba9c19daeb2cc2b2f94ac580311e9.zip |
PNOR code update: clear existing volumes before creating new ones
In testing, a number of issues have occurred in which which we have
attempted to create a read-only volume to mount the squashfs file,
but it's failed because of an existing volume or UBI block of the
same name.
This commit resolves those issues by simply removing any mounts or
volumes of the same name prior to creating and mounting a new
read-only volume during the activation process.
Resolves openbmc/openbmc#2109
Change-Id: Ifa4db46fc873d2177025ec973cace3b23cf17097
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
Diffstat (limited to 'meta-openbmc-machines')
-rw-r--r-- | meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios index b365b79b6..1ed25297f 100644 --- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios +++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios @@ -54,9 +54,18 @@ attach_ubi() { mount_squashfs() { pnormtd="$(findmtd pnor)" - pnor="${pnormtd#mtd}" - ubidev="/dev/ubi${pnor}" + ubidev="/dev/ubi${pnormtd#mtd}" mountdir="/media/${name}" + vol="$(findubi "${name}")" + + if is_mounted "${name}"; then + echo "${name} is already mounted." + return 0 + fi + + if [ ! -z "${vol}" ]; then + ubirmvol "${ubidev}" -N "${name}" + fi if [ ! -d "${mountdir}" ]; then mkdir "${mountdir}" @@ -65,24 +74,35 @@ mount_squashfs() { # Create a static ubi volume of arbitrary size 24MB, # the current pnor image is ~19MB # TODO Set size based on file size openbmc/openbmc#1840 + ubimkvol "${ubidev}" -N "${name}" -s 24MiB --type=static vol="$(findubi "${name}")" - if [ -z "${vol}" ]; then - ubimkvol "${ubidev}" -N "${name}" -s 24MiB --type=static - vol="$(findubi "${name}")" + + if [ $? != 0 ]; then + echo "Unable to create RO volume!" + return 1 fi - # Create a ubi block needed for read-only volumes, - # and update the volume with the pnor squashfs image ubidevid="${vol#ubi}" - block="/dev/ubiblock${ubidevid}" - if [ ! -e "$block" ]; then - img="/tmp/images/${version}/pnor.xz.squashfs" - ubiblock --create "/dev/ubi${ubidevid}" - ubiupdatevol "/dev/ubi${ubidevid}" "${img}" + img="/tmp/images/${version}/pnor.xz.squashfs" + ubiupdatevol "/dev/ubi${ubidevid}" "${img}" + + if [ $? != 0 ]; then + echo "Unable to update RO volume!" + return 1 fi - if ! is_mounted "${name}"; then - mount -t squashfs -o ro "${block}" "${mountdir}" + ubiblock --create "/dev/ubi${ubidevid}" + + if [ $? != 0 ]; then + echo "Unable to create UBI block for RO volume!" + return 1 + fi + + mount -t squashfs -o ro "/dev/ubiblock${ubidevid}" "${mountdir}" + + if [ $? != 0 ]; then + echo "Unable to mount RO volume!" + return 1 fi } |