View Full Version : Automount USB Drive using Volume Name as Mount Point
mrsbonus1
2007-01-23, 09:07 PM CST
I have a couple of external USB hard drives with NTFS partitions each with different volume names eg HDD1 and HDD2
If I connect these one at a time they both come up as /dev/sde and I have an autofs entry like
usb -fstype=ntfs-3g :/dev/sde1
This mounts one drive as /misc/usb
This works fine except it would be ideal if each drive actually mounted as
/misc/HDD1 and /misc/HDD2 so that scripts can more easily differentiate the disks
If I log in using Gnome then this seems to have no problem mounting each drive and placing an icon on the desktop using the volume label. However, I almost never use Gnome and the machine in question is a server.
So in summary I would like to be able to plug in a USB Drive with an NTFS partition (ntfs-3g) and have it automatically mount to /mountpoint/volumename without having Gnome running.
mrsbonus1
2007-01-23, 09:09 PM CST
Forgot to include the fact that I am running FC6 with all latest updates as of mid-Jan 2007
mdulzo
2007-01-23, 09:57 PM CST
This may be an option.
If these usb drives are continuously plugged in to the server (at least I assume that they must be, at the very least I believe that they must be plugged in to the same usb port) You can try and edit your fstab file so they are mounted on boot up.
1. Create mountpoint directories at /mountpoint/volumename by using "mkdir /mountpoint/volumename" with the respective names inserted appropriately.
2. open /etc/fstab in your favorite text editor as the root user.
3. Add the following lines to you fstab file:
/dev/sdeX /mountpoint/volumename ntfs-3g silent,umask=0002,utf8=true
/dev/sdeX /mountpoint/volumename ntfs-3g silent,umask=0002,utf8=true
Where X is the correct sde number and mountpoint/volumename are the same as the directory you created above.
Granted, this might not work based on your needs and if linux will assign different sde numbers to the usb ports on startup. But it may be worth a shot.
mrsbonus1
2007-01-23, 10:04 PM CST
I believe I need some form of HAL or Hotplug solution.
An fstab of autofs solution is not really going to work nicely.
The USB drives can be plugged in at anytime, together (the devices become /dev/sde and /dev/sdf) or separately (only /dev/sde is used). The only distinguishing feature is then the volume name.
gabbe
2007-02-21, 03:25 PM CST
Maybe you already solved it. I had the same problem as you and was also thinking along HAL or hotplug. There is a much simpler solution:
Look in /dev/disk/by-id/ where you should find the devices listed by there internal id. In my case it looks like this:
usb-WD_3200JB_External_57442D5743414D5231383734323636 -> ../../sdc
usb-WD_3200JB_External_57442D5743414D5231383734323636-part1 -> ../../sdc1
usb-WD_3200JB_External_57442D5743414D5234313532303133 -> ../../sdd
usb-WD_3200JB_External_57442D5743414D5234313532303133-part1 -> ../../sdd1
So now i can
mount /dev/disk/by-id/usb-WD_3200JB_External_57442D5743414D5231383734323636-part1 /mnt/HDD1
and
mount /dev/disk/by-id/usb-WD_3200JB_External_57442D5743414D5234313532303133-part1 /mnt/HDD2
and be sure they never get mixed up. At least in theory :rolleyes:
vBulletin® v3.8.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.