My Linux Blog

Wednesday, October 04, 2006

Fixed mount point for external USB drive

I guess this is a common problem: you have an external USB drive that you want to use as if it were a permanent drive, so you want it to be mounted always at the same mount point.

Anyway, these are the steps I have followed:
i. Identify the device node your disk is mounted on. On kde (kubuntu) this is as simple as hoovering over the usb drive icon. For example, I get /dev/sdb1.
ii. Find some info regarding the usb device:
# udevinfo -a -p /sys/block/sdb/sdb1/
This spits out a lot of info. Usefull lines can be
SYSFS{idProduct}=="fc91"
SYSFS{idVendor}=="07ab"
SYSFS{manufacturer}=="Freecom Technologies"
SYSFS{maxchild}=="0"
SYSFS{product}=="FHD-3 USB2.0"
SYSFS{serial}=="1E0D377B1565F071FW415"

iii. I guess product and serial are most useful. So I added the following lines to /etc/udev/rules.d/hal.rules
BUS=="usb", SYSFS{product}=="FHD-3 USB2.0", KERNEL=="sd?1", NAME=="%k", SYSFS{serial}=="1E0D377B1565F071FW415",SYMLINK=="freecom", GROUP=="hal"

This makes sure that a fixed device node is created (/dev/freecom, in this particular example).

iv. Now the proper linecan be added to /etc/fstab, for example
/dev/freecom /media/freecom ext3 noauto,rw,user 0 0

v. This requires, of course, that the mount point exists:
#sudo mkdir /media/freecom

vi. Also, this assumes that the disk has an ext3 filesystem. If the disk is new and has no data you can do:
#sudo mkfs.ext3 /dev/freecom



Now it should be ready to go (a reboot shouldn't be needed if the propper services are restarted, but in any case it should work aftere a reboot).