Mount Options from fstab get ignored when using the "colibri-sd" link of sd card

Hi,
I want to give the torizon user (uid 1000) write access to the SD card on our colibri imx7 (using torizon-core-docker-colibri-imx7-emmc-Tezi_5.7.2+build.20).

Using uid and fmask in /etc/fstab works Automatic mounting of sdcard on boot

However, on my system the SD card is available under /dev/mmcblk0 which means, that, when the sd card is not inserted, the built in flash (which is under /dev/mmcblk1 when a sd card is present) will have that path.

I found the nice symlink /dev/colibri-sd-part1 which points to /dev/mmcblk0 (and I would assume that this symlink will not be present / point to nowhere, when there is no SD card inserted. Haven’t confirmed yet, since currently working remote).

But the following line in /etc/fstab with symlink works only halfways. It will mount the SD card under /media/sdcard but it is still owned by root and others have no write permission.

/dev/colibri-sd-part1 /media/sdcard auto defaults,uid=1000,gid=1000,dmask=0000,fmask=0111,nofail 0 0 mounts, but without specified permissions

When using the direct device path, it works just fine. However, this may mess things up, when the SD card is not present (not inserted or died in field…).

/dev/mmcblk0p1 /media/sdcard auto defaults,uid=1000,gid=1000,dmask=0000,fmask=0111,nofail 0 0 mounts with specified permissions

When using the /dev/disk/by-label/LOGGING symlink, it also works just fine. However, this complicates the process of preparing the SD card.

/dev/disk/by-label/LOGGING /media/sdcard auto defaults,uid=1000,gid=1000,dmask=0000,fmask=0111,nofail 0 0 mounts with specified permissions

How can I use the symlink and get writeable permissions for the torizon user? Or is there another way to address the SD card without the risk of confusing it with the builtin flash?

Thanks in advance

Hello @bfa,

Welcome to the Toradex Community :tada:

Could you please try and see if this solution works for you?
As @jeremias.tx suggested, I tried with the command mount -o nofail,uid=1000,gid=1000,umask=007 $dev /var/rootdirs/media 2>/dev/null || true and it seems to work for me.

Please let us know how it goes.

Hi,
Thanks for your fast response.

I don’t think, that using mount instead of udisksctl mount in the usermount.service would work. The automatic mountpoint assignment of udisksctl isn’t available in mount and therefore fail if more than one device is attached.

However, thanks for pointing me to the usermount.service, which helped me to debug my issue and find a solution.

The problem is that the usermount.service mounted the SD card first with the wrong permissions, since it is not using /etc/fstab. Then it was mounted again by the entry in the /etc/fstab, which can’t set permissions correctly, when the card is already mounted.

My solution was to disable the usermount.service. Then the SD card is only mounted via the /etc/fstab and everything is working as expected.