Comment 5 for bug 310820

Revision history for this message
frytek (newsgrabber) wrote : Re: Tuner cards change /dev/video device node on reboot

this is how i do it, because i have a tv card and two (cheap :) webcams.
i use udev rules to create symlinks.

connect all devices. they will create /dev/video0 and /dev/video1 /dev/video2 (or something similar). write down which is which.

now, for each device type:

1.
udevinfo -a -p $(udevinfo -q path -n /dev/video0)
2.
udevinfo -a -p $(udevinfo -q path -n /dev/video1)
3.
udevinfo -a -p $(udevinfo -q path -n /dev/video2)

you will get a very loooong list of attributes. you must find something that differs your devices and is also easy to identify. it might be the vendor, model or numeric ID.

in my case i select (to give you some idea):

1.
ATTR{model}=="Labtec Webcam Elch2 "

2.
ATTR{card}=="36"
(there were probably some better options, but i found my particular card with this number on google, so it seems to be quite unique ;)

3.
ATTR{model}=="Qtec Webcam 100"

once you define these, you go to the /etc/udev/rules.d

you create 3 files, respectively:
11-labtec-webcam.rules
11-qtec-webcam.rules
11-tv-card.rules

an easy method is to copy one of existing files to a new name. inside you paste (or modify) one line (you may get it from other files from this directory) which will be as follows, respectively:

1.
ATTR{model}=="Labtec Webcam Elch2 ", SYMLINK+=labtec-cam

2.
ATTR{card}=="36", SYMLINK+=tv-card

3.
ATTR{model}=="Qtec Webcam 100", SYMLINK+=qtec-cam

after rebooting your system, you will find 3 symlinks in your /dev/ directory. they will be pointing to right devices, no matter if they are temporarily named video0, 1 or 2. in my case these are

/dev/labtec-cam, /dev/qtec-cam and /dev/tv-card

then you reconfigure your programs (tvtime, motion, xawtv - whatever you use) to use /dev/symlink instead of /dev/videoN. this means for instance that i run tvtime with this command:

tvtime -d /dev/tv-card

enjoy.