Mapping USB modem in udev

I decided to install kernel 3.10.4 with the tuxonice patch on my Gentoo.

The result was very satisfying, many system problems disappeared, and this is considering the fact that I did not modify the old kernel configuration. The first thing I noticed is that the network finally started working properly after waking up from suspend.

But there was something that needed adjustment.

Let's start with the fact that I connected to the Internet using wvdial. In the configuration, you need to specify the modem device: Modem = /dev/ttyUSB0

Previously everything was fine. Every time I connected the modem, 4 devices appeared: ttyUSB0, ttyUSB1, ttyUSB2, ttyUSB3, and wvdial worked with the zero device.

But now, every time I reconnected, the device numbers incremented, so initially 4 devices appeared starting from 0, then 1, 2, etc. Not good.

Fortunately, this is easily fixable, you just need to create a "stable" symlink to the device in udev rules.

This is how I did it:

Create a file in nano /etc/udev/rules.d/ with the desired name, for example,

nano /etc/udev/rules.d/50-modem.rules
Next:
DRIVERS=="sierra", ATTRS{port_number}=="0", SYMLINK+="ttyUSB0"
I think some explanations are required here =)

We set the alternative address for the device using the symlink, I set it to what it was before. The first two expressions perform the selection. I made the selection based on the driver of my device (sierra in my case) and the port (0 for the device I need, since I have 4 of them).

To find the information about your device, enter, for example,

udevadm info --query=all -a -n /dev/ttyUSB0
or specify your address. Find the necessary data to form the selection and create a udev rule.

And finally, for the changes to take effect:

udevadm control --reload