Udev: Assign unique names to your devices
[udev] was born for this job. This is fun stuff! (I'm a sick geek.)
- Make sure you've emerged [sys-fs/udev] and [sys-apps/baselayout].
- Put [/etc/udev/rules.d/10-local.rules] under version control, you're going to put your rules there.
- Make sure the kernel has the following enabled:
File systems ---> Pseudo filesystems ---> [*] /proc file system support [*] Virtual memory file system support (former shm fs)
- Run [lsusb], plug your device in, run it again and compare. This will show you the bus+device+deviceid. For USB devices, you can use the Device ID as a unique identifier.
- If needed, run [lsusb -D /proc/bus/usb/#bus#/#device#] to find out everything about your device.
- If you still want more help, plug in your device while watching /var/log/messages to get the dev path, then use this to get more udev identifiers:
udevinfo -a -p `udevinfo -q path -n /dev/sda`
- Write a rule using the selected identifier. Add it to [/etc/udev/rules.d/10-local.rules]. Here's one using a device with ID [090c:6000]:
BUS=="usb", SYSFS{idVendor}=="090c", SYSFS{idProduct}=="6000", NAME="sdhc_via_usb"
- Tell udev to reload rules, and wait for it to finish:
udevadm control --reload_rules udevadm trigger udevadm settle
- Remove and re-plugin your device. It should now show up at [/dev/your_name]!
- If it's a drive, add a mount rule to [/etc/fstab] and mount it using the new dev path. Pretty cool, eh?
- Next, we'll work on firing off a script to automount and autorun when the device is inserted...