1 |
On Sun, May 21, 2006 at 09:03:00PM +0200, gentoo@×××××××××××××××.de wrote |
2 |
> Hello, |
3 |
> |
4 |
> I want to use linux for dvd writing and scanning. |
5 |
> Both my scanner (Canon) and my dvd writer (BenQ) are usb devices. |
6 |
> |
7 |
> How can I know which device files these devices use? Or how can I |
8 |
> configure a device file for these devices? |
9 |
|
10 |
I strongly recommend udev rules to create symlinks. The problem is |
11 |
that mass storage devices (harddrives, CDs, DVDs, flash drives, etc) are |
12 |
assigned the "next available device name". If you have 2 or more such |
13 |
devices, their entries in /dev depend on the order they're plugged in. |
14 |
udev rules allow you to create English symlinks that will always be the |
15 |
same, and will point to the correct /dev entry, regardless of order of |
16 |
plugging in. I'll run through what I did. You can follow along with |
17 |
your DVDRW. |
18 |
|
19 |
> // I guess this is the dvd writer? |
20 |
> |
21 |
> T: Bus=01 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#= 9 Spd=480 MxCh= 0 |
22 |
> D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 |
23 |
> P: Vendor=04a5 ProdID=1007 Rev= 1.12 |
24 |
> S: Product=USB 2.0 Storage Device |
25 |
> C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr= 0mA |
26 |
> I: If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage |
27 |
> E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms |
28 |
> E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=125us |
29 |
|
30 |
|
31 |
1) You must either login or su as root to do all the following. |
32 |
|
33 |
|
34 |
2) *WITHOUT* the device plugged in, execute the command "fdisk -l". |
35 |
Here's my output... |
36 |
|
37 |
[m3000][root][~] fdisk -l |
38 |
|
39 |
Disk /dev/sda: 160.0 GB, 160041885696 bytes |
40 |
255 heads, 63 sectors/track, 19457 cylinders |
41 |
Units = cylinders of 16065 * 512 = 8225280 bytes |
42 |
|
43 |
Device Boot Start End Blocks Id System |
44 |
/dev/sda1 1 1460 11727418+ 83 Linux |
45 |
/dev/sda2 1461 19457 144560902+ 5 Extended |
46 |
/dev/sda5 1461 1704 1959898+ 82 Linux swap / Solaris |
47 |
/dev/sda6 1705 19457 142600941 83 Linux |
48 |
|
49 |
|
50 |
3) Connect the device, insert media if required, and wait 60 seconds |
51 |
for the necessary hand-shaking. |
52 |
|
53 |
|
54 |
4) *WITH* the device plugged in, execute the command "fdisk -l". |
55 |
Here's my output... |
56 |
|
57 |
[m3000][root][~] fdisk -l |
58 |
|
59 |
Disk /dev/sda: 160.0 GB, 160041885696 bytes |
60 |
255 heads, 63 sectors/track, 19457 cylinders |
61 |
Units = cylinders of 16065 * 512 = 8225280 bytes |
62 |
|
63 |
Device Boot Start End Blocks Id System |
64 |
/dev/sda1 1 1460 11727418+ 83 Linux |
65 |
/dev/sda2 1461 19457 144560902+ 5 Extended |
66 |
/dev/sda5 1461 1704 1959898+ 82 Linux swap / Solaris |
67 |
/dev/sda6 1705 19457 142600941 83 Linux |
68 |
|
69 |
Disk /dev/sdb: 40.0 GB, 40060403712 bytes |
70 |
64 heads, 32 sectors/track, 38204 cylinders |
71 |
Units = cylinders of 2048 * 512 = 1048576 bytes |
72 |
|
73 |
Device Boot Start End Blocks Id System |
74 |
/dev/sdb1 1 38204 39120880 83 Linux |
75 |
|
76 |
|
77 |
5) Look for new devices (*NOT* partitions). "Disk /dev/sdb" is my |
78 |
new device... *THIS TIME*. If I unplug it, plug in one or more other |
79 |
USB devices, and plug it in again, it'll be a different device. To |
80 |
work around that hassle, we need a udev rule that creates a consistent |
81 |
symlink. |
82 |
|
83 |
|
84 |
6) Use the command "udevinfo -a -p /sys/block/??? > x.txt" to get udev |
85 |
info for your device. Note that this variant only works for block |
86 |
devices. Replace the "???" with the device name in /dev. It should be |
87 |
something like "sda" or "sdb", etc. Mine was "sdb", so... |
88 |
|
89 |
[m3000][root][~] udevinfo -a -p /sys/block/sdb > x.txt |
90 |
|
91 |
7) This will include a lot of output. It'll have the main USB bus, the |
92 |
USB ports, and also the device itself. Here's the important part for my |
93 |
"shirtpocket" USB drive... |
94 |
|
95 |
ID=="2-2" |
96 |
BUS=="usb" |
97 |
DRIVER=="usb" |
98 |
SYSFS{configuration}=="" |
99 |
SYSFS{serial}=="10000E0009C22E4B" |
100 |
SYSFS{product}=="LaCie Hard Drive USB" |
101 |
SYSFS{manufacturer}=="LaCie" |
102 |
SYSFS{maxchild}=="0" |
103 |
SYSFS{version}==" 2.00" |
104 |
SYSFS{devnum}=="2" |
105 |
SYSFS{speed}=="480" |
106 |
SYSFS{bMaxPacketSize0}=="64" |
107 |
SYSFS{bNumConfigurations}=="1" |
108 |
SYSFS{bDeviceProtocol}=="00" |
109 |
SYSFS{bDeviceSubClass}=="00" |
110 |
SYSFS{bDeviceClass}=="00" |
111 |
SYSFS{bcdDevice}=="0000" |
112 |
SYSFS{idProduct}=="0341" |
113 |
SYSFS{idVendor}=="059f" |
114 |
SYSFS{bMaxPower}==" 2mA" |
115 |
SYSFS{bmAttributes}=="c0" |
116 |
SYSFS{bConfigurationValue}=="1" |
117 |
SYSFS{bNumInterfaces}==" 1" |
118 |
|
119 |
Use any combination of the above keys that is unique enough *FOR YOUR |
120 |
NEEDS* to generate a udev rule. If you've got 3 kids with identical |
121 |
model mp3 players, and only one will connect at any time, then BUS, and |
122 |
SYSFS{idProduct}, and SYSFS{idVendor} should be sufficient to identify |
123 |
the device. If two or more will be connected simultaneously, you'll |
124 |
need to key in on SYSFS{serial} to differentiate between them. Note; |
125 |
you *MUST* copy the keys *EXACTLY*, including leading and trailing |
126 |
spaces. I suggest cut-and-paste. |
127 |
|
128 |
In addition to identifying the device on the system, you also have to |
129 |
tell udev what the device will be called, and also what symlink to use |
130 |
for it. Here is my rule for the above device; yours will obviously be |
131 |
somewhat different... |
132 |
|
133 |
BUS=="usb", SYSFS{serial}=="10000E0009C22E4B", NAME="%k", SYMLINK="PocketDrive1" |
134 |
|
135 |
The double-equals are the search criteria, which are and-ed. We want |
136 |
the first (and hopefully the only) device that we run into with BUS |
137 |
"usb" and serial number "10000E0009C22E4B". NAME="%k" means that we want |
138 |
to assign the same name that the kernel would ordinarily assign to it. |
139 |
In my case, this is /dev/sdb or whatever the first free /dev/sd? slot |
140 |
is. The SYMLINK is the important part. This is a stable name that will |
141 |
always be the same when you plug in the device. In your case I suggest |
142 |
something like SYMLINK="USB_DVDRW". |
143 |
|
144 |
Where does this rule go you ask? It goes into the file... |
145 |
/etc/udev/rules.d/10-local.rules |
146 |
It may not exist if you haven't done any udev rules. Create it if |
147 |
necessary. |
148 |
|
149 |
|
150 |
8) The rules files are normally read at boot. To implement the new rule |
151 |
without rebooting... |
152 |
- unplug the affected device |
153 |
- execute "udevstart" |
154 |
- insert the affected device |
155 |
after sevral seconds of handshaking, you should have a /dev/USB_DVDRW or |
156 |
whatever you called it. |
157 |
|
158 |
|
159 |
9) You can write CDs and DVDs and play music CDs without mounting the |
160 |
device. If you want to be able to mount it as a regular user, create a |
161 |
normal entry in /etc/fstab, using device /dev/USB_DVDRW or whatever you |
162 |
called it. |
163 |
|
164 |
|
165 |
-- |
166 |
Walter Dnes <waltdnes@××××××××.org> In linux /sbin/init is Job #1 |
167 |
My musings on technology and security at http://tech_sec.blog.ca |
168 |
-- |
169 |
gentoo-user@g.o mailing list |