obmc-flash-bmc: Mount alt rwfs

Mount the rwfs of the alt-bmc chip if present when the BMC
boots up to be able to synchronize (backup files) from the
BMC rwfs to the alt one, for the case when a chip switch
occurs then the persistent data is available on the alt chip.

Create a persist/etc directory to backup the /etc files to
it since that's the overlay's upperdir for /etc.

Change-Id: Ibe287fa792c1e214ba35a43bc253da391728299a
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc b/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
index 26f99cc..875a90f 100644
--- a/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
+++ b/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
@@ -231,6 +231,17 @@
     done
 }
 
+mount_alt_rwfs() {
+  altNum="$(findmtdnum "alt-bmc")"
+  if [ ! -z "${altNum}" ]; then
+    altVarMount="/media/alt/var"
+    mkdir -p "${altVarMount}"
+    if mount ubi"${altNum}":rwfs "${altVarMount}" -t ubifs -o defaults; then
+      mkdir -p "${altVarMount}"/persist/etc
+    fi
+  fi
+}
+
 remount_ubi() {
   bmcmtd="$(findmtd "bmc")"
   altbmcmtd="$(findmtd "alt-bmc")"
@@ -477,6 +488,7 @@
     ;;
   ubiremount)
     remount_ubi
+    mount_alt_rwfs
     ;;
   createenvbackup)
     backup_env_vars