I know this is an old thread, but I came across it while looking to do the same thing, and found a solution using fstab, see below:
First, plug in a drive to the port you want to map a mountpoint to. Use sudo blkid
to get the /dev/sd** path to the drive & note this down/remember it. I'll be using '/dev/sda1'
Second, use udevadm info --name=/dev/sda1 | grep disk/by-path
, which should give you a readout something like:
S: disk/by-path/platform-20980000.usb-usb-0:1.3:1.0-scsi-0:0:0:0-part1
E: DEVLINKS=/dev/disk/by-id/usb-SanDisk_Cruzer_Switch_4C530001110415101044-0:0-part1 /dev/disk/by-label/BACKUP_1 /dev/disk/by-path/platform-20980000.usb-usb-0:1.3:1.0-scsi-0:0:0:0-part1 /dev/disk/by-uuid/5936-F7EA
It's the platform-20980000.usb-usb-0:1.3:1.0-scsi-0:0:0:0-part1
that we want. It might look fairly different depending on your device & hub. Copy it/note it down then open up fstab config sudo nano /etc/fstab
and on a new line:
/dev/disk/by-path/platform-20980000.usb-usb-0:1.4:1.0-scsi-0:0:0:0-part1 /media/card exfat auto,nofail,noatime,users,rw,uid=pi,gid=pi 0 0
replace /media/card
with the mountpoint you desire, and make sure the bit following /dev/disk/by-path/
matches what you copied earlier. The other options are variable depending on what you want.
Ctrl-X, Y, enter, to save fstab, then reboot and you should now have an auto-mounting usb port! You can repeat the previous steps for each port :)
udevadm info
to figure out attributes specific to each port of your hub, then writeudev
rules for them. You probably want to look forKERNELS
(notKERNEL
).udevadm info --name=/dev/sde
for example for a disc will provide aID_PATH_TAG
that should be a constant (egpci-0000_04_00_0-usb-0_2_1_1_1_0-scsi-0_0_0_0
) that you can match in an udev rule. You need to read up onudisks2
and be very specific about your OS and version (especially systemd or not).