diff options
Diffstat (limited to 'recipes-core/udev/files')
-rw-r--r-- | recipes-core/udev/files/bootpart-automount.rules | 6 | ||||
-rwxr-xr-x | recipes-core/udev/files/toradex-mount-bootpart.sh | 33 |
2 files changed, 39 insertions, 0 deletions
diff --git a/recipes-core/udev/files/bootpart-automount.rules b/recipes-core/udev/files/bootpart-automount.rules new file mode 100644 index 0000000..8b02dec --- /dev/null +++ b/recipes-core/udev/files/bootpart-automount.rules @@ -0,0 +1,6 @@ +# Toradex specific, to bind mount boot partition to /boot. +# +# To be noticed: Be careful if you want to change the rule file name, it must be loaded +# by udevd after automount.rules, otherwise, the original mount point might be not present. +# +ACTION=="add", KERNEL=="mmcblk[0-9]p[0-9]*", RUN+="/etc/udev/scripts/toradex-mount-bootpart.sh" diff --git a/recipes-core/udev/files/toradex-mount-bootpart.sh b/recipes-core/udev/files/toradex-mount-bootpart.sh new file mode 100755 index 0000000..965d747 --- /dev/null +++ b/recipes-core/udev/files/toradex-mount-bootpart.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env sh +# +# Bind mount boot partition /boot -> /${MOUNT_BASE}/BOOT-PARTITION-MOUNTPOINT +# in which: +# MOUNT_BASE is defined in /etc/udev/scripts/mount.sh +# BOOT-PARTITION-MOUNTPOINT is the mount point of boot partition. + +BASEUUID=$(sed -r 's/^.*\broot=PARTUUID=([0-9a-f]+)-02.*$/\1/' /proc/cmdline) +BOOTPART=$(readlink -f /dev/disk/by-partuuid/"${BASEUUID}-01") +if [ x"$DEVNAME" = x"$BOOTPART" ]; then + MOUNTPOINT="$(lsblk -o MOUNTPOINT -nr "$DEVNAME" | head -1)" + MOUNTNAME="$(basename "$MOUNTPOINT")" + BASE_INIT="$(readlink -f "@base_sbindir@/init")" + INIT_SYSTEMD="@systemd_unitdir@/systemd" + + if [ "x$BASE_INIT" = "x$INIT_SYSTEMD" ];then + # systemd as init uses systemd-mount to mount block devices + MOUNT="/usr/bin/systemd-mount --no-block -o silent" + UMOUNT="/usr/bin/systemd-umount" + else + MOUNT="/bin/mount" + UMOUNT="/bin/umount" + + # Silent util-linux's version of mounting auto + if [ "x$(readlink $MOUNT)" = "x/bin/mount.util-linux" ]; then + MOUNT="$MOUNT -o silent" + fi + fi + + if [ -e /tmp/.automount-"$MOUNTNAME" ]; then + $MOUNT -o bind "$MOUNTPOINT" /boot + fi +fi |