TorizonCore container: Unable to read/write to SD card

Hi Toradex Community,

I am working with an Apalis iMX6 on an Ixora Evaluation Board v1.2, and TorizonCore 6.1.0 Build 1 as my base image.

I am attempting to read/write data from my application container to the SD card, but obtain Permission Denied errors.

So far, I’ve managed to expose my mountpoint /mnt, so the container, and am able to view the SD card content from the container.

However, attempting to read or write to it is not allowed.

What I’ve tried so far
The TorizonCore folder /mnt (where I mounted my SD card), is exposed to the container like so in my docker-compose file, giving it read/write permission (from my understanding):

I’ve tried playing around options shown in “Hardware Access” of the following section but to no avail: Torizon Best Practices Guide | Toradex Developer Center

I was wondering if someone can help me figure out what step am I missing to bind the /mnt volume with appropriate permissions for my container.

Kind regards,

Greetings @anthonyabboud,

I imagine what is happening is that your SD card once mounted belongs to the root user. Therefore read/write actions to this SD card can only be done by the root user or with root privileges. By the looks of it the user inside your container is the “torizon” user so it makes sense that you can’t read/write to the SD card.

Now to get around this you can change the ownership/permissions of the SD card after it’s mounted. There’s a couple of ways to do this though perhaps the most straightforward way is with a /etc/fstab entry. There’s a good example in this post here: Automatic mounting of sdcard on boot

You may need to adjust the line slightly to fit your needs/use-case, but the important part is the uid=1000,gid=1000 portion. This will change the uid/gid of the mounted drive to 1000, which so happens to match the uid/gid of the “torizon” user. Thereby effectively making the SD card and it’s contents owned by this user allowing for reads/writes.

Best Regards,

Hi @jeremias.tx,

Adding uid=1000,gid=1000 allows my container to read/write to the SD card just like mentioned in the linked post. Thank you very much!

By to way, to understand the format of an fstab entry, I tried playing with the other parameters, such as noauto and user to disable automount and allow the container itself to mount instead:

# uncomment this if your device has a SD/MMC/Transflash slot
/dev/mmcblk0p1       /mnt          auto       noauto,user,rw,sync,uid=1000,gid=1000  0  0

The SD automounts even then but I’m trying to give power to the container itself to mount/unmount it whenever it needs to.

Did I understand the full behavior of this entry correctly?

  • noauto = prevent automount at bootup
  • user = give torizon permission to mount/unmount /dev/mmcblk0p1
  • uid/gid = give torizon read/write permissions like we just mentioned

Well noauto prevents automatic mounting via fstab. However, in TorizonCore it’s not fstab that does the automatic mounting. There’s actually a service called usermount that handles this as you can see here: meta-toradex-torizon/recipes-support/usermount/usermount at kirkstone-6.x.y · toradex/meta-toradex-torizon · GitHub

You can try disabling this service if you don’t want this auto-mounting behavior. Though I’m not entirely sure if there will be any other side effects from disabling this. But, you can always re-enable it if things get strange.

Best Regards,