Skip to contentSkip to conversation

udev: Don't remount root filesystem under /media

PATCH New Andy Ross 1 participant 1 message Aug 10, 2012

lore
Share & tools
lore

Andy Ross

author
#0 lore raw

PATCH 1/1 udev: Don't remount root filesystem under /media

The existing logic to avoid mounting already-mounted filesystems breaks for a kernel-mounted root, which appears as /dev/root in /proc/mounts. The effect is that an image booted with e.g. "root=/dev/mmcblk0p1" will find its root filesystem remount rw under /media/mmcblk0p1 at boot.

---
 meta/recipes-core/udev/udev/mount.sh | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
meta/recipes-core/udev/udev/mount.sh +9 -3
index c13b8bb..61d14a3 100644
@@ -49,9 +49,15 @@ if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ]; then
 	elif [ -x $MOUNT ]; then
     		$MOUNT $DEVNAME 2> /dev/null
 	fi
-	
-	# If the device isn't mounted at this point, it isn't configured in fstab
-	grep -q "^$DEVNAME " /proc/mounts || automount
+
+	# If the device isn't mounted at this point, it isn't
+	# configured in fstab (note the root filesystem shows up as
+	# /dev/root in /proc/mounts, so parse the command line for
+	# that case)
+	root=`sed 's/\(^\|.* \)root=\([^ ]*\).*/\2/' /proc/cmdline`
+	if [ "$root" != "$DEVNAME" ]; then
+		grep -q "^$DEVNAME " /proc/mounts || automount
+	fi
 fi
 
 
Signature · 1 line
1.7.11.2