[SOLVED] Reliably mount different external drives to the same points?
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.
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.
Reliably mount different external drives to the same points?
I'm maintaining a system which utilises external drives. Previously the system has been set up to mount these using device names (/dev/sdxY) in fstab. This appeared to work fine for a while, but today I saw it detect an external drive as /dev/sdaY, which messed everything up.
-various scripts expect the two drives to be at specific mount points
-the drives are all the same make and filesystem type, though a few different sizes
-up to two drives can be connected at any one time, so I don't believe I can add a single udev rule to always mount drives of this type to a particular point
-there is a large pool of drives and more may be purchased at any time, so I can't know all the UUIDs to add a rule for each drive
How can I guarantee that any one of these drives will always get mounted to one of the two mount points I specify?
Thanks for your response, but as mentioned in the OP, there's a large pool of possible drives and new ones are added ad-hoc (without going through me), so I wouldn't be able to set the label manually for every drive. Unless there's a way to programatically do it? Also, can you set labels on NTFS drives?
I'd still need to solve the problem of mounting two distinct drives of the same fstype to separate mount points anyway.
I think what I really need is a way to set udev rules that copes with two 'identical' drives, without relying on me knowing the serial numbers. Does such a thing exist? S:
That is impossible, as far as I see. The udev rule can't know the serial numbers (or whatever else is used to recognize the disks), so it can't reliably mount unknown devices to one specific mountpoint when several possibilities for that exist.
The only solution I see is to change your workflow, so that new drives have to be approved by you so that you can change the udev rules accordingly.
Had another thought: while the drives are interchangeable, they will always be plugged into the same two ports. 'lsscsi' gives me 1:0:0:0 and 2:0:0:0 as the (addresses?) for the two drives. Is there any way I can use this information to specify that anything connected to the first port gets mounted to one point, and anything connected to the second gets mounted to another?
Just to follow up on this in case anyone else comes across a similar issue (for instance, this would allow replacing external devices attached to a particular port and get it to mount to the same place as the old one without needing to update udev):
udev rule with ID_PATH in didn't seem to work (when I ran udevadm info -a -p /path, ID_PATH was not in the list of attributes), but the suggestion put me on the right path (no pun intended). Using the info from the 'looking at parent device' section, I managed to get the following rule to work: