diff mbox series

initramfs-framework: support LABEL with root-only udev trigger

Message ID 20260826092522.1618546-1-wenwfu@qti.qualcomm.com
State New
Headers show
Series initramfs-framework: support LABEL with root-only udev trigger | expand

Commit Message

Wenwen Fu Aug. 26, 2026, 9:25 a.m. UTC
Filesystem labels are not available in kernel uevents. Enable the
BusyBox findfs applet and use it to resolve root=LABEL= to a device.
Read the kernel-provided PARTUUID from sysfs and trigger only that
partition. Fall back to the full trigger when the label cannot be
resolved safely.

Signed-off-by: Wenwen Fu <wenwfu@qti.qualcomm.com>
---
 meta/recipes-core/busybox/busybox/defconfig          |  2 +-
 .../initrdscripts/initramfs-framework/udev           | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/recipes-core/busybox/busybox/defconfig b/meta/recipes-core/busybox/busybox/defconfig
index 1f4b5e3d1e..a282370a8f 100644
--- a/meta/recipes-core/busybox/busybox/defconfig
+++ b/meta/recipes-core/busybox/busybox/defconfig
@@ -634,7 +634,7 @@  CONFIG_FEATURE_FDISK_WRITABLE=y
 # CONFIG_FEATURE_OSF_LABEL is not set
 # CONFIG_FEATURE_GPT_LABEL is not set
 # CONFIG_FEATURE_FDISK_ADVANCED is not set
-# CONFIG_FINDFS is not set
+CONFIG_FINDFS=y
 CONFIG_FLOCK=y
 # CONFIG_FDFLUSH is not set
 # CONFIG_FREERAMDISK is not set
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/udev b/meta/recipes-core/initrdscripts/initramfs-framework/udev
index 8f67e78a7c..85c5ba1178 100644
--- a/meta/recipes-core/initrdscripts/initramfs-framework/udev
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/udev
@@ -43,6 +43,18 @@  udev_trigger_root_device() {
 		PARTUUID=?*)
 			root_match="PARTUUID=${bootparam_root#PARTUUID=}"
 			;;
+		LABEL=?*)
+			# The kernel does not export the filesystem LABEL in the
+			# uevent, so resolve it to a device node with findfs and
+			# match on that device's kernel-provided PARTUUID.
+			root_label="${bootparam_root#LABEL=}"
+			root_dev=$(findfs "LABEL=$root_label" 2>/dev/null) || return 1
+			[ -n "$root_dev" ] || return 1
+			root_partuuid=$(sed -n 's/^PARTUUID=//p' \
+				"/sys/class/block/${root_dev#/dev/}/uevent" 2>/dev/null)
+			[ -n "$root_partuuid" ] || return 1
+			root_match="PARTUUID=$root_partuuid"
+			;;
 		*)
 			return 1
 			;;