「udevルールの書き方」の編集履歴(バックアップ)一覧はこちら
「udevルールの書き方」(2007/06/21 (木) 20:38:26) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
*udevルールの書き方@CentOS5
/etc/udev/rules.d/にルールの定義ファイルがある
自分のルールを追加する場合は"10-udev-local.rules"の様に新しいファイルを作成する方がメンテしやすい
udevinfoコマンドを使うとデバイスの情報が取得できる
># udevinfo -a -p $(udevinfo -q path -n /dev/sdb)
>Udevinfo starts with the device specified by the devpath and then
>walks up the chain of parent devices. It prints for every device
>found, all possible attributes in the udev rules key format.
>A rule to match, can be composed by the attributes of the device
>and the attributes from one single parent device.
>
> looking at device '/block/sdb':
> KERNEL=="sdb"
> SUBSYSTEM=="block"
> SYSFS{stat}==" 36 47 664 886 0 0 0 0 0 577 886"
> SYSFS{size}=="235776"
> SYSFS{removable}=="1"
> SYSFS{range}=="16"
> SYSFS{dev}=="8:16"
>
> looking at parent device '/devices/pci0000:00/0000:00:07.2/usb1/1-1/1-1:1.0/host2/target2:0:0/2:0:0:0':
> ID=="2:0:0:0"
> BUS=="scsi"
> DRIVER=="sd"
> :
> SYSFS{model}=="SD R/W"
> SYSFS{vendor}=="I/O DATA"
> SYSFS{scsi_level}=="3"
> SYSFS{type}=="0"
> SYSFS{queue_type}=="none"
> SYSFS{queue_depth}=="1"
> SYSFS{device_blocked}=="0"
> SYSFS{max_sectors}=="240"
/dev/sdbの情報を取得した場合
この情報を元にudevルールを作成する
>BUS=="scsi", SYSFS{model}=="SD R/W", KERNEL=="sd?2", SYMLINK+="SD_CARD"
BUSが"scsi"で、model名が"SD R/W"でかつ"/dev/sd?2"(?は任意の一文字)にデバイスが割り当てられたら、そのリンボリックリンクを/dec/SD_CARDとして作成する
*参考リンク
[[udevルールの書き方>http://www.gentoo.gr.jp/transdocs/udevrules/udevrules.html]]