LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 10-20-2003, 02:18 PM   #1
blixel
LQ Newbie
 
Registered: Sep 2003
Posts: 22

Rep: Reputation: 15
Mount hardware to specific location with specified device


My subject probably doesn't make any sense but I wasn't sure how to word it.

I have 2 external USB 2.0 / Firewire hard-drives and an iPod. I only turn them on when I need them. The problem I'm running into is that whichever is the first device to be turned on gets assigned to /dev/sda. The next device gets /dev/sdb and so on.

I need to assign each piece of hardware it's own device so that my programs know where to find the correct hardware. For example, when I turn on my iPod I want it to get /dev/sdc even if I don't have my hard-drives on. And if I turn on my "2nd" hard-drive first, I want it to get /dev/sdb instead of /dev/sda

Is this possible?

As it stands right now, every time I turn on one of my devices I have to manually shuffle around the mount locations because /etc/fstab will mount /dev/sda to /mnt/ext_hdd regardless of which device it is. And if it happens to be my iPod, then when I start GTKPod, it can't find any of my music because it's looking in /mnt/ipod
 
Old 10-20-2003, 02:42 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,535

Rep: Reputation: 148Reputation: 148
Without some extra, quite advanced modification, I think it's not possible.

An idea of work-around: a script started after the drives are mounted, checking the contents of all directories drives are mounted to (they need to be easily identificated, maybe a file with it's name on every disk or something similar). Then, the drives are symlinked into their places (specified in the script or as script parameters). Would something like this do?
 
Old 10-20-2003, 02:57 PM   #3
blixel
LQ Newbie
 
Registered: Sep 2003
Posts: 22

Original Poster
Rep: Reputation: 15
I understand what you're getting at... that would probably work but I was hoping for a more elegant solution. But if all else fails though I might go with that idea.

have the devices automount to /mnt/check_mount

Then something like this

if [ -d /mnt/check_mount/iPod_Control ] ; then
umount /mnt/check_mount && mount /dev/sda2 /mnt/ipod ;
elif [ -f /mnt/check_mount/FileCheck_1st_exthdd ] ; then
umount /mnt/check_mount && mount /dev/sda1 /mnt/ext_hdd ;
elif [ -f /mnt/check_mount/FileCheck_2nd_exthdd ] ; then
umount /mnt/check_mount && mount /dev/sda1 /mnt/ext_hdd2 ;
fi ;

Would have to make adjustments so it would work with /dev/sdb and /dev/sdc
 
Old 10-20-2003, 03:53 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,535

Rep: Reputation: 148Reputation: 148
Yes, something like this, but I think it's better to symlink, not remount.
 
Old 10-20-2003, 05:03 PM   #5
blixel
LQ Newbie
 
Registered: Sep 2003
Posts: 22

Original Poster
Rep: Reputation: 15
<i>Yes, something like this, but I think it's better to symlink, not remount.</I>

Hmm... if you symlink and then wanted to turn on another device, I would think that would cause a conflict. You would be symlinking /mnt/ipod to the newly mounted external hard-drive. Then you would have two symlinks pointing to the same data ... kinda defeats the point. Unless I'm misunderstanding something?
 
Old 10-21-2003, 04:21 PM   #6
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,535

Rep: Reputation: 148Reputation: 148
Hmm...There's nothing bad in two symlinks to the same data. It may cause problems from time to time, yes, but noting serious. Example
Moment1:
'iPod' disk is mounted (/dev/hda->/mnt/disk1). It gets symlinked to /mnt/ipod
Moment2:
You add second disk(/dev/hdb->/mnt/disk2). It gets symlinked to /mnt/ext_hdd
Moment3:
Both disks are removed. Symlinks stay as they were (and now point empty directories)
Moment4:
Second disk added (/dev/hda->/mnt/disk2). The symlink's changed (/mnt/ext_hdd->/mnt/disk1), /mnt/ipod still points to /mnt/disk1 (not dangerous, will be chenged as soon as you add the drive).

The script may be more complicated and try all symlinks when mounting a new drive, for example.

Remounting is also a good idea. Both will work. I just personally prefer symlinking
If you find remounting easier, do it.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
HowTo add specific location into sources.list? Mathsniper Debian 1 08-28-2005 04:21 AM
hardware specific distros phil29 General 0 08-06-2005 11:37 AM
Which linux to get for specific hardware ThorsHammer Linux - Software 8 01-28-2004 06:17 PM
Mounting specific hardware devices to specfic mount points tallguy999 Linux - Newbie 3 11-27-2003 02:07 PM
/dev location or name of USB device dark_forests Linux - Hardware 3 10-12-2003 11:37 PM


All times are GMT -5. The time now is 09:14 AM.

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