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 have inherited a large number of external drives. Some are mechanical drives. Others are flash. Most are USB. Some are Secure Digital (SD) or Compact Flash (CF) or similar "media" cards. Currently, on connection, everything gets mounted automatically into a folder that is part of /media. If the drive has a "label", the mount point is /media/driveLabel. I don't want to guess or search for where this stuff gets mounted and so I'd like to "manage" all of this somehow. Q1: Are there any end-user, desktop tools to help manage a large pool of external drives?
I know that udev rules operate to accomplish the drive device creation, configuration and mounting in a automatic way. Q2: Are there any utilities that make it easy to administer where to mount drives, what to do when each drive gets mounted, how and when to notify the end user? and so on.
What's to guess? As you said, your automounter mounts all drives to /media/driveLabel. How would you like it to behave instead?
udev rules in cases like this are usually designed to create uniquely-named symlinks to the device nodes in question. You choose some characteristic about the device for the rule to match, and whenever it detects that device, it will create the corresponding link for it. Then you can use these unvarying symlinks to mount the device instead of the normal, possibly-changing /dev entries.
Note though that this is separate from the behavior of your automounter, as described above, which only runs after the udev-created devices are in place. It is possible to use udev to launch some kind of automount script as well, but it's not generally recommended.
Again, I think you really need to detail exactly what kind of mount system you actually want for these devices before we can recommend a solution.
What's to guess? As you said, your automounter mounts all drives to /media/driveLabel. How would you like it to behave instead?
That's a fine choice when one knows the label. Given the OP's situation, I'm guessing he doesn't know the labels. He probably doesn't even know the UUIDs.
Quote:
Originally Posted by David the H.
udev rules in cases like this are usually designed to create uniquely-named symlinks to the device nodes in question. You choose some characteristic about the device for the rule to match, and whenever it detects that device, it will create the corresponding link for it. Then you can use these unvarying symlinks to mount the device instead of the normal, possibly-changing /dev entries.
Note though that this is separate from the behavior of your automounter, as described above, which only runs after the udev-created devices are in place. It is possible to use udev to launch some kind of automount script as well, but it's not generally recommended.
Again, I think you really need to detail exactly what kind of mount system you actually want for these devices before we can recommend a solution.
I'm guessing at what the OP might want, but I know it is exactly what I would want in his situation ... and I've been in a similar one a few times. To me, the ideal is to have a fixed identity for every point a drive could be plugged in to, and have the drive show up via that identity (in addition to any other). Trouble is, various technologies like USB have really made a mess of any kind of fixed identity. IMHO, it's a bad design because of that alone.
If I have a device with whole device label of "foobar", and a whole device UUID of "382f6ad2-426d-4f6e-ac6f-338a6a140d73", and I plug it into the port connected to bus 1, controller 2, port 0, hub port 3 ... which has partition 1 with a label of "xyzzy" and a UUID of "21da59e5-62c4-4ded-92ac-47a723743db3", then I'd like it to appear in some definite place based on any of those pieces of info, including the partition being based on its own info, as well as the info of the whole device plus the partition number and label.
But for now, if there is just one hard drive /dev/sda, plugging in a 2nd one always getting /dev/sdb would be fine. And automounting should have an equally fixed reference, e.g. /mnt/sdb1 for partition 1.
If there was a way to determine exactly where in the USB bus tree a device is plugged in to, which never changes when the device is unplugged and another device is plugged in to the same place (so it now references the new device), which I have not see how to get (what info I do get is an incrementing number that keeps going up every time I unplug and plug in), then I'd want a to have that reference used (in addition to being based on labels and UUIDs since those have uses, too).
There are plenty of times I simply want to access the device plugged into a specific USB port when all I know is what USB port it is (presume I have once found out the exact bus path to that port and remember the numbers).
...
There are plenty of times I simply want to access the device plugged into a specific USB port when all I know is what USB port it is (presume I have once found out the exact bus path to that port and remember the numbers).
...
Over here is this whirling state of physical hardware. When some item comes online, I always want to assign the name, "Framis" or "Foobar" or "Tom" or ... ( I could do this with Vax/Vms in a prior life ).
If there are several devices in the same family as "Framis" then I'd like consistent names for the whatever I connect regardless of which orifice I choose to use.
Also, I don't understand why USB remains such a mess. At the low levels ports and hubs and adapters will always be a mesh of parts. At the upper levels, all of that mesh should vanish under a single, unified "device" -- say /dev/usbA01...usbCNN or similar. ** MY ** configuration ought to let me map from the physical to the logical in a deterministic way.
~~~ 0;-Dan
Now software can always look for "Framis", test if it is available and readable etc and do whatever I want to happen with every such "Framis."
I think you're both still missing that there are two separate systems involved here; udev, which creates the device nodes, and your mounting system, which creates the actual mount points from those nodes.
Not that I'm an expert on udev, but it seems to me that the default udev rules for usb are fairly reasonable and do pretty much what you'd expect them to do, and basically what you've both described. It generally appears to simply increment the device letter for each new device detected. The only thing I can criticize about that is that it sometimes doesn't seem to "clear" removed devices so that the letters can be reused, meaning that the letter will keep incrementing on multiple insertions and removals. Perhaps there are also be some factors based on how different buses are detected, but in the end the generic rules are limited to what the kernel is reporting about the hardware. I'm not going to claim to know how it works in detail
However, as I explained before, you can also create your own udev rules so that you can have fixed device symlinks for specific hardware devices. These rules can match, or partially match, just about anything the /sys device tree reports, and yes, this can include things like the physical bus address of each usb port, or the device labels, manufacturer name, serial number, or whatever. You can even use external programs or scripts to generate the device names you want it to create. If you want all usb block devices to have entries like /dev/usb01, /dev/usb02, etc. then you can, or you can have /dev/usbport01, /dev/usbport02, etc instead, or as well. In the end it all comes down to how you choose and use the matching rules. It's a very powerful and flexible system, and I'm willing to bet that both of you can build exactly the kind of device tree you want if you just take the time to figure it out. I've already linked you to the howto (but note that most of the commands like udevinfo have changed to udevadm info, etc.).
The second part, the mounting system, is harder to help with, because each distribution and desktop does things a little differently. The only thing I can suggest is that you take a look at your distribution's automount documentation. Chances are that once you have decent udev rules in place, you can also design a mount configuration to take you the rest of the way.
This is all assuming removable media of course. Fixed devices should almost always use fstab, preferably mounted according to UUID if you want to avoid possible conflicts or changes in hardware configuration.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.