recovery-initramfs-init: fix "update" volume wipe when singlemtdsys is enabled

Currently, when wiping the update volume via the recovery partition on a
ccimx6ul with singlemtdsys enabled, the procedure fails with this error:

    [RECOVERY] Starting recovery...
    [RECOVERY] Wipe 'update' partition requested
    [RECOVERY] Formatting 'update' ubi volume
    ubi0 error: ubi_open_volume.part.0: cannot open device 0, volume 3, error -16
    ubiupdatevol: error!: cannot open "/dev/ubi0_3"
                  error 16 (Device or resource busy)

This is because the logic used to unmount a volume before formatting it is
expecting this entry format when running "mount":

    ubi0:update on /mnt/update type ubifs

While this is the format of the "mount" output in userspace for the rootfs
volume, other trivial volumes have this format instead:

    ubi0_3 on /mnt/update type ubifs

Adapt the logic to this format so that the "update" volume wipe procedure can
take place.

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
Gabriel Valcazar 2024-06-28 13:07:11 +02:00
parent 17658bdffa
commit 5695cf15db
1 changed files with 2 additions and 2 deletions

View File

@ -277,8 +277,8 @@ format_ubi_volume() {
volname="$(ubinfo ${v} | grep ^Name | awk '{print $(2)}')" volname="$(ubinfo ${v} | grep ^Name | awk '{print $(2)}')"
if [ "${volname}" = "${1}" ]; then if [ "${volname}" = "${1}" ]; then
# Find mountpoint # Find mountpoint
u="$(basename ${d})" u="$(basename ${v})"
mountpoint="$(mount | grep ${u}:${1} | awk '{print $(3) }')" mountpoint="$(mount | grep ${u} | awk '{print $(3) }')"
umount ${mountpoint} 2> /dev/null umount ${mountpoint} 2> /dev/null
# Wipe out volume # Wipe out volume
ubiupdatevol ${v} -t ubiupdatevol ${v} -t