Friday, May 9, 2008

My lastest fight with udev...

Important note: This post has been modified according to a private remark from Marco d'Itri, thanks to him for his explanations !

I've been trying for a very long while to learn to write udev rules, but I've mostly been unsuccessful, or rather, successful by chance, which is hardly better, as it implies no understanding whatsoever of what I'm doing.

My game, today, was to create a symlink for a loop device (loop7) and set the device's group to cdrom (I might elaborate some time later why I need that). So, here is what I learned:

  • at least for the GROUP= directive, the latest item in the /etc/udev/rules.d directory rules
  • to test the modifications, the best thing is to generate a synthetic add using the following snippet:
    echo add > /sys/block/loop7/uevent
    
    Many thanks to Marco d'Itri for this information !

With that in mind, the following snippet worked for me, under the name 40-private-loop.rules:

KERNEL=="loop7", SYMLINK="videoloop", GROUP="cdrom"

Enjoy !

No comments: