Define auto mountpoint for usb storage and hot plug

Dear Developer Community,

in TorizonCore 5.1.0 on Colibri iMX8X, USB drives are automatically mounted to a new folder with the same volume name under /media (/var/rootdirs/media/corsair)

By adjusting /etc/fstab like in this post mentioned
rw-automount
I can define mountpoint of plugged in USB storage after reboot to e.g. /media/desiredName adding:
/dev/sda1 /media/desiredName auto relatime,nofail,utf8,uid=torizon,gid=torizon,umask=002 0 0

Hot removing and reinserting mounts the USB storage into /var/rootdirs/media/corsair again, but I want it to appear in /media/dresiredName.

[in your torizoncore]
Please look at /etc/udev/scripts/mount.sh , function automount()

[in torizon source git]
https://git2.toradex.com/cgit/meta-toradex-bsp-common.git/tree/recipes-core/udev/files/mount.sh?h=dunfell-5.x.y

Greetings @pettaa1234,

Not sure I fully understand your issue.

Are you saying that after making the changes to /etc/fstab your USB is still not being mounted as desiredName, but as corsair still?

I just did a quick test and making the change to /etc/fstab does affect my USB mount name. Perhaps try other USBs?

Best Regards,
Jeremias

@jeremias.tx you are right, but hot removing/reinserting mounts the USB under
/var/rootdirs/media/corsair instead of /media/desiredName

How can I overcome this?

Well /var/rootdirs/media symlinks to /media as seen here:

lrwxrwxrwx 2 root root 18 Oct 7 12:53 /media -> var/rootdirs/media

Effectively these are the same location on the filesystem. For some reason though your setup is ignoring your /etc/fstab entry. Could you try a more recent TorizonCore version if possible? My testing on 5.4.0 shows /etc/fstab entries are working as expected.

Another thing to check is that your /etc/fstab entry assumes the USB is device /dev/sda1. Are you sure about this? Or is the USB being enumerated as something else like /dev/sda2 or something?

Best Regards,
Jeremias