Mounting a USB disk in a permanent location

Solution 1:

Mount the disk using udev. Place the rules from this wiki into /etc/udev/user.rules and reboot (or reconnect the USB HDD) . There are several favors of rules in the wiki (that's why I didn't list them here), choose the one that best suits your needs (e.g. you need a specific normal user to be able to unmount it).

Perusing /lib/udev/rules.d/80-udisks.rules will help you understand what's udev doing to your hard disk.

Besides the udev rules I mentioned above I think there's another approach you can take: instruct udisks (through udev) to leave your disk alone and then mount it through fstab.

This code works on my system

ACTION!="add|change", GOTO="my_udisks_end"
SUBSYSTEM!="block", GOTO="my_udisks_end"

ENV{ID_TYPE}!="disk", GOTO="my_udisks_end"
ENV{ID_BUS}!="ata", GOTO="my_udisks_end"
ENV{DEVTYPE}!="partition", GOTO="my_udisks_end"

KERNEL=="sd*|hd*", ENV{UDISKS_PRESENTATION_NOPOLICY}="1"

LABEL="my_udisks_end"

but is generic and includes all partitions. To be able to target your particular hdd/partition use udevadm info --query=all -n /dev/sdX and then match on some of those particular atributes in the udev rules.

A good resource to help you in this is Writing udev rules. Unfortunately it contains some outdated info (udevinfo was replaced by udevadm indo). I assure you, though, it's a worthwhile read -- udev is a central piece of architecture nowadays and you can accomplish a lot by using it. It's also pretty flexible.

It's also easy to make mistakes in udev rules :). Use udevadm test $(udevadm info -q path -n /dev/sdX) to take a 'peek' at what's udev doing.

Solution 2:

You could try referencing it by /dev/... instead of by UUID. It is most likely /dev/sdb*, you can check this by going to System -> Administration -> System Monitor and clicking on the 'File Systems' tab. You will need to have inserted the USB drive first and let it be automatically mounted. Replace 'UUID=uuid' with the '/dev/sdb*' in /etc/fstab. It's always a good idea to back up fstab before editing it.