From ed6d7b07832f7a9e32a7dc2ac3afb7b35608c8d3 Mon Sep 17 00:00:00 2001 From: Michael Tritz Date: Thu, 21 Sep 2017 00:41:15 -0500 Subject: Service files to remove orphaned UBI volumes This commit provides supplementary service files for openbmc/openbmc#2264, which adds a function to delete all versions to each of the BMC and host updaters. The service files introduced in this change will locate any "orphaned" BMC or host volumes - that is to say, volumes which do not correspond to a current version on the system. Change-Id: If324d24f66ba08fb0b76ca5873addb6bf2446f97 Signed-off-by: Michael Tritz --- .../openpower-software-manager/obmc-flash-bios | 24 ++++++++++++++++++++++ .../obmc-flash-bios-cleanup.service | 8 ++++++++ 2 files changed, 32 insertions(+) create mode 100644 meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-cleanup.service (limited to 'meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager') 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 948c6ec05..6e4aa78cf 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 @@ -270,6 +270,27 @@ clear_ubi() { fi } +ubi_cleanup() { + # When ubi_cleanup is run, it expects one or no active version. + activeVersion=$(busctl --list --no-pager tree \ + org.open_power.Software.Host.Updater | \ + grep /xyz/openbmc_project/software/ | tail -c 9) + + if [[ -z "$activeVersion" ]]; then + vols=$(ubinfo -a | grep -e "pnor-ro-" -e "pnor-rw-" | cut -c 14-) + vols=(${vols}) + else + vols=$(ubinfo -a | grep -e "pnor-ro-" -e "pnor-rw-" | \ + grep -v "$activeVersion" | cut -c 14-) + vols=(${vols}) + fi + + for (( index=0; index<${#vols[@]}; index++ )); do + name=${vols[index]} + umount_ubi + done +} + case "$1" in ubiattach) attach_ubi @@ -297,6 +318,9 @@ case "$1" in name="$2" clear_ubi ;; + ubicleanup) + ubi_cleanup + ;; *) echo "Invalid argument" exit 1 diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-cleanup.service b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-cleanup.service new file mode 100644 index 000000000..07642a0e0 --- /dev/null +++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-cleanup.service @@ -0,0 +1,8 @@ +[Unit] +Description=Clean up UBI volumes unattached to a Host version + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart=/usr/bin/env obmc-flash-bios ubicleanup +SyslogIdentifier=obmc-flash-bios -- cgit v1.2.1