diff options
author | Saqib Khan <khansa@us.ibm.com> | 2017-08-10 11:24:38 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-08-16 21:27:40 +0000 |
commit | cbc74ac23f1594d4fd2022cc552e7ebf60a64c82 (patch) | |
tree | 18720ac8591cfca9cd9d5a4d9fcb774753b94edb /meta-phosphor/common | |
parent | c9a417424a32971f3e685b4a422ea25290e8fa2f (diff) | |
download | talos-openbmc-cbc74ac23f1594d4fd2022cc552e7ebf60a64c82.tar.gz talos-openbmc-cbc74ac23f1594d4fd2022cc552e7ebf60a64c82.zip |
BMC: Mount ubi volume on BMC reboot
- Create a static service file that will be run
on all BMC boot to remount the bmc ubi volume.
- Read the ubinfo for all available volumes from
obmc-flash-bmc script.
- Re-Mount the available volumes on /media/ dir
using the volume names.
Change-Id: I8f3a0b41257927fa0e69001278cc836ba0a52dda
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
Diffstat (limited to 'meta-phosphor/common')
3 files changed, 53 insertions, 0 deletions
diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb index ef8d30e8e..96a66e20b 100644 --- a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb +++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb @@ -72,6 +72,7 @@ SYSTEMD_SERVICE_${PN}-updater += " \ obmc-flash-bmc-ubirw-remove.service \ obmc-flash-bmc-ubiro-remove@.service \ usr-local.mount \ + obmc-flash-bmc-ubiremount.service \ " # Name of the mtd device where the ubi volumes should be created diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc index 5c960f3b8..d17ee5c36 100644 --- a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc +++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc @@ -80,6 +80,43 @@ ubi_remove() { fi } +remount_ubi() { + # Get a list of all devices formatted as UBI + for file in /dev/mtd*; do + if [[ $(hexdump -C -n 3 $file) =~ "UBI" ]]; then + mtd="${file: -1}" + if [[ $mtd =~ ^-?[0-9]+$ ]]; then + mtds=${mtd},${mtds} + fi + fi + done + + IFS=',' read -r -a mtds <<< "$mtds" + mtds=($(echo "${mtds[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')) + for mtd in ${mtds[@]}; do + # Re-attach mtd device to ubi if not already done + ubiattach /dev/ubi_ctrl -m "${mtd}" -d "${mtd}" &> /dev/null + # Get information on all ubi volumes + ubinfo=$(ubinfo -d ${mtd}) + presentVolumes=${ubinfo##*:} + IFS=', ' read -r -a array <<< "$presentVolumes" + for element in ${array[@]}; do + elementProperties=$(ubinfo -d $mtd -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} == ro-* ]]; then + mountdir="/media/${name}" + mkdir -p "${mountdir}" + ubiblock --create /dev/ubi${mtd}_${element} &> /dev/null + mount -t squashfs -o ro "/dev/ubiblock${mtd}_${element}" "${mountdir}" + fi + done + done +} + ubi_setenv() { varName="${variable%"\x3d"*}" value="${variable##*"\x3d"}" @@ -119,6 +156,9 @@ case "$1" in variable="$2" ubi_setenv ;; + ubiremount) + remount_ubi + ;; *) echo "Invalid argument" exit 1 diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubiremount.service b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubiremount.service new file mode 100644 index 000000000..36b55516b --- /dev/null +++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubiremount.service @@ -0,0 +1,12 @@ +[Unit] +Description=Remount the ubi volume after a reboot +Wants=xyz.openbmc_project.Software.BMC.Updater.service +Before=xyz.openbmc_project.Software.BMC.Updater.service + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart={sbindir}/obmc-flash-bmc ubiremount + +[Install] +WantedBy=multi-user.target |