You are not logged in.

#1 2009-07-31 00:30:43

klazsick
Member
Registered: 2008-07-10
Posts: 12

udev rules and automounting

I know there are easier ways to do this, but that's not the point.  I'm trying to make a udev rule to mount all my external usb drives by name.

For example: here's some of my udevadm info -a -p `udevadm info -q path -n /dev/sdb`

  looking at device '/devices/pci0000:00/0000:00:1d.7/usb1/1-3/1-3:1.0/host9/tar
get9:0:0/9:0:0:0/block/sdb':
    KERNEL=="sdb"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{range}=="16"
    ATTR{ext_range}=="256"
    ATTR{removable}=="1"
    ATTR{ro}=="0"
    ATTR{size}=="7999487"
    ATTR{capability}=="53"
    ATTR{stat}=="     112     2460     3932     5400       10        0       14 
     316        0     3120     5716"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-3/1-3:1.0/ho
st9/target9:0:0/9:0:0:0':
    KERNELS=="9:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{device_blocked}=="0"
    ATTRS{type}=="0"
    ATTRS{scsi_level}=="0"
    ATTRS{vendor}=="Apple   "
    ATTRS{model}=="iPod            "
    ATTRS{rev}=="1.62"
    ATTRS{state}=="running"
    ATTRS{timeout}=="30"
    ATTRS{iocounterbits}=="32"
    ATTRS{iorequest_cnt}=="0xd7"
    ATTRS{iodone_cnt}=="0xd7"
    ATTRS{ioerr_cnt}=="0x0"
    ATTRS{modalias}=="scsi:t-0x00"
    ATTRS{evt_media_change}=="0"
    ATTRS{queue_depth}=="1"
    ATTRS{queue_type}=="none"
    ATTRS{max_sectors}=="240"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-3':
    KERNELS=="1-3"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="c0"
    ATTRS{bMaxPower}=="500mA"
    ATTRS{urbnum}=="971"
    ATTRS{idVendor}=="05ac"
    ATTRS{idProduct}=="1205"
    ATTRS{bcdDevice}=="0001"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{speed}=="480"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="15"
    ATTRS{version}==" 2.00"
    ATTRS{maxchild}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Apple"
    ATTRS{product}=="iPod mini"
    ATTRS{serial}=="000000B70A98"

Now if i add the following rule, an iPod mini folder is created, but the problem is everything i plug into my usb drive gets a folder created.

SUBSYSTEM=="usb", DRIVER=="usb", SYMLINK+="hd-%k%n", GROUP=="storage", RUN+="/bin/mkdir '/media/%s{product}'"

I've tried adding KERNEL=="sdb" in the front, but then i don't get the folder created.  I've also tried NAME="%s{product}" and then tried to recall $name in subsequent rules, but it would create a bus folder with a couple of sub folders

On another note, if I automount the drive in udev it doesn't come up as a drive on the side panel in pcmanfm.  Is there anyway to do that?

Let me know if what i'm trying to do isn't possible.

Thanks
Jeff

Offline

#2 2009-07-31 18:45:18

djszapi
Member
From: Cambridge, United Kingdom
Registered: 2009-06-14
Posts: 1,439
Website

Re: udev rules and automounting

Hello klazsick!

What does the udevadm monitor & say to you ?

Offline

Board footer

Powered by FluxBB