diff mbox series

[isar-cip-core,v3,1/2] make method to find /var mount configurable

Message ID 20231009115344.746642-2-felix.moessbauer@siemens.com (mailing list archive)
State Accepted
Headers show
Series make compatible with latest ISAR revision | expand

Commit Message

Felix Moessbauer Oct. 9, 2023, 11:53 a.m. UTC
Previously, the /var mount is only located by the partition label. This
is problematic, as collisions on this label might happen when working
with multiple disks. This patch makes the method to find the /var
partition configurable. By that, downstream implementations can use UUID
or PARTUUID based mounting.

For backwards compatibility we keep the current label-based mounting as
default.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 .../initramfs-overlay-hook/files/overlay.script.tmpl | 12 ++++++------
 .../initramfs-overlay-hook_0.1.bb                    |  5 +++--
 2 files changed, 9 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl
index 71d2599..d7da6fb 100644
--- a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl
+++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl
@@ -27,17 +27,17 @@  esac
 . /scripts/functions
 
 
-ovl_partition_label="${INITRAMFS_OVERLAY_STORAGE_PARTITION_LABEL}"
+ovl_partition_device="${INITRAMFS_OVERLAY_STORAGE_DEVICE}"
 ovl_storage_path="${INITRAMFS_OVERLAY_STORAGE_PATH}"
 ovl_lower_dirs="${INITRAMFS_OVERLAY_PATHS}"
 
 root_mount_storage=${rootmnt}${ovl_storage_path}
 
-if ! mountpoint -q "${rootmnt}/${ovl_partition_label}"; then
-	if ! mount -t $(get_fstype /dev/disk/by-label/${ovl_partition_label}) \
-		 /dev/disk/by-label/${ovl_partition_label} \
-		 ${rootmnt}/${ovl_partition_label}; then
-		panic "Can't mount /${ovl_partition_label} partition - overlay will not work!"
+if ! mountpoint -q "${rootmnt}/var"; then
+	if ! mount -t $(get_fstype ${ovl_partition_device}) \
+		 ${ovl_partition_device} \
+		 ${rootmnt}/var; then
+		panic "Can't mount /var partition - overlay will not work!"
 	fi
 fi
 
diff --git a/recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.1.bb b/recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.1.bb
index 566bd15..9e78dc8 100644
--- a/recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.1.bb
+++ b/recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.1.bb
@@ -19,12 +19,13 @@  SRC_URI += " \
 
 INITRAMFS_OVERLAY_PATHS ??= "/etc"
 INITRAMFS_OVERLAY_STORAGE_PATH ??= "/var/local"
-INITRAMFS_OVERLAY_STORAGE_PARTITION_LABEL ??= "var"
+# override this to switch to UUID or PARTUUID based mounts
+INITRAMFS_OVERLAY_STORAGE_DEVICE ??= "/dev/disk/by-label/var"
 
 TEMPLATE_FILES = "overlay.script.tmpl"
 TEMPLATE_VARS += " INITRAMFS_OVERLAY_STORAGE_PATH \
     INITRAMFS_OVERLAY_PATHS \
-    INITRAMFS_OVERLAY_STORAGE_PARTITION_LABEL"
+    INITRAMFS_OVERLAY_STORAGE_DEVICE"
 
 DEBIAN_DEPENDS = "initramfs-tools, awk, coreutils, util-linux"