0

This is going to sound sorta vague, but I have an ANKER USB 3.0 hub. I want to be able to connect multiple USB disks to here, however I want the Linux system to be able to assign the device name (i.e. /dev/sdX) based on the USB port that the device is connected to on the hub. I have 9 data enabled ports, so port 1 would get /dev/sdb, port 2 would get /dev/sdc, etc. I have no other disks on this computer, so I don't see a need to worry about device name collisions, but I would like to make such a binding happen.

Is this at all possible, and if it is, how would I structure a set of udev rules to do this? Using Ubuntu 16.04, but would like it to work in modern Debian (stable or later) as well.

  • 1
    Does it have to be /dev/sdX? Would /dev/disk/by-path do what you want? – icarus Jan 15 '17 at 18:20
  • @icarus If we could define what by-path would be, so that each is unique per USB port, then that'd work. – Thomas Ward Jan 15 '17 at 18:24
  • 1
    by-path is a directory, which contains filenames like pci-0000:00:12.2-usb-0:2:1.0-scsi-0:0:0:0 which tell you the motherboard location, and then the usb location. – icarus Jan 15 '17 at 18:29
  • 2
    And in case it's unclear, by-path is already automatically populated with symlinks by standard udev rules. No need to write new ones for that. – dirkt Jan 15 '17 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.