PNOR: Mount ubi volumes on BMC reboot
- Create a static service file that will be
run on all BMC boot to remount the ubi volumes.
- Read the ubinfo for all available volumes from
obmc/flash-bios script.
- Re-Mount the available volumes on /media/ dir
using the volume names.
Resolves openbmc/openbmc#1848
Change-Id: I9e336340a04f335d034438406e5f0fff9b21d1b9
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/common/recipes-phosphor/flash/openpower-software-manager.bb b/common/recipes-phosphor/flash/openpower-software-manager.bb
index 14f7d10..1aacf28 100644
--- a/common/recipes-phosphor/flash/openpower-software-manager.bb
+++ b/common/recipes-phosphor/flash/openpower-software-manager.bb
@@ -45,4 +45,5 @@
obmc-flash-bios-ubiumount-prsv.service \
obmc-flash-bios-ubiumount-rw@.service \
obmc-flash-bios-squashfsmount@.service \
+ obmc-flash-bios-ubiremount.service \
"
diff --git a/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios b/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
index 2265275..dffd298 100644
--- a/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
+++ b/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
@@ -128,6 +128,34 @@
fi
}
+remount_ubi() {
+ pnormtd="$(findmtd pnor)"
+ pnor="${pnormtd#mtd}"
+ # Get information on all ubi volumes
+ ubinfo=$(ubinfo -d ${pnor})
+ presentVolumes=${ubinfo##*:}
+ IFS=', ' read -r -a array <<< "$presentVolumes"
+ for element in ${array[@]};
+ do
+ elementProperties=$(ubinfo -d $pnor -n $element)
+ # Get ubi volume name by getting rid of additional properties
+ name=${elementProperties#*Name:}
+ name="${name%Character*}"
+ name="$(echo -e "${name}" | tr -d '[:space:]')"
+
+ if [[ ${name} == pnor-prsv ]] || [[ ${name} == pnor-rw* ]] || [[ ${name} == pnor-ro* ]]; then
+ mountdir="/media/${name}"
+ if [[ ${name} == pnor-ro* ]]
+ then
+ ubiblock --create /dev/ubi${pnor}_${element}
+ mount -t squashfs -o ro "/dev/ubiblock${pnor}_${element}" "${mountdir}"
+ else
+ mount -t ubifs "ubi${pnor}:${name}" "${mountdir}"
+ fi
+ fi
+ done
+}
+
case "$1" in
ubiattach)
attach_ubi
@@ -145,6 +173,9 @@
name="$2"
umount_ubi
;;
+ ubiremount)
+ remount_ubi
+ ;;
*)
echo "Invalid argument"
exit 1
diff --git a/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiremount.service b/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiremount.service
new file mode 100644
index 0000000..fd839f3
--- /dev/null
+++ b/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiremount.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Remount the squashfs and ubi volumes after a reboot
+Requires=obmc-flash-bios-ubiattach.service
+After=obmc-flash-bios-ubiattach.service
+Wants=org.open_power.Software.Host.Updater.service
+Before=org.open_power.Software.Host.Updater.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=no
+ExecStart={sbindir}/obmc-flash-bios ubiremount
+
+[Install]
+WantedBy=multi-user.target