@@ -35,6 +35,29 @@ udev_enabled() {
return 0
}
+udev_trigger_root_device() {
+ case "${bootparam_root:-}" in
+ PARTLABEL=?*)
+ root_match="PARTNAME=${bootparam_root#PARTLABEL=}"
+ ;;
+ PARTUUID=?*)
+ root_match="PARTUUID=${bootparam_root#PARTUUID=}"
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+
+ root_devices=$(udevadm trigger --dry-run --verbose \
+ --subsystem-match=block "--property-match=$root_match") || return 1
+
+ # udevadm succeeds even when no devices match, so check its dry-run output.
+ [ -n "$root_devices" ] || return 1
+
+ udevadm trigger --subsystem-match=block \
+ "--property-match=$root_match" --action=add
+}
+
udev_run() {
add_module_pre_hook "udev_shutdown_hook_handler"
@@ -45,6 +68,11 @@ udev_run() {
sh -c "exec 4< /dev/console" || { exec 0> /dev/null; exec 1> /dev/null; exec 2> /dev/null; }
$_UDEV_DAEMON --daemon
- udevadm trigger --action=add
+ if [ "${bootparam_initramfs_udev_root_only:-}" = "1" ] &&
+ udev_trigger_root_device; then
+ debug "Triggered udev for root partition only"
+ else
+ udevadm trigger --action=add
+ fi
udevadm settle
}
The initramfs udev module replays add events for the complete device tree and waits for every resulting event. An initramfs that only mounts a root partition does not need to coldplug unrelated devices. Add an opt-in initramfs.udev-root-only kernel parameter. When root uses PARTLABEL or PARTUUID, trigger only the matching block device. For PARTLABEL roots, match the PARTNAME property exposed by udev. Keep the existing full trigger as the default so current users and other initramfs modules retain their existing behaviour. If the requested root cannot be matched safely, or a targeted trigger fails, fall back to the original full coldplug. Signed-off-by: Wenwen Fu <wenwfu@qti.qualcomm.com> --- .../initrdscripts/initramfs-framework/udev | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)