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.
Relevant info: -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 in advance for any ideas! |
You can use labels in fstab; never tried it though.
|
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. |
Hmm, that's a shame. Thanks for your help, anyway.
|
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?
|
I don't see why the mount command the udev rule runs couldn't be "mount <mountpoint1> || mount <mountpoint2>". I haven't tried this however.
Code:
SUBSYSTEMS=="scsi", KERNEL=="sd[a-h]1", Have separate rules depending on the ID_PATH value. |
i think this is what uuid was created for ?
|
Ha, wonderful! ID_PATH seems to be exactly what I need. Many thanks
|
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: Code:
SUBSYSTEM=="block", KERNEL=="sd*1", KERNELS=="1:0:0:0", SYMLINK+="<label_1>" Code:
/dev/<label_1> /mnt/<mountpoint_1> <attributes> |
Thanks for posting back your solution. If you feel that you have solved your problem please mark this thread as solved using the thread tools at the top of the thread.
|
All times are GMT -5. The time now is 09:40 PM. |