Why is my boot partition mounted twice?

I am building the tdx-reference-minimal-image using the toradex-manifest git repository.
I have extra layers I include for my custom application and systemd services.

When running my built image I am seeing the boot partition get mounted twice.
I also see my other generated partitions being auto mounted.

root@streamProcessor:~# lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
mmcblk2      179:0    0 29.1G  0 disk
|-mmcblk2p1  179:1    0   48M  0 part /boot
|                                     /media/BOOT-mmcblk2p1
|-mmcblk2p2  179:2    0 10.4G  0 part /

What can I do to stop these from being auto mounted?
I am assuming it is something to do with udev? As I am pretty sure we add something for that so we can disable the mounting of USB storage devices for security reasons.

My custom partitions I assume I can just add to the mount.ignorelist file, but I am not sure that is possible for the boot partition as I think that would cause none of the mounts to occur.

I suspect it is an ordering thing between the automount.rules from udev-extraconf and the bootpart-automount.rules which appears to be a toradex thing (as it points to a toradex names script file).

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

The issue you’re encountering with the boot partition being mounted twice seems to be related to the automount features provided by udev rules, as you’ve correctly identified. This can happen when multiple rules are set to mount partitions upon detection, which is common in systems designed to be user-friendly by automatically mounting filesystems for easy access.

To address this issue, you can take the following steps:

  1. Review and Modify Udev Rules: Start by reviewing the udev rules related to automounting. Look for files like automount.rules and bootpart-automount.rules within /etc/udev/rules.d/ or /lib/udev/rules.d/. You might find rules that automatically mount partitions based on their labels or types. If the boot partition is being mounted by both a generic automount rule and a Toradex-specific rule, you may need to adjust these rules to prevent double mounting.

  2. Customize Mount Options: For your custom partitions, adding entries to the mount.ignorelist is a good approach. However, for the boot partition, since it needs to be mounted for the system to function correctly, you cannot simply ignore it. Instead, you might need to customize the rule that mounts the boot partition to ensure it’s only mounted once, in the desired location.

  3. Ordering of Udev Rules: Udev processes rules in lexical order, so the order in which rules are applied matters. You can rename the rule files to change the order in which they are processed. Files are processed in lexical order, so prefixing filenames with numbers can control the order (e.g., 10-automount.rules would be processed before 90-bootpart-automount.rules). Adjusting the order might help resolve conflicts between rules.

  4. Disable Unnecessary Rules: If certain automount features are not required for your application, you can disable them by renaming the rule files to have a .disabled extension or by commenting out specific lines in the rule files. This can help prevent unwanted automount behavior.

  5. Udev Control: If the automounting is indeed being triggered by udev, and if it’s not critical for your use case, consider disabling the specific udev rule responsible for the unwanted mount. This might involve commenting out or modifying the rule that matches your boot partition.

  6. Systemd Mount Units: Check if there are any systemd mount units (*.mount) responsible for mounting these partitions. Systemd might be

Please, also check if these links can help you solve your problem:

Distro Boot | Toradex Developer Center.

Hello @izzy_building,

That is correct, you can also use this for /dev/mmcblk2p1.
This will result in the boot partition not being mounted when the system is up, but this does not stop the system for booting or loading the device tree or overlays.

If you just want /boot to not be mounted, while keeping /media/BOOT-mmcblk2p1, you can remove the /etc/udev/scripts/toradex-mount-bootpart.sh script from your image, as it is responsible for this extra mount point.

This file is added by the udev-toradex-rules recipe.

Best Regards,
Bruno

@bruno.tx
So I could also remove the bootpart-automount.rules file too? this is what creates the rule to call that script.
I assume this is then not responsible for mounting it as /boot?
Regards,

Hello @izzy_building,

I apologize for the confusion, my previous comment was incorrect.
The /etc/udev/scripts/toradex-mount-bootpart.sh script is actually used to create the /boot mountpoint.
The /media/BOOT-mmcblk2p1 mountpoint is the one created by default.
I will correct my previous comment to reflect that.

Yes, if you don’t need the /etc/udev/scripts/toradex-mount-bootpart.sh script, you can remove the bootpart-automount.rules file.

Best Regards,
Bruno

@bruno.tx
So just to confirm…
If I want to remove the /boot mount I remove the toradex script and bootpart-automount.rules in udev-toradex-rules.bbappend.
But if I want to remove the /media/... ones then I can add /dev/mmcblk2p[0-9]* to the mount.ignorelist in udev-extraconf_%.bbappend.
I believe that is what you are saying?
Regards,

Hello @izzy_building,

That is correct.


By adding /dev/mmcblk2p[0-9]* to the mount.ignorelist file, you end up without /media/... and /boot, as the /media/... mount is the default one.
A possible approach to keep only the /boot mount, could be to modify the toradex-mount-bootpart.sh script to unmount the /media/... mount after /boot is mounted.

Best Regards,
Bruno