Ubuntu - How to automount an external drive at a preconfigured mount point?

13

8

Normally, when I attach an external USB drive to my Ubuntu system, the filesystem on it are automounted to /media/label. However, I'd like the filesystem to be mounted at a mount point of my choosing. I've added a line like this to my /etc/fstab:

UUID=2BE905C238C1F724   /p   ntfs-3g   defaults   0   0   # Passport 320GB

This allows me to manually mount the volume at /p by running sudo mount /p, however the filesystem is no longer automounted when the drive is attached to the PC. What do I need to do to get automount to this mount point to work, if at all possible?

Lars Haugseth

Posted 2009-08-01T16:11:02.793

Reputation: 362

1This is not a real answer, more like a workaround: If the label is unique among your media, you could make /p a symlink to /media/label. – balpha – 2009-08-01T16:14:43.003

I've always had terrible luck with external USB drives and Ubuntu. They never seem to mount in the right place - so I did the same thing as balpha. – The How-To Geek – 2009-08-01T17:50:38.063

It seems like it should be possible to override this, at least for compliant volume managers, by arranging for the volume.mount_point HAL property to be set. I have not, however, figured out how to accomplish this or make it work with Thunar's volume manager. – Michael Ekstrand – 2009-08-02T00:58:44.657

Answers

12

GeorgeM is close, but not close enough.

On Ubuntu, gnome-mount is reponsible for mounting media and also for maintaining the needed configuration. The man page of gnome-mount should tell you much more and with a little trial and error you should be able to achieve what you want.

After I played with this for a little while, I found the following:

  1. It seems you can not specifiy a mount point outside of /media
  2. You can set the mount points name by hal udi

The following command will change the settings used to mount a USB drive on my system:

gnome-mount --write-settings \
            --hal-udi /org/freedesktop/Hal/devices/volume_uuid_00AD_15D0 
            --mount-point p

When inserted, the USB drive will be mounted in /media/p

innaM

Posted 2009-08-01T16:11:02.793

Reputation: 9 208

Thanks, I'll mark this as the accepted answer, unless someone comes up with a way to achieve mounts outside /media. – Lars Haugseth – 2009-08-01T22:56:46.907

1

The mount point is determined by HAL and its complicated and arcane rules. No need to hack your fstab file.

GeorgeM

Posted 2009-08-01T16:11:02.793

Reputation: 46

0

For an external USB hard-disk formatted with ext4 (you'll need to adapt the options if using ntfs):

  • created a file 99-toshiba.rules:

    IMPORT{program}="/sbin/blkid -o udev -p %N"
    ENV{ID_FS_LABEL}!="toshiba", GOTO="toshiba_end"
    ACTION=="add", RUN+="/bin/mkdir -m 0 -p /media/toshiba", RUN+="/bin/mount -o noatime,nodiratime,errors=remount-ro /dev/%k /media/toshiba"
    ACTION=="remove", RUN+="/bin/umount -l /dev/%k", RUN+="/bin/rmdir /home/toshiba"
    LABEL="toshiba_end"
    
  • copied the file: sudo cp 99-toshiba.rules /lib/udev/rules.d/

  • reloaded the configuration sudo udevadm control --reload-rules

As you can see the I manually set the mount point to /media/toshiba but it could be anywhere.

it actually works ;-)

Francisco

Posted 2009-08-01T16:11:02.793

Reputation: 1 250