Mount all removable USBs writable to user torizon

Greetings @jmcwa,

Just to make sure I understand your use-case, is the idea that any kind of FAT-formatted USB can be plugged and removed from your system at any time, and no matter the USB it must be mounted with permissions for the torizon user?

If that is the case this can be tricky with FAT formatted filesystems.

For context we have a systemd service usermount.service that auto mounts devices to /media. This service uses udisk2 to facilitate the mounting process. However, as you have noticed it doesn’t handle FAT very well due to the lack of unix permissions in this filesystem so it just defaults to root permissions.

I did a quick test and I have a possible idea. So here’s the auto-mounting script we use: https://github.com/toradex/meta-toradex-torizon/blob/kirkstone-6.x.y/recipes-support/usermount/usermount/usermount-mounter

As you can see it uses the line udisksctl mount -b $dev 2>/dev/null || true to finally mount the device. I tried instead replacing this command with the mount command directly, something like this mount -o nofail,uid=1000,gid=1000,umask=007 $dev /var/rootdirs/media 2>/dev/null || true, and this seems to work though I haven’t rigorously tested this.

You could probably make a similar script that loops and start it using another systemd service. You’ll probably need to disable our usermount.service to prevent conflicts. This is just a quick idea I had so there may be something I’m missing.

Best Regards,
Jeremias

1 Like