On Sun, May 21, 2006 at 09:03:00PM +0200, [EMAIL PROTECTED] wrote
> Hello,
> 
> I want to use linux for dvd writing and scanning.
> Both my scanner (Canon) and my dvd writer (BenQ) are usb devices.
> 
> How can I know which device files these devices use? Or how can I
> configure a device file for these devices?

  I strongly recommend udev rules to create symlinks.  The problem is
that mass storage devices (harddrives, CDs, DVDs, flash drives, etc) are
assigned the "next available device name".  If you have 2 or more such
devices, their entries in /dev depend on the order they're plugged in.
udev rules allow you to create English symlinks that will always be the
same, and will point to the correct /dev entry, regardless of order of
plugging in.  I'll run through what I did.  You can follow along with
your DVDRW.

> // I guess this is the dvd writer?
> 
> T:  Bus=01 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#=  9 Spd=480 MxCh= 0
> D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
> P:  Vendor=04a5 ProdID=1007 Rev= 1.12
> S:  Product=USB 2.0 Storage Device
> C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=  0mA
> I:  If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
> E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=125us


1) You must either login or su as root to do all the following.


2) *WITHOUT* the device plugged in, execute the command "fdisk -l".
Here's my output...

[m3000][root][~] fdisk -l

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        1460    11727418+  83  Linux
/dev/sda2            1461       19457   144560902+   5  Extended
/dev/sda5            1461        1704     1959898+  82  Linux swap / Solaris
/dev/sda6            1705       19457   142600941   83  Linux


3) Connect the device, insert media if required, and wait 60 seconds
for the necessary hand-shaking.


4) *WITH* the device plugged in, execute the command "fdisk -l".
Here's my output...

[m3000][root][~] fdisk -l

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        1460    11727418+  83  Linux
/dev/sda2            1461       19457   144560902+   5  Extended
/dev/sda5            1461        1704     1959898+  82  Linux swap / Solaris
/dev/sda6            1705       19457   142600941   83  Linux

Disk /dev/sdb: 40.0 GB, 40060403712 bytes
64 heads, 32 sectors/track, 38204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       38204    39120880   83  Linux


5) Look for new devices (*NOT* partitions).  "Disk /dev/sdb" is my
new device... *THIS TIME*.  If I unplug it, plug in one or more other
USB devices, and plug it in again, it'll be a different device.  To
work around that hassle, we need a udev rule that creates a consistent
symlink.


6) Use the command "udevinfo -a -p /sys/block/??? > x.txt" to get udev
info for your device.  Note that this variant only works for block
devices.  Replace the "???" with the device name in /dev.  It should be
something like "sda" or "sdb", etc.  Mine was "sdb", so...

[m3000][root][~] udevinfo -a -p /sys/block/sdb > x.txt

7) This will include a lot of output.  It'll have the main USB bus, the
USB ports, and also the device itself.  Here's the important part for my
"shirtpocket" USB drive...

    ID=="2-2"
    BUS=="usb"
    DRIVER=="usb"
    SYSFS{configuration}==""
    SYSFS{serial}=="10000E0009C22E4B"
    SYSFS{product}=="LaCie Hard Drive USB"
    SYSFS{manufacturer}=="LaCie"
    SYSFS{maxchild}=="0"
    SYSFS{version}==" 2.00"
    SYSFS{devnum}=="2"
    SYSFS{speed}=="480"
    SYSFS{bMaxPacketSize0}=="64"
    SYSFS{bNumConfigurations}=="1"
    SYSFS{bDeviceProtocol}=="00"
    SYSFS{bDeviceSubClass}=="00"
    SYSFS{bDeviceClass}=="00"
    SYSFS{bcdDevice}=="0000"
    SYSFS{idProduct}=="0341"
    SYSFS{idVendor}=="059f"
    SYSFS{bMaxPower}=="  2mA"
    SYSFS{bmAttributes}=="c0"
    SYSFS{bConfigurationValue}=="1"
    SYSFS{bNumInterfaces}==" 1"

  Use any combination of the above keys that is unique enough *FOR YOUR
NEEDS* to generate a udev rule.  If you've got 3 kids with identical
model mp3 players, and only one will connect at any time, then BUS, and
SYSFS{idProduct}, and SYSFS{idVendor} should be sufficient to identify
the device.  If two or more will be connected simultaneously, you'll
need to key in on SYSFS{serial} to differentiate between them.  Note;
you *MUST* copy the keys *EXACTLY*, including leading and trailing
spaces.  I suggest cut-and-paste.

  In addition to identifying the device on the system, you also have to
tell udev what the device will be called, and also what symlink to use
for it.  Here is my rule for the above device; yours will obviously be
somewhat different...

BUS=="usb", SYSFS{serial}=="10000E0009C22E4B", NAME="%k", SYMLINK="PocketDrive1"

  The double-equals are the search criteria, which are and-ed.  We want
the first (and hopefully the only) device that we run into with BUS
"usb" and serial number "10000E0009C22E4B". NAME="%k" means that we want
to assign the same name that the kernel would ordinarily assign to it.
In my case, this is /dev/sdb or whatever the first free /dev/sd? slot
is.  The SYMLINK is the important part.  This is a stable name that will
always be the same when you plug in the device.  In your case I suggest
something like SYMLINK="USB_DVDRW".

  Where does this rule go you ask?  It goes into the file...
/etc/udev/rules.d/10-local.rules
It may not exist if you haven't done any udev rules.  Create it if
necessary.


8) The rules files are normally read at boot.  To implement the new rule
without rebooting...
   - unplug the affected device
   - execute "udevstart"
   - insert the affected device
after sevral seconds of handshaking, you should have a /dev/USB_DVDRW or
whatever you called it.


9) You can write CDs and DVDs and play music CDs without mounting the
device.  If you want to be able to mount it as a regular user, create a
normal entry in /etc/fstab, using device /dev/USB_DVDRW or whatever you
called it.


-- 
Walter Dnes <[EMAIL PROTECTED]> In linux /sbin/init is Job #1
My musings on technology and security at http://tech_sec.blog.ca
-- 
gentoo-user@gentoo.org mailing list

Reply via email to