Writing udev rules

atie의 이미지

udev를 사용, 사용자가 의미를 부여한 장치명을 rule로 정의하고자 할 때 유용한 글이라 링크 겁니다.
http://www.reactivated.net/udevrules.php

밑의 인용된 부분을 보고나니, udev에 대한 감이 확 오는 군요.

Quote:
As stated above, writing rules for udev is an optional process. By default, you can plug a device in, and the a relevant node (e.g. /dev/sda for a mass-storage device) will be there, just like in previous /dev implementations.

However, udev allows you to customise the naming of device nodes. There are two reasons why you might want to do this: convenience, and persistent naming.

Quote:
Example: Writing a rule for my USB printer
After plugging in my printer, I started looking around some /sys directories for a relevant place to start. I didn't get anywhere, but I noticed that my printer had been given device node /dev/lp0. udevinfo was able to provide me with a useful path:

# udevinfo -q path -n /dev/lp0
/class/usb/lp0

Running "udevinfo -a -p /sys/class/usb/lp0" provided me with a heap of info, as usual. I picked out the relevant bits for unique device identification:

looking at the device chain at '/sys/devices/pci0000:00/0000:00:02.1/usb3/3-3':
BUS="usb"
SYSFS{manufacturer}="EPSON"
SYSFS{product}="USB Printer"
SYSFS{serial}="L72010011070626380"

My udev rule becomes:

BUS="usb", SYSFS{serial}="L72010011070626380", NAME="%k", SYMLINK="epson_680"

And my printer nodes exist at /dev/lp0 (or /dev/lp1 if another printer was plugged in beforehand) and /dev/epson_680 always points at the device node for that particular printer.

Forums: 
palsuet의 이미지

많은 도움이 되었습니다. 감사합니다. ^^

feel the gravity