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 <mtritz@us.ibm.com>
diff --git a/common/recipes-phosphor/flash/openpower-software-manager.bb b/common/recipes-phosphor/flash/openpower-software-manager.bb
index bdd8934..ebb23a1 100644
--- a/common/recipes-phosphor/flash/openpower-software-manager.bb
+++ b/common/recipes-phosphor/flash/openpower-software-manager.bb
@@ -51,4 +51,5 @@
obmc-flash-bios-ubiremount.service \
obmc-flash-bios-updatesymlinks.service \
obmc-flash-bios-ubiclear@.service \
+ obmc-flash-bios-cleanup.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 948c6ec..6e4aa78 100644
--- a/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
+++ b/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
@@ -270,6 +270,27 @@
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 @@
name="$2"
clear_ubi
;;
+ ubicleanup)
+ ubi_cleanup
+ ;;
*)
echo "Invalid argument"
exit 1
diff --git a/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-cleanup.service b/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-cleanup.service
new file mode 100644
index 0000000..07642a0
--- /dev/null
+++ b/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