# help with udev rule[solved]

## F-0_ICE

i have been trying to write a rule so that when i plug in my ipod it is named as /dev/ipod instead of the normal /dev/sd*2

after reading the howto on udev rules i came up with this:

```
cat /etc/udev/rules.d/60-ipod.rules

BUS=="usb", SYSFS{manufacturer}=="Apple*", SYSFS{product}=="iPod*", KERNEL=="sd?2", NAME="ipod"

```

but it doesn't make /dev/ipod

however, if i remove the part KERNEL=="sd?2" /dev/ipod is created but this creates two problems 

first: the ipod has two partitions and the second one is what i use so thats why i need the KERNEL=="sd?2".

second: if i try to mount /dev/ipod mount say it is not a block device.

i don't want to use a symlink to make /dev/ipod since i can't make kde use it.

so any ideas?

TIA

----------

## PaulBredbury

 *F-0_ICE wrote:*   

> the ipod has two partitions

 

Here's how I deal with 2 partitions, using udev & fstab. A USB external drive, but same concepts I think.

----------

## F-0_ICE

i thank you for the reply.

in your example you use symlinks yes? since i can't get kde to use the syslinks i wanted to name the device itself /dev/ipod without symlinks.

----------

## PaulBredbury

Are you sure that KDE can't use symlinks? They are common:

```
find /dev -type l
```

----------

## F-0_ICE

 :Embarassed:  sorry. i probably should have explained it better.

what i mean is that kde's device manager won't accept the syslinks. it may acatually be a problem with hal but i really don't know.

i have a rule that will make a /dev/ipod symlink without trouble. 

but all the programs in kde want to use the /dev/sd* instead whether or not i have /dev/ipod in fstab.

i got this form the gentoo wiki for making the symlink:

```
BUS=="usb", SYSFS{manufacturer}=="Apple*", SYSFS{product}=="iPod*", SYMLINK+="ipod"
```

 funny thing is if i add the above mentioned KERNEL part to this rule it fails to work as well.

strange huh?

truth be told i was looking in on how to get hal to use the symlink but i couldn't find anything that worked.

thats when i looked into making /dev/ipod without using a symlink.

----------

## PaulBredbury

 *F-0_ICE wrote:*   

> SYMLINK+="ipod"

 

That will match with both partitions 1 & 2. Which makes no sense. Read man udev  - you need to match on the partition number, or use %n.

----------

## F-0_ICE

doh!   :Embarassed:   i completely missed that.

anyway when i said adding the KERNEL=="sd?2" to the rule that makes a symlink i must have been thinking of something else cause it works.

```
 BUS=="usb", SYSFS{manufacturer}=="Apple*", SYSFS{product}=="iPod*", KERNEL=="sd?2", SYMLINK+="ipod"
```

 results in:

```
ls -l /dev/ipod*

lrwxrwxrwx 1 root root 4 2007-01-24 20:35 /dev/ipod -> sdf2
```

 like it should if i don't use that kernel part it creates this:

```

ls -l /dev/ipod*

lrwxrwxrwx 1 root root  3 2007-01-24 20:31 /dev/ipod -> sdf

lrwxrwxrwx 1 root root 15 2007-01-24 20:31 /dev/ipod00 -> usbdev1.36_ep00

lrwxrwxrwx 1 root root 15 2007-01-24 20:31 /dev/ipod01 -> usbdev1.36_ep01

lrwxrwxrwx 1 root root  4 2007-01-24 20:31 /dev/ipod1 -> sdf1

lrwxrwxrwx 1 root root  4 2007-01-24 20:31 /dev/ipod2 -> sdf2

lrwxrwxrwx 1 root root 15 2007-01-24 20:31 /dev/ipod36 -> bus/usb/001/036

lrwxrwxrwx 1 root root  3 2007-01-24 20:31 /dev/ipod5 -> sg5

lrwxrwxrwx 1 root root 15 2007-01-24 20:31 /dev/ipod82 -> usbdev1.36_ep82

```

ugly right?

.

when i was reading the udev rules howto it said to be specific. so that kernel option for the rule helps with those extra symlinks.

the only thing is that i don't know how to configure kde/hal to use that symlink....then again it may already be using that but still displaying it as /dev/sdf2?

anyway i thanks you for your help since i managed to get my configs to work how i want them i am happy  :Smile:  i can eject the device from both amarok and KDE's media bar for some reason i couldn't before.

but one last question. the rule i listed in the first post do you have any idea what may be wrong with it? i keep looking over it but can't seem to find any error   :Confused: 

----------

## PaulBredbury

NAME matches with the first occurrence. Your filename is 60..., so NAME is probably set in the 50... rules. To make your rule set the NAME, move it to e.g. /etc/udev/rules.d/10-local.rules so it is processed first.

----------

## F-0_ICE

that did it! thanks very much. 

i stuck with that file name since it was used in the ipod wiki for the symlink i didn't know i would have to lower the number to make this work.

i still have much to learn. 

my thanks to you for helping   :Smile: 

----------

## PaulBredbury

 *F-0_ICE wrote:*   

> i stuck with that file name since it was used in the ipod wiki for the symlink

 

It's fine in a 60... filename, when you're only setting SYMLINK+=...

It's the NAME that acts differently, taking only its first assignment. Udev likes to confuse us  :Smile: 

----------

