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-03 13:26:23 +0000
commitc8651feae915eeac23510565dde0f64557696de7 (patch)
treefe53d8f6617ffc69ff4de6194792efda65a5e8c5
parenta4f005089d9c286fa33f4fb5f2e41f1a0ee614d6 (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>
-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"