From 691489bbe45b79310c2016ba7c4e6bf5a07547c8 Mon Sep 17 00:00:00 2001 From: Max Krummenacher Date: Wed, 24 Feb 2021 19:19:48 +0100 Subject: 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 (cherry picked from commit c8651feae915eeac23510565dde0f64557696de7) --- recipes-core/udev/files/mount.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'recipes-core') 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" -- cgit v1.2.3