Linux - General This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
08-15-2012, 03:50 AM
|
#1
|
LQ Newbie
Registered: Oct 2011
Posts: 26
Rep:
|
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!
|
|
|
08-15-2012, 05:49 AM
|
#2
|
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,797
|
You can use labels in fstab; never tried it though.
|
|
|
08-15-2012, 06:00 AM
|
#3
|
LQ Newbie
Registered: Oct 2011
Posts: 26
Original Poster
Rep:
|
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:
Last edited by j_h; 08-15-2012 at 06:04 AM.
|
|
|
08-15-2012, 06:05 AM
|
#4
|
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
|
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.
|
|
|
08-15-2012, 07:01 AM
|
#5
|
LQ Newbie
Registered: Oct 2011
Posts: 26
Original Poster
Rep:
|
Hmm, that's a shame. Thanks for your help, anyway.
Last edited by j_h; 08-15-2012 at 07:40 AM.
|
|
|
08-15-2012, 07:40 AM
|
#6
|
LQ Newbie
Registered: Oct 2011
Posts: 26
Original Poster
Rep:
|
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?
Last edited by j_h; 08-15-2012 at 07:42 AM.
|
|
|
08-15-2012, 08:34 AM
|
#7
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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",
RUN+="/bin/mount /dev/%k /media/removable || /bin/mount /dev/%k /media/removable2"
If you can pass ID_PATH to a script, the script can use variable expansion to add a "1" or "2" to the mountpoint variable.
Have separate rules depending on the ID_PATH value.
Last edited by jschiwal; 08-15-2012 at 08:52 AM.
|
|
1 members found this post helpful.
|
08-15-2012, 08:47 AM
|
#8
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,325
|
i think this is what uuid was created for ?
|
|
|
08-15-2012, 09:03 AM
|
#9
|
LQ Newbie
Registered: Oct 2011
Posts: 26
Original Poster
Rep:
|
Ha, wonderful! ID_PATH seems to be exactly what I need. Many thanks
|
|
|
08-16-2012, 04:32 AM
|
#10
|
LQ Newbie
Registered: Oct 2011
Posts: 26
Original Poster
Rep:
|
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>"
SUBSYSTEM=="block", KERNEL=="sd*1", KERNELS=="2:0:0:0", SYMLINK+="<label_2>"
and then modify the entries in my fstab to
Code:
/dev/<label_1> /mnt/<mountpoint_1> <attributes>
/dev/<label_2> /mnt/<mountpoint_2> <attributes>
Thanks to jschiwal for the helpful pointer.
Last edited by j_h; 08-16-2012 at 04:37 AM.
|
|
1 members found this post helpful.
|
08-16-2012, 05:23 AM
|
#11
|
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
|
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 03:58 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|