Anonymous 寫:tinyding前輩您好
我發現這支隨身碟在usb、disk、scsi都會出現
使用hwinfo加--disk或--scsi為參數的結果如下:
hwinfo --disk內容如下:
- 代碼: 選擇全部
21: SCSI 00.0: 10600 Disk
[Created at block.222]
UDI: /org/freedesktop/Hal/devices/storage_serial_USB_2_0_SD_MMC_Reader____________0_0
Unique ID: jxEh.RC7PH0adNE7
Parent ID: 5YuN.IvM+kRJt5aD
SysFS ID: /block/sda
SysFS BusID: 0:0:0:0
SysFS Device Link: /devices/pci0000:00/0000:00:1d.7/usb4/4-4/4-4:1.0/host0/target0:0:0/0:0:0:0
Hardware Class: disk
Model: "USB 2.0 SD/MMC Reader"
Vendor: usb 0x14cd "USB 2.0"
Device: usb 0x6700 "SD/MMC Reader"
...
hwinfo --scsi內容如下:
20: SCSI 00.0: 10600 Disk
[Created at block.222]
UDI: /org/freedesktop/Hal/devices/storage_serial_USB_2_0_SD_MMC_Reader____________0_0
Unique ID: jxEh.RC7PH0adNE7
Parent ID: 5YuN.IvM+kRJt5aD
SysFS ID: /block/sda
SysFS BusID: 0:0:0:0
SysFS Device Link: /devices/pci0000:00/0000:00:1d.7/usb4/4-4/4-4:1.0/host0/target0:0:0/0:0:0:0
Hardware Class: disk
Model: "USB 2.0 SD/MMC Reader"
Vendor: usb 0x14cd "USB 2.0"
Device: usb 0x6700 "SD/MMC Reader"
...
謝謝您
由於這些看起來都跟 udev 有關,所以,我也去找久沒有用的讀卡機以及 CompactFlash Card 來實驗一下...
在 Ubuntu 7.10 Live CD,執行 lsusb.
- 代碼: 選擇全部
Bus 005 Device 002: ID 04cf:9920 Myson Century, Inc.
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
在 Ubuntu 7.10 Live CD,執行 lshw.
- 代碼: 選擇全部
...
*-scsi
physical id: 1
bus info: usb@5:2
logical name: scsi5
capabilities: emulated scsi-host
configuration: driver=usb-storage
*-disk:0
description: SCSI Disk
product: CS8819A2-110 0
vendor: Myson
physical id: 0.0.0
bus info: scsi@5:0.0.0
logical name: /dev/sda
version: 1.01
capabilities: removable
*-disc
physical id: 0
logical name: /dev/sda
*-disk:1
description: SCSI Disk
product: CS8819A2-110 1
vendor: Myson
physical id: 0.0.1
bus info: scsi@5:0.0.1
logical name: /dev/sdb
version: 1.01
size: 488MB
capabilities: removable
*-disc
physical id: 0
logical name: /dev/sdb
size: 488MB
capabilities: partitioned partitioned:dos
*-volume
description: FAT16 partition
physical id: 1
logical name: /dev/sdb1
capacity: 488MB
capabilities: primary bootable
*-disk:2
description: SCSI Disk
product: CS8819A2-110 2
vendor: Myson
physical id: 0.0.2
bus info: scsi@5:0.0.2
logical name: /dev/sdc
version: 1.01
capabilities: removable
*-disc
physical id: 0
logical name: /dev/sdc
*-disk:3
description: SCSI Disk
product: CS8819A2-110 3
vendor: Myson
physical id: 0.0.3
bus info: scsi@5:0.0.3
logical name: /dev/sdd
version: 1.01
capabilities: removable
*-disc
physical id: 0
logical name: /dev/sdd
也同樣是屬於 "*-scsi" ...
由於在 Ubuntu 7.10 Live CD 中,沒有 hwinfo 命令可供執行,所以,就沒有再測試下去了.
回到 Debian 的環境下 ...
debian:/dev/shm# lsusb
- 代碼: 選擇全部
Bus 005 Device 002: ID 04cf:9920 Myson Century, Inc.
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
debian:/dev/shm# lshw
- 代碼: 選擇全部
...
*-disk:1
description: SCSI Disk
product: CS8819A2-110 1
vendor: Myson
physical id: 0.0.1
bus info: scsi@5:0.0.1
logical name: /dev/sdb
version: 1.01
size: 488MiB (512MB)
capabilities: removable
*-medium
physical id: 0
logical name: /dev/sdb
size: 488MiB (512MB)
capabilities: partitioned partitioned:dos
*-volume
description: Windows FAT volume
vendor: MSDOS5.0
physical id: 1
logical name: /dev/sdb1
logical name: /media/disk
version: FAT16
serial: b88f-20b5
size: 488MiB
capacity: 488MiB
capabilities: primary bootable fat initialized
configuration: FATs=2 filesystem=fat mount.fstype=vfat mount.options=rw,nosuid,nodev,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1 state=mounted
然後,又看了幾篇 udev 的文章,也想來測試一下"當讀卡機 Plug in 時..."
debian:/dev/shm# udevinfo --query=all -a --path=/sys/block/sdb/
- 代碼: 選擇全部
...
looking at device '/block/sdb':
KERNEL=="sdb"
SUBSYSTEM=="block"
DRIVER==""
ATTR{capability}=="13"
ATTR{stat}==" 330 223 784 228 0 0 0 0 0 212 228"
ATTR{size}=="1000944"
ATTR{removable}=="1"
ATTR{range}=="16"
ATTR{dev}=="8:16"
looking at parent device '/devices/pci0000:00/0000:00:10.4/usb5/5-1/5-1:1.0/host5/target5:0:0/5:0:0:1':
KERNELS=="5:0:0:1"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{modalias}=="scsi:t-0x00"
ATTRS{ioerr_cnt}=="0x0"
ATTRS{iodone_cnt}=="0x272"
ATTRS{iorequest_cnt}=="0x272"
ATTRS{iocounterbits}=="32"
ATTRS{timeout}=="30"
ATTRS{state}=="running"
ATTRS{rev}=="1.01"
ATTRS{model}=="CS8819A2-110 1 "
ATTRS{vendor}=="Myson "
ATTRS{scsi_level}=="0"
ATTRS{type}=="0"
ATTRS{queue_type}=="none"
ATTRS{queue_depth}=="1"
ATTRS{device_blocked}=="0"
ATTRS{max_sectors}=="240"
...
然後參考這篇文章
http://www.reactivated.net/writing_udev_rules.html 並根據由上述執行 "udevinfo --query=all -a --path=/sys/block/sdb/" 命令後所得的結果,我也寫了一個 udev rule ...
debian:/etc/udev# pwd
/etc/udev
debian:/etc/udev# ls -la myself_cf_card_reader.rules
-rw-r--r-- 1 root root 128 2008-01-10 09:34 myself_cf_card_reader.rules
debian:/etc/udev# cat myself_cf_card_reader.rules
KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRS{model}=="CS8819A2-110 1 ", SYMLINK+="my_cf_card_reader%n", OPTIONS+="all_partitions"
debian:/etc/udev/rules.d# pwd
/etc/udev/rules.d
debian:/etc/udev/rules.d# ls -la z99_my*
lrwxrwxrwx 1 root root 30 2008-01-10 09:37 z99_myself_cf_reader.rules -> ../myself_cf_card_reader.rules
然後執行 udevtrigger,讓 rules 生效...
debian:/dev/shm# udevtrigger
將讀卡機拔出後再重新插入 USB 槽,然後我看到 /dev 目錄的變化...
debian:/dev# pwd
/dev
debian:/dev# ls -la my*
lrwxrwxrwx 1 root root 33 2008-01-10 09:40 my_cf_card_reader -> scsi/host6/bus0/target0/lun1/disc
lrwxrwxrwx 1 root root 34 2008-01-10 09:40 my_cf_card_reader1 -> scsi/host6/bus0/target0/lun1/part1
而 hwinfo --disk 也會記錄到這個 my_cf_card_reader ...
- 代碼: 選擇全部
...
30: SCSI 600.1: 10600 Disk
[Created at block.222]
UDI: /org/freedesktop/Hal/devices/storage_serial_Myson_CS8819A2_110_1_100_0_1
Unique ID: R0Fb.fEb7n9qmz4E
Parent ID: WQQk.rHX5uN+34wE
SysFS ID: /block/sdb
SysFS BusID: 6:0:0:1
SysFS Device Link: /devices/pci0000:00/0000:00:10.4/usb5/5-1/5-1:1.0/host6/target6:0:0/6:0:0:1
Hardware Class: disk
Model: "Myson CS8819A2-110 1"
Vendor: usb 0x04cf "Myson"
Device: usb 0x9920 "CS8819A2-110 1"
Revision: "1.01"
Driver: "usb-storage", "sd"
Driver Modules: "usb_storage"
Device File: /dev/sdb (/dev/sg1)
Device Files: /dev/sdb, /dev/scsi/host6/bus0/target0/lun1/disc, /dev/discs/disc3/disc, /dev/disk/by-id/usb-Myson_CS8819A2-110_1_100-0:1, /dev/disk/by-path/pci-0000:00:10.4-usb-0:1:1.0-scsi-0:0:0:1, /dev/my_cf_card_reader
Device Number: block 8:16-8:31 (char 21:1)
Features: Hotpluggable
Geometry (Logical): CHS 993/16/63
Size: 1000944 sectors a 512 bytes
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #18 (USB Controller)
...
不過,由於你的 Debian 系統不能正確辨識出你那台讀卡機,所以,寫個 udev rules 的方式,可能也不能發揮什麼效用? 這時,你可能要參考一下底下那篇參考文章中的 "Using external programs to name devices" 與 "Running external programs upon certain events" 節中所使用的 "PROGRAM=" 或者 "RUN+=",去指定執行一個 ShellScript or hwinfo,以便辨識出你那台讀卡機,並在執行後看需不需要 delay 個幾秒? 然後返回原先的 udev rules 中去繼續完成未完成的步驟...
Good Luck!
參考文章:
Writing udev rules:
http://www.reactivated.net/writing_udev_rules.html