-   Linux - Hardware (
-   -   Mount hardware to specific location with specified device (

blixel 10-20-2003 02:18 PM

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

Mara 10-20-2003 02:42 PM

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?

blixel 10-20-2003 02:57 PM

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

Mara 10-20-2003 03:53 PM

Yes, something like this, but I think it's better to symlink, not remount.

blixel 10-20-2003 05:03 PM

<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?

Mara 10-21-2003 04:21 PM

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
'iPod' disk is mounted (/dev/hda->/mnt/disk1). It gets symlinked to /mnt/ipod
You add second disk(/dev/hdb->/mnt/disk2). It gets symlinked to /mnt/ext_hdd
Both disks are removed. Symlinks stay as they were (and now point empty directories)
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.

All times are GMT -5. The time now is 08:46 PM.