Basically my problem is that I am on a server which constantly switches around hdd’s. What I want to achieve is have having devices tied to the physical ports on the hardware.
/dev/sda is port 0
/dev/sdb is port 0 and so on.
I have been reading about udev rules and it always comes back to using serials and such. however since my hardware is constantly changing I can’t use that. I need to assign ports to device files.
Is such a thing possible?
I’ve done this for external hard drives. I got my info using
lsscsi, which will print something like the following:
[0:0:0:0] disk <descriptor> /dev/sda [1:0:0:0] disk <descriptor> /dev/sdb [2:0:0:0] cd/dvd <descriptor> /dev/sr0
Where 0,1,2 correspond to the port IDs. Then something similar to the following rule should do what you want:
SUBSYSTEM=="block", KERNEL=="sd*1", KERNELS=="1:0:0:0", SYMLINK+="<label_1>"
(Note I haven’t checked that this works for internal drives – my external ones needed ‘usb’ rather than ‘block’ as the subsystem type)