summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2021-02-24 19:19:48 +0100
committerMax Krummenacher <max.krummenacher@toradex.com>2021-03-23 17:34:45 +0100
commit691489bbe45b79310c2016ba7c4e6bf5a07547c8 (patch)
tree528d026e6c9b43f7d3545c9f4892126af8fcad50
parent6e7481b6373c18915abec98f1d56f684268e221b (diff)
udev: mount.sh: create a symlink to the partition with the bootfiles
Add to the mount.sh script code which creates a symlink to partition with the bootfiles if that can be guessed from the rootfs partition. Scan the /proc/cmdline for the rootfs partition. If this is the second partition of a block device and a first partition exists it creates the symlink /dev/boot-part. /etc/fstab consumes the symlink to mount that at /boot. Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> (cherry picked from commit c8651feae915eeac23510565dde0f64557696de7)
-rw-r--r--recipes-core/udev/files/mount.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/recipes-core/udev/files/mount.sh b/recipes-core/udev/files/mount.sh
index 323458d..e179ec4 100644
--- a/recipes-core/udev/files/mount.sh
+++ b/recipes-core/udev/files/mount.sh
@@ -4,6 +4,25 @@
#
# Attempt to mount any added block devices and umount any removed devices
+# By default we boot from a block device the BSP uses the first partition to
+# store the files used by U-Boot, aka. the bootfs. The second partition of the
+# same block device then contains the rootfs.
+# Read the PARTUUID of the rootfs from /proc/cmdline, check if that device
+# exists and then assume that the first partition on that device is the one
+# with the bootpartion on it.
+# Symlink that partition to /dev/boot-part, that then gets mounted to /boot,
+# compare with /etc/fstab.
+
+# expects 'root=PARTUUID=fe6beb3d-02' in /proc/cmdline
+
+BASEUUID=$(sed 's/root=\([^[:space:]]*\).*/\1/ ; s/PARTUUID=\([0-9a-f]*\)-02/\1/' /proc/cmdline)
+if [ -b /dev/disk/by-partuuid/${BASEUUID}-02 ]; then
+ BOOTPART=$(readlink -f /dev/disk/by-partuuid/${BASEUUID}-01)
+ if [ x$DEVNAME = x$BOOTPART ]; then
+ logger "$0 creating symlink"
+ ln -sf $BOOTPART /dev/boot-part
+ fi
+fi
MOUNT="/bin/mount"
PMOUNT="/usr/bin/pmount"