I have a USB hub connected to my laptop, always through the same port - my question is how can I make my linux installation always mount whatever is plugged into one of the specific ports on this hub be mounted to (e.g) /mount/left and likewise for the other port.

I know how I can do this for specific drives with the UUID of the drive, but I want it to be that case that /mount/left always refer to whatever is in the left port, whichever order different USB devices are plugged in.

  • I am doubting, whether this is possible. I do not think you can reliably infer port number from device number on an external USB-Hub after a few device (re-)connections leading to renumbering. Favorited. Jun 26, 2016 at 15:45
  • You can do it with udev, but you'll have to fight your way to it. You'll need to run udevadm info to figure out attributes specific to each port of your hub, then write udev rules for them. You probably want to look for KERNELS (not KERNEL). Jun 26, 2016 at 18:30
  • How would I go about doing this? Just to clarify, this would be a permanently connected USB hub - I only use a hub because if I'm going to break USB ports by plugging things in and out over and over, I'd rather break the USB ports on a hub I can replace than on my laptop itself
    – Sleumas
    Jun 26, 2016 at 18:50
  • 2
    udevadm info --name=/dev/sde for example for a disc will provide a ID_PATH_TAG that should be a constant (eg pci-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 on udisks2 and be very specific about your OS and version (especially systemd or not).
    – meuh
    Jun 26, 2016 at 19:23

1 Answer 1


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 :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .