udev: distinguish between USB floppy & memory stick
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
udev: distinguish between USB floppy & memory stick
Writing udev rules and need to distinguish between floppy devices and USB memory sticks ..
Sifting thru all the udevinfo stuff I see that sticks have SYSFS{dev}=="8:17" and floppys have "8:32" ..
As best I can find out from surfin the net those numbers are major/minor numbers I *think* ... but haven't found anything to explain what they mean in detail and if I can count on them for those specific devices on different h/w, etc...
When writing my rules I use SYSFS{Product}="Product Name". It's almost always the name that can be found in dmesg. My USB floppy drive's product is "MISTSUMI FLOPPY" and my flash drives are "JUMPDRIVE TRIO" and "SanDisk Cruzer Micro" et al. I also used the rules to create symlinks automatically for easier fstab entries and mounting.
Yep, I was going to use SYSFS{product} as well but then found different USB Keys report different stuff, and I was hoping (praying? ;-)) there was some value in all the udevinfo stuff that identified the type of device generically ..
I did since find some more details on major/minor and I don't think they can be used to identify the type of device, so I'm still kinda stuck ..
The major/minor numbers are completely arbitrary, but they should be the same across computers (or else /dev would have had serious problems way back when you had to manually create /dev files to add new hardware, it should be fine, but like i said, the numbers are arbitrary, you should really find another way if you can.
I also noticed that the USB floppy reports SYSFS{interface}=="FLOPPY" but the memory stick doesn't report that SYS{interface} at all. Is there any way to write rules to take advantage of that?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.