[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: udev alzheimers



On Thu 21 May 2020 at 08:23:55 (-0400), Gene Heskett wrote:
> 
> Since updating to stretch, udev has been randomly swapping ttyUSB0 and 
> ttyUSB1 and sometimes ttyUSB2 around, confusing the hell out of heyu, a 
> trs-80-coco3, and occasionally even nut.  Nut (apc ups) is not on a 
> usb-serial adapter, it just a usb cable but the other 2 are on 
> individually unique FTDI adaptors. 
> 
> What udev persistent file, and where is it, do I edit

To give you a concrete example, I've attached a set of files that
I use to generate stable mountpoints (USB sticks) and symlinks
(drives) in /media when I insert known sticks or DVD-burners.

The comments in the first file explain how to find out the relevant
information for writing the others. It looks as if your serial numbers
would be a good choice to concentrate on, just like my burners.

Note that, because I'm lazy, I treat the LABELs, UUIDs and serial
numbers as unique and distinct from each other, in one mixed namespace
(the filenames in /etc/udev/rules.d/my-mountpoints/).
The mountpoint or link is the contents of the file in that directory.
Thus a 1GB USB that I acquired 2017-04-03 with USGS inscribed on it
is FAT formatted with a "UUID" 2017-0403, and generates a mountpoint
/media/usgs1g. The DVD-burner with the serial number KZ3E2DH0440
generates a link /media/cdrom3, which makes it easy to distinguish
two identical LG Slim Portables plugged in simultaneously.

> and chattr +i to 
> effect a permanent cure for this apparently random device renaming?

No. don't do that!

> And whats the command to restart udev from a clean slate without 
> rebooting?

# udevadm control -R

> These are the ttyUSB ports that need persistent names:
> 
> root@coyote:rules.d$ usb-devices|grep -C4 SERIAL
> T:  Bus=01 Lev=01 Prnt=01 Port=09 Cnt=01 Dev#=  2 Spd=12  MxCh= 0
> D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
> P:  Vendor=0403 ProdID=6001 Rev=04.00
> S:  Manufacturer=FTDI
> S:  Product=USB HS SERIAL CONVERTER
> S:  SerialNumber=FTDHG45D
> C:  #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=44mA
> I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=ftdi_sio
> 
> --
> T:  Bus=01 Lev=02 Prnt=04 Port=02 Cnt=02 Dev#=  7 Spd=12  MxCh= 0
> D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
> P:  Vendor=0403 ProdID=6001 Rev=06.00
> S:  Manufacturer=FTDI
> S:  Product=USB FAST SERIAL ADAPTER
> S:  SerialNumber=FTOOS09N
> C:  #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
> I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=ftdi_sio

Cheers,
David.
# /etc/udev/rules.d/80-mymkdir.rules last edited 2020-02-14

# $ udevadm monitor -u -p
# is used to check what udev is doing when USB devices are (un)plugged.
# $ udevadm monitor -u -p -s block/partition
# filters out all but USB sticks etc
# $ udevadm monitor -u -p -s block/disk
# filters out all but CDROM/DVD devices etc
# # udevadm control -R
# as root is used to reread the rules whenever a rule is changed.

# Don't touch swan but leave it to fstab.
ENV{ID_SERIAL_SHORT}=="W3708T01", GOTO="mymkdir_rules_end"

# Run a shell script for more flexibility with LABELs, UUIDs and so on.

ACTION=="add",    SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", RUN+="/etc/udev/rules.d/mymkdir.sh"
ACTION=="remove", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", RUN+="/etc/udev/rules.d/myrmdir.sh"

ACTION=="add",    SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", RUN+="/etc/udev/rules.d/mymkdirlnk.sh"
ACTION=="remove", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", RUN+="/etc/udev/rules.d/myrmdirlnk.sh"

LABEL="mymkdir_rules_end"
#

Attachment: mymkdir.sh
Description: Bourne shell script

Attachment: myrmdir.sh
Description: Bourne shell script

Attachment: mymkdirlnk.sh
Description: Bourne shell script

Attachment: myrmdirlnk.sh
Description: Bourne shell script

usgs1g
cdrom3

Reply to: