On Friday 10 February 2006 00:59, Iain Buchanan wrote:
> On Thu, 2006-02-09 at 20:52 +0100, Harm Geerts wrote:
> > On Thursday 09 February 2006 06:38, Iain Buchanan wrote:
> > > This doesn't seem to be the right way to go, as I can mount the drive
> > > _without_ nls_utf8, but gnome-volume-manager can't...
> >
> > I *think* gvm uses fstab to override defaults.
> > You can try to add an entry for your usb device to /etc/fstab
> >
> > /dev/sdd1   /gvm/mountpoint vfat    
> > noauto,user,codepage=437,iocharset=iso8859
> >-1   0 0
>
> could do, but I have multiple drives (media readers, external hd's, etc)
> so I can't do this for all of them, especially when I plug them in
> random orders.  And I don't want to play with udev (just yet :)

udev is great for this.
As an example I'll try to go through the config for my usbstick.
With my thanks to http://www.reactivated.net/writing_udev_rules.html for the 
great guide, here comes the cliffnote version :)
My usbstick comes up as /dev/sdc

# udevinfo -a -p $(udevinfo -q path -n /dev/sdc)
<snipped>
  looking at device '/devices/pci0000:00/0000:00:02.1/usb1/1-9':
    ID=="1-9"
    BUS=="usb"
    DRIVER=="usb"
    SYSFS{configuration}=="Storage"
    SYSFS{serial}=="ABCD12345678"
    SYSFS{product}=="2.0 Card Driver"
    SYSFS{manufacturer}=="Singim"
    SYSFS{maxchild}=="0"
    SYSFS{version}==" 2.00"
    SYSFS{devnum}=="5"
    SYSFS{speed}=="480"
    SYSFS{bMaxPacketSize0}=="64"
    SYSFS{bNumConfigurations}=="1"
    SYSFS{bDeviceProtocol}=="00"
    SYSFS{bDeviceSubClass}=="00"
    SYSFS{bDeviceClass}=="00"
    SYSFS{bcdDevice}=="014f"
    SYSFS{idProduct}=="2005"
    SYSFS{idVendor}=="0dda"
    SYSFS{bMaxPower}=="500mA"
    SYSFS{bmAttributes}=="80"
    SYSFS{bConfigurationValue}=="1"
    SYSFS{bNumInterfaces}==" 1"

I've removed some device entries returned by udevinfo, but this is the device 
entry that is usefull for what I want. It gives us information on how I can 
let udev recognize the usbstick.

    BUS=="usb"
    SYSFS{serial}=="ABCD12345678"
    SYSFS{product}=="2.0 Card Driver"
    SYSFS{manufacturer}=="Singim"

These are the keys I'll use to match the usbstick, udevinfo already formatted 
them for use in udev rules.
Note: You cannot mix keys from different device entries!
I've chosen the device entry /devices/pci0000:00/0000:00:02.1/usb1/1-9, so I 
can only use keys from that device in the rule. 

The only exception are global keys, KERNEL (the kernel device name) is a 
global which can be used with all device entries. The usbstick came up 
as /dev/sdc, so I can use this in for the KERNEL key.

KERNEL=="sd*"

This will match sda2, sdb, sdc1 etc. so it doesn't matter in when the usbstick 
is inserted or how many partitions are on it. Now I should have enough keys 
to distinct the usbstick from other devices, I only need to name it.

NAME="%k"
%k is replaced with the kernel device name (sd*)
Note: I'm using = for assignment instead of == for matching

And now the most important part, a symlink with a fixed name so even us humans 
can recognize the usbstick. Now I will always be able to access the usbstick 
on the same location, the symlink will always point to the device file of my 
usbstick.

SYMLINK="singim%n"
%n is replaced with the partitionnumber of the drive
It creates a symlink to the value in NAME

Now I have all the data to complete the rule, the keys are seperated with a 
comma ',' 
Note: this goes on 1 line !!!
# cat /etc/udev/rules.d/10-local.rules
KERNEL=="sd*",   BUS=="usb ",SYSFS{serial}=="ABCD12345678 
",SYSFS{manufacturer}=="Singim",SYSFS{product}=="2.0Card Driver", NAME="%k", 
SYMLINK="singim%n"

After you've added/changed a rule run udevstart to let the changes take effect
# udevstart

If the device didn't show up you probably made a mistake in the udev rule

# ls -l /dev/singim*
lrwxrwxrwx 1 root root 3 feb 10 01:39 /dev/singim -> sdc
lrwxrwxrwx 1 root root 4 feb 10 01:39 /dev/singim1 -> sdc1

Done!
No matter what, my usbstick can always be accessed through /dev/singim

Note: http://www.reactivated.net mentions something about GVM not being able 
to use symlinks, in that case you could swap the NAME and SYMLINK values.
NAME="singim%n", SYMLINK="%k"

Good luck :-)
-- 
gentoo-user@gentoo.org mailing list

Reply via email to