LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 08-15-2012, 03:50 AM   #1
j_h
LQ Newbie
 
Registered: Oct 2011
Posts: 26

Rep: Reputation: Disabled
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!
 
Old 08-15-2012, 05:49 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,797

Rep: Reputation: 282Reputation: 282Reputation: 282
You can use labels in fstab; never tried it though.
 
Old 08-15-2012, 06:00 AM   #3
j_h
LQ Newbie
 
Registered: Oct 2011
Posts: 26

Original Poster
Rep: Reputation: Disabled
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.
 
Old 08-15-2012, 06:05 AM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
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.
 
Old 08-15-2012, 07:01 AM   #5
j_h
LQ Newbie
 
Registered: Oct 2011
Posts: 26

Original Poster
Rep: Reputation: Disabled
Hmm, that's a shame. Thanks for your help, anyway.

Last edited by j_h; 08-15-2012 at 07:40 AM.
 
Old 08-15-2012, 07:40 AM   #6
j_h
LQ Newbie
 
Registered: Oct 2011
Posts: 26

Original Poster
Rep: Reputation: Disabled
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.
 
Old 08-15-2012, 08:34 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.
Old 08-15-2012, 08:47 AM   #8
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,325

Rep: Reputation: 919Reputation: 919Reputation: 919Reputation: 919Reputation: 919Reputation: 919Reputation: 919Reputation: 919
i think this is what uuid was created for ?
 
Old 08-15-2012, 09:03 AM   #9
j_h
LQ Newbie
 
Registered: Oct 2011
Posts: 26

Original Poster
Rep: Reputation: Disabled
Ha, wonderful! ID_PATH seems to be exactly what I need. Many thanks
 
Old 08-16-2012, 04:32 AM   #10
j_h
LQ Newbie
 
Registered: Oct 2011
Posts: 26

Original Poster
Rep: Reputation: Disabled
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.
Old 08-16-2012, 05:23 AM   #11
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
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.
 
  


Reply

Tags
fstab, mounting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mount points disappear and reappear under /media for USB drives alamode Linux - Server 2 06-11-2012 02:47 PM
Create mount points automatically for removable drives? Mig21 Slackware 2 01-10-2010 05:39 PM
Question on External Drive Mount Points ervt Linux - General 1 04-15-2008 06:03 PM
External HDD, mount points and permissions Niteskye Fedora 2 05-13-2006 04:42 PM
don't want mount points for some drives! garyd9 Mandriva 1 03-25-2004 12:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration