automount USB external drive

I have an external USB had drive. It is a Buffalo drive. When ti is mounted it appears in /Media/Buffalo

The problem is, every time I reboot my system it is mounted to a different location.
e.g. /Media/Buffalo_1
reboot again and it is mounted to /Media/Buffalo_2

the two previous mount points always remain present as empty directories.

This is creating problems I need to do away with. I need to work out how to get this to mount to the same directory every time.

In opensuse 11.2 with the automount option installed I did not have this problem. It has only appeared since the install of 11.3

If the disk is allway connected to the computer adding an entry to the fstab may be a solution. IF you want to proceed like this The best way to do so would be to use the disk ID (ls /dev/disk/by-id/usb).

Before the automount option was available that is what I used to do. However, it is troublesome because, while the external drive is usually connected, it is sometimes removed and not connected at all.
I would prefer to find a solution using the automounter as it should work seamlessly as it did in 11.2

May be labeling the drive will solve the problem

first ensure that the drive is unmounted
Know it’s access link (/dev/sdxx) or drive ID

first well check if there a label for the drive.
If the drive as no label the result will be something like Volume has no label
Elseway the actual label will be chow.
If the disk as already a label, labelling will not solve the problem. Esle it may solve it.

The labeling method depend on the File system.

As root (or via sudo)

For fat
check the curent label if any

mlabel -i /dev/sdxx -s ::

adding new label

mlabel -i /dev/sdcc ::new_label

Note that space is no supported for label name so avoid it.

mlabel is provide by the mtools package

For ext2/ext3/ext4

checking label

e2label /dev/sdxx

adding new label

e2label /dev/sdxx new_label

Note that space is no supported for label name so avoid it.

e2label is provide by the e2fsprogs package

For NTFS

checking label

ntfslabel /dev/sdxx

adding new label

ntfslabel /dev/sdxx new_label

Note that space is no supported for label name so avoid it and max 128 character

it’s an ext4 drive already labelled as BUFFALO

I tried relabelling it using your method to BUFFALO_USB but the same symptoms persist.

i’ve had this same problem, it seems to stem from using either amule or ktorrent, i forget which, when i would reboot the machine and one of those programs were running on the restart they would recreate the mountpoint with the -1 designation.

solution, before you reboot shut these programs down, then do the reboot.

No, I don’t have these programs running or anything that would be accessing the disk at the time of closing or rebooting.

it seems if I unmount the drive before closing or rebooting I do not have the problem.
Should the device not be un-mounted automatically when shutting down?

I may have a solution, it’s more a workaround but it work

My solution could be more simple however, it prevent conflitcs

  1. need the device to be unmounted
umount /dev/sdxx
  1. need to know the “serial” of the device
udevadm info -a -p $(udevadm info -q path -n /dev/sdx) | grep ATTRS{serial}

where sdx is your device
if the device as a serial note it as we’ll need it. and continue with step 3

If the device as no serial (the previous command return nothing, this may cause conflict if tow identical device as they could have the same ID, label, uuid and/or path.
however we need a link to the device so I chose the ID link (but we could have use the link by path by uuid or by label).

ls -l /dev/disk/by-id/*usb*

identify your device (the sdxx) and note the link some thing like /dev/disk/by-id/usb-USB_Flash_Drive-XXXXXXXXXXXXXX-0:0-part1 andgo to step 4.

  1. now we need to modify the udev rules.
    so as root edit (or create the rule file as show bellow with your favorit editor)
vim /etc/udev/rules.d/10-local.rules

On this file add this line and save the file

BUS=="usb", ATTRS{serial}=="<your_device_serial>", NAME="%k", SYMLINK="my_usb_device_symlink"

Where <your_device_serial> is the device serial we get earlyer and my_usb_device_symlink" is the name that will be use to symlink deht device on /dev/ (the symloink name must )be a name that doesn’t already appear under /dev/.

Note the symlink you enter.

4)now we need to edit the fstab to add an entry.

vim /etc/fstab

at the end of the fstab file add this line

<link_to_the_device>          <mount_point>          auto          rw,user,nosuid,noauto          0 0

where <link_to_the_device> is yout /dev/<my_usb_device_symlink> or your device ID symlink (on my exemple /dev/disk/by-id/usb-USB_Flash_Drive-XXXXXXXXXXXXXX-0:0-part1)
Just save yout fstab, and every thing should be right.

thanks for your help
I’m a bit stuck with the serail . .

I get

udevadm info -a -p $(udevadm info -q path -n /dev/sdb1) | grep ATTRS{serial}
    ATTRS{serial}=="000001044E74"
    ATTRS{serial}=="0000:00:1d.7"

two serials. Which do I use?
Could it be that one serial is for the disk and one for the external USB case that the disk is in?

Weel in fact it’s probably one for the actual usb device and the other for the controler

I think thaht the actual serial will be the first one however, retry whithout the ending |grep ATTRS(serial)

then you have a complete report of the udevinfo

look what the command return one of the multiple device will probably have something like this

ATTRS{manufacturer}=="Buffalo"
ATTRS{product}=="USB Flash Drive"
ATTRS{serial}=="000001044E74"

And the other
some thing like

ATTRS{product}=="EHCI Host Controller"
ATTRS{serial}=="0000:00:1d.7"

note that the serial may not be asociate with the good device on my exemple

SO the serial you need is the one associate with the USB Flash Drive

many thanks.
That appears to have fixed things up for me in the meantime.

it seems that an update of the file udisks in opensuse updater has corrected my original problem.
Still testing but so far so good.