Udev removable drives

We've sold a number of CRU Dataport V external removable drive units. These can connect via firewire or USB2, and are a great solution for rotating large backups offsite. The biggest problem is getting them to mount in the same place consistently.

The solution, with modern distributions, is udev.

udevinfo helps you find things to match in a rules file:
udevinfo -a -p $(udevinfo -q path -n /dev/sdb1)

Then create a rules file:
/etc/udev/rules.d/10-local.rules

  1. Freelock file for loading Dataport drives to specific device, for backup scripts

BUS=="scsi", SYSFS{vendor}=="ST325082", NAME="dataport",SYMLINK+="backup"
KERNEL=="sd?5", BUS=="scsi", SYSFS{vendor}=="ST325062", NAME="dataport",SYMLINK+="backup"
... the above show two different lines we've used, one for a firewire-mounted drive, the other to get partition #5. Slightly different vendor numbers were reported in these cases. Both of these create a /dev/dataport device, with a symlink at /dev/backup.

Note that question marks ("?") can be used to match any character. This comes in handy when newer drives of the same type are used, such as:

BUS=="scsi", SYSFS{vendor}=="ST325???", NAME="dataport",SYMLINK+="backup"

See:
  • http://ubuntuforums.org/showthread.php?t=168221&highlight=identify+removable+drive
  • http://reactivated.net/writing_udev_rules.html
for more detail.