LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 07-19-2010, 03:14 AM   #1
smallbook
Member
 
Registered: Jan 2008
Posts: 40

Rep: Reputation: 15
Auto mount USB drive to specified mount point after reboot


Hi all,

I have servers installed with RHEL 4 2.6.9-89.0.9 ELsmp. I tried using uuid and label in /etc/fstab to automount usb drives to mountpoints that I specify after reboot. Unfortunately, it just does not work in all my RHEL4 servers. After every reboot, /etc/fstab will be automatically modified and all configurations related to my USB drives will be changed. Irregardless of whether i use UUID or LABEL in my /etc/fstab.

However, it works on RHEL5. But, upgrading is not an option in my environment. I have been googling around looking for alternatives but everything seems to point back to using UUID or LABEL in /etc/fstab.

Anyone has tried something that works? Please help me, thank you.
 
Old 07-19-2010, 02:37 PM   #2
timsgreen
LQ Newbie
 
Registered: Mar 2006
Posts: 14

Rep: Reputation: 2
I encourage you to take a look at UDEV to solve your problem.

Take a look at this link:

http://ubuntuforums.org/showthread.php?t=168221

While the article is intended for Ubuntu users, it shouldn't be too much trouble to adapt the procedure to a RHEL system. For one, leave out all the 'sudo' prefixes to commands if you're already root (but I didn't have to tell you that).

Hope this helps,

-Tim

Last edited by timsgreen; 07-19-2010 at 02:38 PM.
 
Old 07-19-2010, 02:43 PM   #3
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
Further to what Tim wrote, if you do end up needing UDEV rules for this to work right, there are several excellent articles around the net; just Google for "Writing UDEV Rules" and you will find them. The trick is, UDEV is something of a moving target, and has had MANY release versions over the years; with every so many release versions, the syntax of the rules has changed a lot over time, so one tutorial may not apply as well to your version of udev as another tutorial (and your version is bound to be rather old on RHEL4) - so reference & compare syntax in several tutorials if you are getting errors from udev about your rules.
 
Old 07-20-2010, 01:32 AM   #4
smallbook
Member
 
Registered: Jan 2008
Posts: 40

Original Poster
Rep: Reputation: 15
Hi there guys/gals,

Thank you so much for your prompt response. If I write UDEV rules, and I plug out those USB drives, will it cause any error upon reboot? I don't want the hal daemon to keep on looping to look for the drive and causes an infinite loop. The USB drives will be left in the server for a few months and after that we might change to a different USB drives hence we need flexibility but also some fixed configurations.
 
Old 07-20-2010, 04:41 AM   #5
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
The UDEV rules which will apply for the USB drives will simply not have any effect if the drive is not present in the machine upon power-up, and will effectively be skipped. So, neither HAL nor UDEV should get stuck in a loop looking for a device that is not present. As long as the drive *is* present, the rules will have their effect during power-up.

If you write a rule to apply specifically to a particular device (based on device serial # and/or some other unique characteristics) then the rule will apply only to that very device (fixed configuration - this is what I use for my USB sticks); but if you write a rule(s) which can apply to more than one particular device, then whatever device gets inserted, the rule will act upon (somewhat flexible configuration) - however, I'm not sure what might happen if you have one device already plugged in & mounted, and then you plug in a second device which the UDEV rule says to mount at the same location. Either a passive error from UDEV or from the kernel, or maybe the drive will get auto-mounted somewhere that you didn't expect it to.

My choice would be to write an individual rule for each of any drive(s) you currently use, and when you get some new drives, add some new rules for them at that time. Writing multiple rules is simple once you get the first one working - then it's just a copy & paste and a little editing of the serial # or whatever unique identifier(s) you have chosen.

If you search LQ a little for threads about UDEV and USB sticks, you will find several that describe your situation here, at least one of which were posted by me, describing how I created the rules for my USB sticks. If you want them and can't find them, I'll find the threads for you and provide links.

Good luck
 
Old 07-20-2010, 08:36 PM   #6
smallbook
Member
 
Registered: Jan 2008
Posts: 40

Original Poster
Rep: Reputation: 15
Hi GrapeFruitGirl

Thanks a lot! I tried a few rules yesterday and I think there is some sort of syntax error. I got rather confused with the == or the = used. Some examples I read use == whereas some use =. If you can enlighten me on that, it'd be great. As a result of this syntax error, when I plugged in new disks, it couldn't be detected! I had a shock of my life time haha. It only worked when I deleted the faulty rules created by me.
The thread that you previously talked abou this would be of great help to me, if you can locate and send me the link.

Thanks once again!
 
Old 07-20-2010, 11:34 PM   #7
smallbook
Member
 
Registered: Jan 2008
Posts: 40

Original Poster
Rep: Reputation: 15
Hi there,

Some updates to share. I finally got the syntax correct. The syntax really differs from OS to OS i assume. However, after managing to create those fixed names for each device, the fstab still changes my entries after reboot. For example,

/dev/cg2 /mnt/cg2 ext3 ....

is changed to

/dev/cg2 /media/cg2 ext3 ....

How do i stop fstab from changing my entries? I still end up having to mount those devices by myself. At least the good news is, I somehow have a simple name to refer to so that I know which device contains what information.

Your help is highly appreciated. Thank you.
 
Old 07-21-2010, 04:40 AM   #8
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
Hi,

Yes, because of all the different versions of UDEV out there over the years, various OS's all have different versions installed, so as mentioned, small changes to the rules' syntax over time means that rules from one machine won't necessarily work perfectly on another machine without some tuning. The UDEV administrative tools & commands have also changed.

As to why your fstab file is being changed upon reboot, I have no clue. I hope that either another user of RHEL4 can offer something on that subject, or that you can find the reason for this either in the RHEL documentation or perhaps on the RH website(s). I'm confident that the answer is out there -- Google might be your best friend.

Here are a couple threads where other members and I talked about udev rules for USB hard-disks, card-readers and usb sticks (which are all the same idea - SCSI disks), and where I have posted examples of my udev rules for some of those devices, and how I got the information I needed to create the rules. Again, keep in mind that your UDEV version is probably different from any I may have been using at that time, so the exact commands & syntax you end up using might be slightly different from those I've shown. Other members have commented in those threads about, for example, using the command udevadm instead of udevinfo, depending on the UDEV or OS version. Anyhow, here's some links - I hope this helps you in some way:

http://www.linuxquestions.org/questi...rd-%7D-756634/

http://www.linuxquestions.org/questi...drives-735069/
 
  


Reply


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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
udev rules to mount external hard drive at mount point akamikeym Gentoo 3 03-31-2010 01:12 PM
Trying to use udev to auto mount usb drive njnear Linux - General 5 12-04-2007 01:53 AM
Static mount point for USB drive vm_devadas Linux - Server 1 05-16-2007 09:43 AM
Set up rsync to mirror mount on Windows Server to mount point on 2nd internal drive MoMule Linux - Server 4 04-13-2007 09:34 PM
auto mount usb drive jag Slackware 3 07-28-2006 03:09 AM


All times are GMT -5. The time now is 10:39 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration