summaryrefslogtreecommitdiff
path: root/recipes-core
diff options
context:
space:
mode:
authorMing Liu <ming.liu@toradex.com>2022-07-26 15:58:39 +0200
committerFrancesco Dolcini <francesco.dolcini@toradex.com>2022-07-26 14:49:30 +0000
commita403bdf1785b7975411acc7c3a920bd52cfee5f2 (patch)
tree92b5caa9bfa35895f6be84679bf33617a7d3e9c2 /recipes-core
parent24da367be6a1d33d9ce2947658b12fc8e4444d33 (diff)
udev-toradex-rules: introduce bootpart-automount.rules
It will handle bind mount boot partition to /boot. provided that the modules boot from eMMC/SDCard devices and there is a boot partition present. It whould work with both sysvinit and systemd init managers. Related-to: ELB-4620 Signed-off-by: Ming Liu <ming.liu@toradex.com>
Diffstat (limited to 'recipes-core')
-rw-r--r--recipes-core/udev/files/bootpart-automount.rules6
-rwxr-xr-xrecipes-core/udev/files/toradex-mount-bootpart.sh33
-rw-r--r--recipes-core/udev/udev-toradex-rules.bb11
3 files changed, 48 insertions, 2 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
diff --git a/recipes-core/udev/udev-toradex-rules.bb b/recipes-core/udev/udev-toradex-rules.bb
index a94da96..c31f416 100644
--- a/recipes-core/udev/udev-toradex-rules.bb
+++ b/recipes-core/udev/udev-toradex-rules.bb
@@ -3,16 +3,23 @@ LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "\
- file://99-toradex.rules \
file://10-toradex-wifi-ifnames.link \
+ file://99-toradex.rules \
+ file://bootpart-automount.rules \
file://toradex-adc.sh \
+ file://toradex-mount-bootpart.sh \
"
do_install () {
install -d ${D}${sysconfdir}/udev/rules.d
install -d ${D}${sysconfdir}/udev/scripts
install -d ${D}${sysconfdir}/systemd/network
+ install -m 0644 ${WORKDIR}/10-toradex-wifi-ifnames.link ${D}${sysconfdir}/systemd/network/
install -m 0644 ${WORKDIR}/99-toradex.rules ${D}${sysconfdir}/udev/rules.d/
+ install -m 0644 ${WORKDIR}/bootpart-automount.rules ${D}${sysconfdir}/udev/rules.d/
install -m 0755 ${WORKDIR}/toradex-adc.sh ${D}${sysconfdir}/udev/scripts/
- install -m 0644 ${WORKDIR}/10-toradex-wifi-ifnames.link ${D}${sysconfdir}/systemd/network/
+ install -m 0755 ${WORKDIR}/toradex-mount-bootpart.sh ${D}${sysconfdir}/udev/scripts/
+
+ sed -i 's|@systemd_unitdir@|${systemd_unitdir}|g' ${D}${sysconfdir}/udev/scripts/toradex-mount-bootpart.sh
+ sed -i 's|@base_sbindir@|${base_sbindir}|g' ${D}${sysconfdir}/udev/scripts/toradex-mount-bootpart.sh
}