Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I use Slackware with 2.4.x kernels on most of my machines for it's rock solid stability. I've run into a nuisance that I feel should be easy enough to solve, although I've googled and not found any solutions to the problem.
The Problem:
When I plug in my flash drive, the kernel assigns a node in /dev to interface with the drive as a scsi disk, let's say /dev/sda for example. At some later time, I plug in my digital camera, which is also a mass storage device. The kernel assigns the next sdx node, say /dev/sdb. After this, I plug in my SD card reader, which is assigned /dev/sdc.
This is all well and good. It's also nice that the kernel remembers which device goes with which node, because if I plug in my flash drive again, it's again given /dev/sda. The problem comes when I reboot my machine, or even just unload the usb-storage module and modprobe it in again. Instead of the flash drive continuing to be assigned /dev/sda, it's assigned a node in whatever order it was plugged in. In other words, if I take the steps in the paragraph above, then reload the usb-storage module and plug in my card reader, THAT is now /dev/sda.
I'd like to change this.
The Solution:
I worked up a hack to trick the machine into assigning the SAME node to each specific device every time it's plugged in. I even wrote a script and have things mostly working. I did run into a roadblock though.
/var/log/syslog is written to with information about the device when a drive is first plugged in, but not on subsequent plug-ins. /var/log/messages does not either. lsusb -v shows a ton of information about connected devices, some of which I plan on using. I have the bus ID and device ID of the mass storage device that was connected, but need some way of determining which /dev/sdx node was assigned to it.
Like I said above, I *know* the kernel remembers this information somehow, as the same /dev/sdx node is assigned to each specific device every time it's plugged in. I just need some way of finding out what node was assigned to a device at a given bus and device ID.
udev:
I know that many of you are going to say that udev has this capability and that I should just upgrade to a 2.6.x kernel. I do have my reasons for staying with 2.4.x though. First, I know from experience that udev does not detect RAID arrays automatically as 2.4.x does. (Took me several hours of swearing and finally manually creating /dev/md0 in rc.local using mknod to figure that one out!)
I've also read comments online from many people that indicate to me that udev is not as stable as it should be. I use linux because I hate having computer problems; if I want to run my machine for 6 months, then it should run for 6 months without a problem. My servers are even more critical - one of them goes down, our $20,000 security system could be rendered useless or many people would be unable to work until I get it fixed. Linux is wonderful for these applications and I don't want to risk instabilities by migrating to a new kernel prematurely. (I've yet to find any compelling reason to go to 2.6.x yet anyways.)
I also have some applications written in Kylix, which last time I checked, will only run on 2.4.x kernels.
Conclusion:
If anybody knows of a program I could call and pass the bus/device id of a usb device and have the specific /dev/sdx node that was allocated for it, I'd be grateful. The project isn't dead without it, but is going to take a LOT more work to find a roundabout way to determine this information.
I am planning on starting a SourceForge page for this once I get something functional, but have never done one before and don't want to post stuff for people to rip apart until I get something working.
BTW, I've poked around in the usb source files and found that the maintainer listed is Matthew Dharm. I tried e-mailing him, but the e-mail came back as undeliverable. I went to the domain listed and e-mailed the professor who had Matthew as a student, but he has lost touch with him since the site was updated and does not know how to get in contact with him.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.