recovery-initramfs: add script and mdev rule for UBI volumes

On systems with a single MTD system partition and multiple UBI
volumes, the initramdisk doesn't mount the 'update' partition
because mdev rules only trigger events for MTD partitions.

This commit adds a rule to trigger an event for every /dev/ubi0_x
(every UBI volume on ubi0 device) and call the new automount_ubi.sh
script. The script checks if the volume is called 'update' and if
so, it creates /mnt/update mountpoint and mounts the volume.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>

https://onedigi.atlassian.net/browse/DEL-8297
(cherry picked from commit df9c622b1bf0a7307c61deda12cf1f67d4f630f0)
This commit is contained in:
Hector Palacios 2023-01-16 18:03:26 +01:00
parent f6eeb0fdfb
commit 8b8f9560af
3 changed files with 24 additions and 1 deletions

View File

@ -5,7 +5,7 @@ LICENSE = "GPL-2.0-only"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6"
# When building a TrustFence enabled recovery initramfs, we need the TrustFence PKI tree to # When building a TrustFence enabled recovery initramfs, we need the TrustFence PKI tree to
# be already generated in order to copy the public key. Forcing a dependence against # be already generated in order to copy the public key. Forcing a dependence against
# 'virtual/kernel' ensures that the keys are already generated as they are needed to sign the # 'virtual/kernel' ensures that the keys are already generated as they are needed to sign the
# kernel artifacts. # kernel artifacts.
DEPENDS += "${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'virtual/kernel openssl-native', '', d)}" DEPENDS += "${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'virtual/kernel openssl-native', '', d)}"
@ -15,6 +15,7 @@ SRC_URI = " \
file://swupdate.cfg \ file://swupdate.cfg \
file://automount_block.sh \ file://automount_block.sh \
file://automount_mtd.sh \ file://automount_mtd.sh \
file://automount_ubi.sh \
file://mdev.conf \ file://mdev.conf \
${@bb.utils.contains('STORAGE_MEDIA', 'mmc', 'file://mount_cryptrootfs.sh', '', d)} \ ${@bb.utils.contains('STORAGE_MEDIA', 'mmc', 'file://mount_cryptrootfs.sh', '', d)} \
" "
@ -31,6 +32,7 @@ do_install() {
install -d ${D}${base_libdir}/mdev install -d ${D}${base_libdir}/mdev
install -m 0755 ${WORKDIR}/automount_block.sh ${D}${base_libdir}/mdev/automount_block.sh install -m 0755 ${WORKDIR}/automount_block.sh ${D}${base_libdir}/mdev/automount_block.sh
install -m 0755 ${WORKDIR}/automount_mtd.sh ${D}${base_libdir}/mdev/automount_mtd.sh install -m 0755 ${WORKDIR}/automount_mtd.sh ${D}${base_libdir}/mdev/automount_mtd.sh
install -m 0755 ${WORKDIR}/automount_ubi.sh ${D}${base_libdir}/mdev/automount_ubi.sh
install -m 0644 ${WORKDIR}/mdev.conf ${D}${sysconfdir} install -m 0644 ${WORKDIR}/mdev.conf ${D}${sysconfdir}
# If Trustfence is enabled, copy the public key that is going to be used into the # If Trustfence is enabled, copy the public key that is going to be used into the

View File

@ -0,0 +1,20 @@
#!/bin/sh
#
# Copyright (c) 2023, Digi International Inc.
#
UPDATE_MOUNTPOINT="/mnt/update"
PARTITION_NAME="update"
# Check if there is a UBI volume called 'update'
# (for single MTD systems).
volname="$(ubinfo ${MDEV} | awk '$1=="Name:" {print $2}')"
if [ "${volname}" = "${PARTITION_NAME}" ]; then
if mkdir -p ${UPDATE_MOUNTPOINT} && ! mountpoint -q ${UPDATE_MOUNTPOINT}; then
# Mount the volume.
if ! mount -t ubifs "${MDEV}" "${UPDATE_MOUNTPOINT}"; then
echo "ERROR: Could not mount '${PARTITION_NAME}' partition"
rmdir --ignore-fail-on-non-empty ${UPDATE_MOUNTPOINT}
fi
fi
fi

View File

@ -2,3 +2,4 @@
sd[a-z][0-9]+ 0:0 660 */lib/mdev/automount_block.sh sd[a-z][0-9]+ 0:0 660 */lib/mdev/automount_block.sh
mmcblk[0-9]+p[0-9]+ 0:0 660 */lib/mdev/automount_block.sh mmcblk[0-9]+p[0-9]+ 0:0 660 */lib/mdev/automount_block.sh
mtd[0-9]+ 0:0 660 */lib/mdev/automount_mtd.sh mtd[0-9]+ 0:0 660 */lib/mdev/automount_mtd.sh
ubi0_[0-9]+ 0:0 660 */lib/mdev/automount_ubi.sh