mount_digiparts.sh: add support to dualboot volumes on read-only mode

This commit allows to mount only the linux partition active in read-only mode.

https://onedigi.atlassian.net/browse/DEL-8193

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
This commit is contained in:
Arturo Buzarra 2022-11-17 11:40:28 +01:00
parent 5be7db1f9f
commit 4d07069448
1 changed files with 15 additions and 2 deletions

View File

@ -26,12 +26,25 @@ elif [ "${SUBSYSTEM}" = "ubi" ]; then
PARTNAME="$(cat /sys/${DEVPATH}/name)"
fi
MOUNT_FOLDER=${PARTNAME}
MOUNT_PARAMS="-o silent"
# Mount 'linux' partition as read-only
if [ "${PARTNAME}" = "linux" ]; then
if [ "${PARTNAME}" = "linux" ] || [ "${PARTNAME}" = "linux_a" ] || [ "${PARTNAME}" = "linux_b" ]; then
MOUNT_FOLDER="linux"
MOUNT_PARAMS="${MOUNT_PARAMS} -o ro"
fi
DUALBOOT_MODE="$(fw_printenv -n dualboot 2>/dev/null)"
if [ "${DUALBOOT_MODE}" = "yes" ]; then
if [ "${PARTNAME}" = "linux_a" ] || [ "${PARTNAME}" = "linux_b" ]; then
ACTIVE_SYSTEM="$(fw_printenv -n active_system 2>/dev/null)"
if [ "${ACTIVE_SYSTEM}" != "${PARTNAME}" ]; then
logger "Skip mount partition '${PARTNAME}', because it is not the active system"
exit 0
fi
fi
fi
if [ "x$BASE_INIT" = "x$INIT_SYSTEMD" ];then
# systemd as init uses systemd-mount to mount block devices
MOUNT="/usr/bin/systemd-mount"
@ -57,7 +70,7 @@ else
fi
# Create mount point if needed
MOUNTPOINT="/mnt/${PARTNAME}"
MOUNTPOINT="/mnt/${MOUNT_FOLDER}"
[ -d "${MOUNTPOINT}" ] || mkdir -p ${MOUNTPOINT}
if [ "${SUBSYSTEM}" = "block" ]; then