How to change ownership of Memory Card in TorizonCore

Hi,

I have installed lighttpd in Torizon for PHP web server.
I am able to run the web server and able to write the memory location (tmp & var)
by changing ownership for particular folder for PHP User.
But I am unable to change ownership in case of external Memory Card which
is mounted on /Media/mmcblk0p1.
I used ls -dl for this folder and found that its default user is root and while
changing ownership it gives error 'Operation not permitted’

Please help. How Can I give ownership to PHP Server User to give write access?

Note: We are using PHP to synchronize the Database which is located in Memory Card.

Regards,
Pradeep Pol

Greetings @eklavya19,

I believe I found a solution on my setup using a USB drive as a test external media.

Try running the following command when mounting your external media drive:

sudo mount -o rw,user,uid=1000,gid=1000,dmask=007,fmask=117 /dev/sdb1 /mnt/sd1

Make sure to modify the folders in the command to your use-case. Also the uid/gid of 1000 used above is the default ID for the torizon user if you have a another user then use the appropriate ID for your use-case instead. After mounting the external drive check again with ls and the mounted folder should now have the correct permission for whichever user.

Best Regards,
Jeremias

Hi @jeremias.tx,

Thanks for the reply.

Actually i tried this already but its not working. After applying command, user is still ‘root’.
2374-selection-099.png
Regards,
Pradeep Pol

After some more digging on my side it seems that uid/gid of 1000 is not the default for torizon in all cases. On some of my torizon modules across different software versions it seems to differ.

Run id on your device you should get an output similar to this:

uid=1220(torizon) gid=880(torizon) groups=880(torizon),27(sudo),46(plugdev),100(users),877(docker)

Make note of the uid and gid that gets returned in your setup and then try rerunning the mount command with the right ID numbers.

Best Regards,
Jeremias

Hi,

In my case, Both UID & GID are 1000.

2376-selection-100.png

Regards,

Pradeep Pol

Can you try completely unmounting the media with umount first? In my test running the command with the remount argument doesn’t actually work. You need to mount the media from scratch.

Best Regards,
Jeremias

Hi,

I have commented out auto mounting command from /etc/fstab for memory card and tried to mount directly with php user then its working but if I mount with torizon user then again I am unable to change the ownership.

Also How to automount or how to mount the card when container runs?

Regards,
Pradeep Pol

So you can only mount with gid/uid for this php user? But not the default torizon user? Are you making sure to unmount between each attempted mount? What happens if you try to mount with the torizon user’s uid/gid?

Also for auto-mounting into a container it depends. Will this drive be removed and attached throughout the life-cycle of the container? Or will it just be inserted once before/at container start?

After some research I found a feature that may help, “bind propagation”. I don’t believe we’ve ever tried this feature ourselves but it seems like it may do what you’re looking for.

https://docs.docker.com/storage/bind-mounts/#configure-bind-propagation

Best Regards,
Jeremias