I have a small computer with 2 USB sockets : A and B.I want any external USB disk, attached to socket A - to be mounted as deviceAI want any external USB disk, attached to socket B - to be mounted as deviceBExpecially: Any amount of different disks may be attached to socket A. They all shall be mounted as devicesA. Because of this case I can not use UUIDs of disks and have to identify the sockets.I am using udev rules to automount the disks.How would I implement that?
How to auto-mount all USB-devices at same USB socket to same mountpoint
ubuntu;debian;usb drive;automounting
Take a look at the output of udevadm(8). For me the disk I used was /dev/sdd so I used:udevadm info --attribute-walk --name=/dev/sddThis gives me information about the device itself and the parent devices. One of the parent devices seemingly corresponds to the USB port it is connected to and varies depending on where I connected the disk. For me it is this entry which I'd use for mathing in the udev(7) rule:looking at parent device '/devices/pci0000:00/0000:00:12.2/usb1/1-4/1-4:1.0':  KERNELS==1-4:1.0  SUBSYSTEMS==usb  DRIVERS==usb-storage  [...]Note the name is KERNELS, SUBSYSTEMS and DRIVERS and not KERNEL, SUBSYSTEM and DRIVER here. According to the page at http://www.reactivated.net/writing_udev_rules.html and the man page for udev(7) these are matching not only the device itself (as the variants not ending in S do), but also the parent devices.Thus it should be possible to give USB storage on a given USB port a fixed name by using this data for matching in the udev rule. The actual mount can then also be done with a RUN inside an udev rule as far as I understand the man page for udev(7). It might be necessary to use a separate rule for the mount, though.