LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   mounting 2 usb drives in to 2 different locations in linux (https://www.linuxquestions.org/questions/linux-newbie-8/mounting-2-usb-drives-in-to-2-different-locations-in-linux-871293/)

gosala 03-27-2011 11:35 AM

mounting 2 usb drives in to 2 different locations in linux
 
Hi,
here is my situation, I am writing a c program in linux and in the program I am mounting 2 usb devices attached to 2 specific ports in the computer. (eg : I have to mount the usb attached to the left port in to /mnt/left and the right port to /mnt/right) and the attachment order of those devices may differ (eg: left port usb may or may not be attached before the right.) In this case what should i do?

bigrigdriver 03-27-2011 01:19 PM

The first part of the solution to your problem involves writing custom udev rules for each usb device. Each device has a unique ID. Once the rule is written to mount a specific device to a specific mount point (/mnt/left or /mnt/right), you can then add an entry to your /etc/fstab for the devices.

The second part of the solution involves determining the unique usb port identifiers. I haven't the foggiest idea how to do that. If you can figure it out, the solution *may* involve the udev rules mentioned above.

www.google.com/linux is your friend. Use it to research Unix/Linux related questions.

Good luck!

PS. Please pardon my manners. Welcome to LQ. This is a great forum for learning (just by reading threads posted by others), and for getting answers to your questions. But please use the link given above first. Most questions you may have are probably already answered on the web.

business_kid 03-27-2011 01:31 PM

If I were you, I would back away from that idea.

There's already a software layer (hal, dbus) that gets involved there, and I wouldn't advise fighting it. So you have to learn it:-(. There's also usb standards, (On intel's site) and kernel code - enough pain in the way to make that a real messy thing to do.

Put the disks in /etc/fstab, and the system will mount them for you

/dev/sdb1 /mnt/hd auto user 0 0

Mind you, it complains while booting if the disk isn't there.

gosala 03-27-2011 09:20 PM

thankx a lot for your concern business_kid and bigrigdriver,

well I went through fstab file's description. But apparently still I cannot distinguish left port and a write port in the system(It says how to mount /dev/hdb or /dev/hdc to a particular location.) How can I know for sure that left port is always /dev/hdb ? Because as I know if I attach a usb device to the left port before the right port usb ,the scsi ids assigned to each port may differ from the assigned scsi ids, when right port usb attach before the left port usb.

what I want is whether I attach left port first or right port first, the left port's usb must be mounted in to /mnt/left and right port's usb in to /mnt/right. what I should do? Is it something to do with port identifiers as bigrigdriver says ?

thnk you all.

gosala 03-28-2011 02:07 AM

Hi ,

I think I found the answer. It has to be done using 'udev' rules.
thank you for your interest.


All times are GMT -5. The time now is 03:59 PM.