Udev
If you want to match /dev/devicename to a device you own (such as a usb hard drive or usb hard disk) you can use udevinfo to find out what attributes you can map to:
First you run dmesg to find out what devicename has been assigned to the drive. This will be towards the bottom of the information. You can also try
dmesg | grep "Attached SCSI disk" -B1
The first line should tell you which device the computer has attatched the drive to.
udevinfo -a -p $(udevinfo -q path -n /dev/sdh1)
This will show several devices related to /dev/sdh1. You can only match rules from 1 parent device, not from multiple ones!
eg some of the output for above is:
looking at parent device '/devices/pci0000:00/0000:00:1a.7/usb4/4-4/4-4:1.0/ho st3/target3:0:0/3:0:0:0': KERNELS=="3:0:0:0" SUBSYSTEMS=="scsi" DRIVERS=="sd" ATTRS{device_blocked}=="0" ATTRS{type}=="0" ATTRS{scsi_level}=="3" ATTRS{vendor}=="Iomega " ATTRS{model}=="External HD " ATTRS{rev}==" " ATTRS{state}=="running" ATTRS{timeout}=="30" ATTRS{iocounterbits}=="32" ATTRS{iorequest_cnt}=="0x3d" ATTRS{iodone_cnt}=="0x3d" ATTRS{ioerr_cnt}=="0x0" ATTRS{modalias}=="scsi:t-0x00" ATTRS{evt_media_change}=="0" ATTRS{queue_depth}=="1" ATTRS{queue_type}=="none" ATTRS{max_sectors}=="240"
looking at parent device '/devices/pci0000:00/0000:00:1a.7/usb4/4-4': KERNELS=="4-4" SUBSYSTEMS=="usb" DRIVERS=="usb" ATTRS{configuration}=="USB Mass Storage" ATTRS{bNumInterfaces}==" 1" ATTRS{bConfigurationValue}=="1" ATTRS{bmAttributes}=="c0" ATTRS{bMaxPower}==" 2mA" ATTRS{urbnum}=="287" ATTRS{idVendor}=="059b" ATTRS{idProduct}=="0276" ATTRS{bcdDevice}=="0100" ATTRS{bDeviceClass}=="00" ATTRS{bDeviceSubClass}=="00" ATTRS{bDeviceProtocol}=="00" ATTRS{bNumConfigurations}=="1" ATTRS{bMaxPacketSize0}=="64" ATTRS{speed}=="480" ATTRS{busnum}=="4" ATTRS{devnum}=="4" ATTRS{version}==" 2.00" ATTRS{maxchild}=="0" ATTRS{quirks}=="0x0" ATTRS{authorized}=="1" ATTRS{manufacturer}=="Iomega" ATTRS{product}=="Iomega External HD" ATTRS{serial}=="948778888888"
allows you to construct the following rules to match the device:
KERNEL=="sd?1", SUBSYSTEMS=="scsi", ATTRS{model}=="External HD ", SYMLINK+="test"
KERNEL=="sd?1", SUBSYSTEMS=="usb", ATTRS{serial}=="948778888888", SYMLINK+="iomega1"
Both will work. You only have to use one.
I put these in /etc/udev/rules.d/local.rules
/etc/init.d/udev restart
and then you have to unplug and replug the device for the symlink to appear in /dev (so /dev/iomega1 or /dev/test)
In order to automount, you can add:
, RUN+="/bin/mount -t auto /dev/iomega1 /media/iomega1"
to the rule, so the above rule in local.rules becomes:
KERNEL=="sd?1", SUBSYSTEMS=="usb", ATTRS{serial}=="948778888888", SYMLINK+="iomega1", RUN+="/bin/mount -t auto /dev/iomega1 /media/iomega1"
This can all be found here
Now if you want this to automount at boot as well, you neet to
cat /etc/mtab
there you can see the fstab options you're going to need. Then you add something like
/dev/iomega1 /media/iomega1 ext3 defaults 0 0
to /etc/fstab
unmount /media/iomega1 and mount -a to test if it mounts properly.