[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH initramfs-tools 2/3] Support MODULES=dep usage when root was mounted from hidden /dev/root



When a current kernel boots without an initramfs provided, it creates
/dev/root on an empty initramfs and mounts that.  There is no
/dev/root on the running system, so we fail to find the real device.
In that case, look up the root device in /proc/cmdline.

Related-to: #760127
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 hook-functions | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/hook-functions b/hook-functions
index dbe8cd2..ed22164 100644
--- a/hook-functions
+++ b/hook-functions
@@ -262,7 +262,29 @@ dep_add_modules()
 	fi
 
 	if [ "${root}" = "/dev/root" ] ; then
-		root="/dev/disk/by-uuid/"$(blkid -o value -s UUID ${root}) 2>/dev/null
+		if [ -b "${root}" ]; then
+			# Match it to the canonical device name by UUID
+			root="/dev/disk/by-uuid/"$(blkid -o value -s UUID ${root}) 2>/dev/null
+		else
+			# Does not exist in our namespace, so look at the
+			# kernel command line
+			root=
+			for arg in $(cat /proc/cmdline); do
+				case "$arg" in
+				root=*)
+					root="${arg#root=}"
+					if [ "${root#/dev/}" = "$root" ]; then
+						root="/dev/$root"
+					fi
+					;;
+				--)
+					break
+					;;
+				*)
+					;;
+				esac
+			done
+		fi
 	fi
 
 	# recheck root device


-- 
Ben Hutchings
This sentence contradicts itself - no actually it doesn't.

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: